-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (68 loc) · 1.47 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import utime
import machine
print("Waiting 3s")
utime.sleep(1)
print("DONE")
print("Connecting to wifi", end="")
import network
network.hostname('abfahrtsdisplay')
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("Nerdberg", "ADD_WIFI_PASSWORD")
print("...", end="")
for i in range(20):
if wlan.isconnected():
break
print(".", end="")
utime.sleep(1)
if wlan.isconnected():
print("DONE")
else:
print("FAILED")
print("Resetting...")
utime.sleep(3)
machine.soft_reset()
ntp_synced = False
print("Initial NTP sync...", end="")
for i in range(5):
try:
import ntptime
ntptime.settime()
print("DONE")
ntp_synced = True
break
except:
print(".", end="")
utime.sleep(1)
if not ntp_synced:
print("FAILED")
print("Resetting...")
utime.sleep(3)
machine.soft_reset()
try:
import webrepl_cfg
print("WebREPL Password: " + webrepl_cfg.PASS)
except:
pass
import webrepl
webrepl.start()
import display
import sys
import time
from display import display_manual
last_exception = None
try:
display.setup()
while True:
display.mainloop()
except Exception as e:
print("Exception occured")
sys.print_exception(e)
last_exception = e
display_manual(type(e).__name__)
for i in range(4):
display.zeile2_scroll_msg(str(e))
display_manual(type(e).__name__, "Reset in 10s")
print("Resetting in 10s")
time.sleep(30)
machine.soft_reset()