Skip to content

Commit 810c12d

Browse files
committed
i dunno just use black i guess
1 parent f6f6d30 commit 810c12d

File tree

1 file changed

+23
-25
lines changed
  • MagTag/MagTag_Weather/openmeteo

1 file changed

+23
-25
lines changed

MagTag/MagTag_Weather/openmeteo/code.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
from adafruit_magtag.magtag import MagTag
1212

1313
# --| USER CONFIG |--------------------------
14-
LAT = 47.6 # latitude
15-
LON = -122.3 # longitude
16-
TMZ = "America/Los_Angeles" # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
17-
METRIC = False # set to True for metric units
18-
CITY = None # optional
14+
LAT = 47.6 # latitude
15+
LON = -122.3 # longitude
16+
TMZ = "America/Los_Angeles" # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
17+
METRIC = False # set to True for metric units
18+
CITY = None # optional
1919
# -------------------------------------------
2020

2121
# ----------------------------
@@ -58,15 +58,15 @@
5858

5959
# Map the above WMO codes to index of icon in 3x3 spritesheet
6060
WMO_CODE_TO_ICON = (
61-
(0,), # 0 = sunny
62-
(1,), # 1 = partly sunny/cloudy
63-
(2,), # 2 = cloudy
64-
(3,), # 3 = very cloudy
65-
(61, 63, 65), # 4 = rain
66-
(51, 53, 55, 80, 81, 82), # 5 = showers
67-
(95, 96, 99), # 6 = storms
68-
(56, 57, 66, 67, 71, 73, 75, 77, 85, 86), # 7 = snow
69-
(45, 48), # 8 = fog and stuff
61+
(0,), # 0 = sunny
62+
(1,), # 1 = partly sunny/cloudy
63+
(2,), # 2 = cloudy
64+
(3,), # 3 = very cloudy
65+
(61, 63, 65), # 4 = rain
66+
(51, 53, 55, 80, 81, 82), # 5 = showers
67+
(95, 96, 99), # 6 = storms
68+
(56, 57, 66, 67, 71, 73, 75, 77, 85, 86), # 7 = snow
69+
(45, 48), # 8 = fog and stuff
7070
)
7171

7272
magtag = MagTag()
@@ -85,8 +85,9 @@
8585
# /////////////////////////////////////////////////////////////////////////
8686
# helper functions
8787

88+
8889
def get_forecast():
89-
URL = f"https://api.open-meteo.com/v1/forecast?latitude={LAT}&longitude={LON}&"
90+
URL = f"https://api.open-meteo.com/v1/forecast?latitude={LAT}&longitude={LON}&"
9091
URL += "daily=weather_code,temperature_2m_max,temperature_2m_min"
9192
URL += ",sunrise,sunset,wind_speed_10m_max,wind_direction_10m_dominant"
9293
URL += "&timeformat=unixtime"
@@ -165,10 +166,7 @@ def update_today(data):
165166
s = data["daily"]["time"][0] + data["utc_offset_seconds"]
166167
t = time.localtime(s)
167168
today_date.text = "{} {} {}, {}".format(
168-
DAYS[t.tm_wday].upper(),
169-
MONTHS[t.tm_mon - 1].upper(),
170-
t.tm_mday,
171-
t.tm_year
169+
DAYS[t.tm_wday].upper(), MONTHS[t.tm_mon - 1].upper(), t.tm_mday, t.tm_year
172170
)
173171
# weather icon
174172
w = data["daily"]["weather_code"][0]
@@ -191,14 +189,14 @@ def update_future(data):
191189
"""Update the future forecast info."""
192190
for i, banner in enumerate(future_banners):
193191
# day of week
194-
s = data["daily"]["time"][i+1] + data["utc_offset_seconds"]
192+
s = data["daily"]["time"][i + 1] + data["utc_offset_seconds"]
195193
t = time.localtime(s)
196194
banner[0].text = DAYS[t.tm_wday][:3].upper()
197195
# weather icon
198-
w = data["daily"]["weather_code"][i+1]
196+
w = data["daily"]["weather_code"][i + 1]
199197
banner[1][0] = next(x for x, t in enumerate(WMO_CODE_TO_ICON) if w in t)
200198
# temperature
201-
t = data["daily"]["temperature_2m_max"][i+1]
199+
t = data["daily"]["temperature_2m_max"][i + 1]
202200
banner[2].text = temperature_text(t)
203201

204202

@@ -303,8 +301,8 @@ def go_to_sleep(current_time_secs):
303301
time.sleep(magtag.display.time_to_refresh + 1)
304302

305303
print("Sleeping...")
306-
h, m, s = (int(t) for t in resp_data.headers['date'].split(" ")[4].split(':'))
307-
current_time_secs = (h * 3600) + (m * 60) + (s) + forecast_data['utc_offset_seconds']
304+
h, m, s = (int(t) for t in resp_data.headers["date"].split(" ")[4].split(":"))
305+
current_time_secs = (h * 3600) + (m * 60) + (s) + forecast_data["utc_offset_seconds"]
308306
go_to_sleep(current_time_secs)
309307
# entire code will run again after deep sleep cycle
310-
# similar to hitting the reset button
308+
# similar to hitting the reset button

0 commit comments

Comments
 (0)