-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.py
60 lines (47 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from utime import sleep
from display import Display
from pico_temperature import PicoTemperature
from scheduler import Scheduler
from clock import Clock
from apps import Apps, App
from pomodoro import Pomodoro
from temperature import Temperature
from time_set import TimeSet
from wifi import WLAN
from mqtt import MQTT
from configuration import Configuration
import machine
import uasyncio
import _thread
machine.freq(250_000_000) # type: ignore
APP_CLASSES = [
Clock,
Pomodoro,
TimeSet
]
print("-" * 10)
print("PICO CLOCK")
print("-" * 10)
print("Configuring...")
config = Configuration()
scheduler = Scheduler()
wlan = WLAN(scheduler)
mqtt = MQTT(scheduler)
display = Display(scheduler)
pico_temperature = PicoTemperature(scheduler, mqtt)
temperature = Temperature(mqtt)
apps = Apps(scheduler)
# register apps
for App in APP_CLASSES:
apps.add(App(scheduler))
async def start():
print("STARTING...")
# start async scheduler
scheduler.start()
# create thread for UI updates.
_thread.start_new_thread(display.enable_leds, ())
# start apps
await apps.start()
uasyncio.run(start())
loop = uasyncio.get_event_loop()
loop.run_forever()