forked from hishizuka/pizero_bikecomputer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pizero_bikecomputer.py
executable file
·63 lines (49 loc) · 1.88 KB
/
pizero_bikecomputer.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
#!/usr/bin/python3
from logger import app_logger
from modules.utils.timer import Timer, log_timers
def main():
app_logger.info("########## INITIALIZE START ##########")
# ensure visually alignment for log
timers = [
Timer(auto_start=False, text=" config import : {0:.3f} sec"),
Timer(auto_start=False, text=" config init : {0:.3f} sec"),
Timer(auto_start=False, text=" display import: {0:.3f} sec"),
Timer(auto_start=False, text=" display init : {0:.3f} sec"),
Timer(auto_start=False, text=" import gui : {0:.3f} sec"),
Timer(auto_start=False, text=" import logger : {0:.3f} sec"),
]
with timers[0]:
from modules import config
with timers[1]:
config = config.Config()
# display
with timers[2]:
from modules.display.display_core import init_display
with timers[3]:
config.set_display(init_display(config))
# minimal gui
with timers[4]:
if config.G_GUI_MODE == "PyQt":
from modules import gui_pyqt
elif config.G_GUI_MODE == "QML":
from modules import gui_qml
elif config.G_GUI_MODE == "Kivy":
from modules import gui_kivy
else:
raise ValueError(f"{config.G_GUI_MODE} mode not supported")
with timers[5]:
from modules import logger_core
logger = logger_core.LoggerCore(config)
config.set_logger(logger)
app_logger.info("Initialize modules:")
total_time = log_timers(timers, text_total=" total : {0:.3f} sec")
app_logger.info("########## INITIALIZE END ##########")
config.boot_time += total_time
if config.G_GUI_MODE == "PyQt":
gui_pyqt.GUI_PyQt(config)
elif config.G_GUI_MODE == "QML":
gui_qml.GUI_QML(config)
elif config.G_GUI_MODE == "Kivy":
gui_kivy.GUI_Kivy(config)
if __name__ == "__main__":
main()