-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (41 loc) · 1.16 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import time
from display import display
from display.display import colors
import weatherservices.smhi
import geodata
def rain_est_to_bars(est):
est = [x * 2 for x in est] # Show half mill as one bar
bars = [0] * 8
if len(est) <= 8:
bars = est
else:
for i in range(4):
bars[i] = est[i]
for i in range(4, 8):
est_i = ((i - 4) * 2 + 4)
bars[i] = est[est_i] + est[est_i + 1]
return bars
loc = geodata.Location()
loc.print()
weather = weatherservices.smhi.Smhi(loc.coordinates)
disp = display.Display(brightness=0.2)
disp.show_text(loc.city)
while True:
rain_est = weather.get_rain_estimates()
if rain_est is not None:
rain_bars = rain_est_to_bars(rain_est)
print(rain_est)
disp.show_bars(rain_bars, colors['blue'])
disp.set_pixel(0, 3, colors['white'], brightness_scale=0.86)
disp.show()
disp.status_light(colors['blue'])
else:
disp.clear()
disp.show_pixel(0, 3, colors['red'])
time.sleep(600)
disp.show_text("emilia")
disp.heart()
time.sleep(5)
disp.show_text("emilia")
disp.heart()
time.sleep(5)