-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpi_code.py
38 lines (32 loc) · 1015 Bytes
/
pi_code.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
import schedule
import urllib.request, json
from microdotphat import HEIGHT, scroll, write_string, scroll_vertical, show, clear
import time
text=""
def job():
with urllib.request.urlopen("https://api.nasa.gov/insight_weather/?api_key=YOUR-API-KEY-HERE&feedtype=json&ver=1.0") as url:
data = json.loads(url.read())
days=list(data.keys())
res=[]
for el in days:
try:
res.append(int(el))
except ValueError:
pass
print(res)
for i in data[str(res[-1])].values():
mn = int((i["mn"]))
mx= int(i["mx"])
break
text = "The live temp on Mars on day "+str(res[-1])+" is max: "+str(mx)+"c and min: "+str(mn)+"c "
print(text)
write_string(text, offset_x= 0,kerning=False)
show()
job()
schedule.every().day.at("00:00").do(job)
while True:
schedule.run_pending()
scroll(amount_x=8)
show()
time.sleep(0.2)
time.sleep(1)