Skip to content

Commit 5fb905f

Browse files
committed
the lint is high and i'm movin on...
1 parent b770895 commit 5fb905f

2 files changed

Lines changed: 33 additions & 31 deletions

File tree

PyPortal_Tides/pp_tides.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
DATE_COLOR = 0xFFFFFF # date and time color
1212
#-------------------------------------------
1313

14+
# pylint: disable=line-too-long
1415
DATA_SOURCE = "https://tidesandcurrents.noaa.gov/api/datagetter?date=today&product=predictions&datum=mllw&interval=hilo&format=json&units=metric&time_zone=lst_ldt&station="+STATION_ID
1516
DATA_LOCATION = ["predictions"]
1617

@@ -50,37 +51,37 @@ def get_tide_info():
5051
raw_info = pyportal.fetch()
5152

5253
# Return will be a dictionary of lists containing tide times
53-
tide_info = {"H":[], "L":[]}
54+
new_tide_info = {"H":[], "L":[]}
5455

5556
# Parse out the tide time info
5657
for info in raw_info:
5758
tide_type = info["type"]
5859
tide_time = info["t"].split(" ")[1]
59-
tide_info[tide_type].append(tide_time)
60+
new_tide_info[tide_type].append(tide_time)
6061

61-
return tide_info
62+
return new_tide_info
6263

63-
def update_display(current_time, update_tides=False):
64+
def update_display(time_info, update_tides=False):
6465
"""Update the display with current info."""
6566

6667
# Tide time info
6768
if update_tides:
6869
# out with the old
69-
for label in HI_LABELS + LO_LABELS:
70-
label.text = ""
70+
for tide_label in HI_LABELS + LO_LABELS:
71+
tide_label.text = ""
7172
# in with the new
7273
for i, hi_time in enumerate(tide_info["H"]):
7374
HI_LABELS[i].text = hi_time
7475
for i, lo_time in enumerate(tide_info["L"]):
7576
LO_LABELS[i].text = lo_time
7677

7778
# Date and time
78-
DATE_LABEL.text = "{:04}-{:02}-{:02} {:02}:{:02}:{:02}".format(current_time.tm_year,
79-
current_time.tm_mon,
80-
current_time.tm_mday,
81-
current_time.tm_hour,
82-
current_time.tm_min,
83-
current_time.tm_sec)
79+
DATE_LABEL.text = "{:04}-{:02}-{:02} {:02}:{:02}:{:02}".format(time_info.tm_year,
80+
time_info.tm_mon,
81+
time_info.tm_mday,
82+
time_info.tm_hour,
83+
time_info.tm_min,
84+
time_info.tm_sec)
8485

8586
board.DISPLAY.refresh_soon()
8687

@@ -100,4 +101,4 @@ def update_display(current_time, update_tides=False):
100101
new_tides = True
101102
current_yday = current_time.tm_yday
102103
update_display(current_time, new_tides)
103-
time.sleep(0.5)
104+
time.sleep(0.5)

PyPortal_Tides/pp_tides_graphical.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
VSCALE = 20 # vertical plot scale
1717
#-------------------------------------------
1818

19+
# pylint: disable=line-too-long
1920
DATA_SOURCE = "https://tidesandcurrents.noaa.gov/api/datagetter?date=today&product=predictions&datum=mllw&format=json&units=metric&time_zone=lst_ldt&station="+STATION_ID
2021
DATA_LOCATION = ["predictions"]
2122

@@ -57,8 +58,8 @@
5758

5859
# Setup current time marker
5960
time_marker_bitmap = displayio.Bitmap(MARK_SIZE, MARK_SIZE, 3)
60-
for i in range(MARK_SIZE * MARK_SIZE):
61-
time_marker_bitmap[i] = 2
61+
for pixel in range(MARK_SIZE * MARK_SIZE):
62+
time_marker_bitmap[pixel] = 2
6263
time_marker = displayio.TileGrid(time_marker_bitmap, pixel_shader=palette, x=-MARK_SIZE, y=-MARK_SIZE)
6364
pyportal.splash.append(time_marker)
6465

@@ -69,20 +70,20 @@ def get_tide_data():
6970
raw_data = pyportal.fetch()
7071

7172
# Results will be stored in a list that is display WIDTH long
72-
tide_data = [None]*WIDTH
73+
new_tide_data = [None]*WIDTH
7374

7475
# Convert raw data to display coordinates
7576
for data in raw_data:
76-
d, t = data["t"].split(" ") # date and time
77+
_, t = data["t"].split(" ") # date and time
7778
h, m = t.split(":") # hours and minutes
7879
v = data["v"] # water level
7980
x = round( (WIDTH - 1) * (60 * float(h) + float(m)) / 1440 )
8081
y = (HEIGHT // 2) - round(VSCALE * float(v))
8182
y = 0 if y < 0 else y
8283
y = HEIGHT-1 if y >= HEIGHT else y
83-
tide_data[x] = y
84+
new_tide_data[x] = y
8485

85-
return tide_data
86+
return new_tide_data
8687

8788
def draw_data_point(x, y, size=PLOT_SIZE, color=1):
8889
"""Draw data point on to the tide plot bitmap at (x,y)."""
@@ -96,10 +97,10 @@ def draw_data_point(x, y, size=PLOT_SIZE, color=1):
9697
except IndexError:
9798
pass
9899

99-
def draw_time_marker(current_time):
100+
def draw_time_marker(time_info):
100101
"""Draw a marker on the tide plot for the current time."""
101-
h = current_time.tm_hour
102-
m = current_time.tm_min
102+
h = time_info.tm_hour
103+
m = time_info.tm_min
103104
x = round( (WIDTH - 1) * (60 * float(h) + float(m)) / 1440 )
104105
y = tide_data[x]
105106
if y is not None:
@@ -108,7 +109,7 @@ def draw_time_marker(current_time):
108109
time_marker.x = x
109110
time_marker.y = y
110111

111-
def update_display(current_time, update_tides=False):
112+
def update_display(time_info, update_tides=False):
112113
"""Update the display with current info."""
113114

114115
# Tide data plot
@@ -121,15 +122,15 @@ def update_display(current_time, update_tides=False):
121122
draw_data_point(x, tide_data[x])
122123

123124
# Current location marker
124-
draw_time_marker(current_time)
125+
draw_time_marker(time_info)
125126

126127
# Date and time
127-
date_label.text = "{:04}-{:02}-{:02}".format(current_time.tm_year,
128-
current_time.tm_mon,
129-
current_time.tm_mday)
130-
time_label.text = "{:02}:{:02}:{:02}".format(current_time.tm_hour,
131-
current_time.tm_min,
132-
current_time.tm_sec)
128+
date_label.text = "{:04}-{:02}-{:02}".format(time_info.tm_year,
129+
time_info.tm_mon,
130+
time_info.tm_mday)
131+
time_label.text = "{:02}:{:02}:{:02}".format(time_info.tm_hour,
132+
time_info.tm_min,
133+
time_info.tm_sec)
133134

134135
board.DISPLAY.refresh_soon()
135136

@@ -149,4 +150,4 @@ def update_display(current_time, update_tides=False):
149150
new_tides = True
150151
current_yday = current_time.tm_yday
151152
update_display(current_time, new_tides)
152-
time.sleep(0.5)
153+
time.sleep(0.5)

0 commit comments

Comments
 (0)