Restructured main.py for better readability
This commit is contained in:
parent
002b01d572
commit
91a58cca61
25
main.py
25
main.py
@ -18,15 +18,6 @@ from gc import collect # garbage collector for better memory performance
|
||||
config = utils.Config()
|
||||
btn_mapping = {"ok_btn": config.PIN_IN_BTN_1, "next_btn": config.PIN_IN_BTN_2} # the btn mapping for all lcdMenus
|
||||
|
||||
if config.STARTUP_WELCOME_SHOW:
|
||||
ws = WelcomeScreen(config.LCD,
|
||||
interrupt_pins=[config.PIN_IN_BTN_1, config.PIN_IN_BTN_2, config.PIN_IN_SWITCH],
|
||||
subtitle=config.STARTUP_PROJECT_NAME,
|
||||
starting_msg=config.STARTUP_MESSAGE_STARTING,
|
||||
started_msg=config.STARTUP_MESSAGE_FINISHED)
|
||||
ws.show(cycles=config.STARTUP_WELCOME_CYCLES)
|
||||
del ws
|
||||
collect()
|
||||
|
||||
# extra functions to access the garbage collector
|
||||
def timer():
|
||||
@ -54,7 +45,7 @@ def settings():
|
||||
collect()
|
||||
return True
|
||||
|
||||
# create the menus
|
||||
# create the main menu
|
||||
main_menu = lcdMenu(config.LCD, btn_mapping, scroll_direction=True, cycle=True, hide_menu_name=False, name="PROGRAMS")
|
||||
main_programs = [("Timer", timer),
|
||||
("Manual", manual),
|
||||
@ -62,5 +53,19 @@ main_programs = [("Timer", timer),
|
||||
("Settings", settings)]
|
||||
main_menu.setup(main_programs) # give it the callback list
|
||||
|
||||
|
||||
# -------
|
||||
|
||||
# run the welcome screen as defined in the config file
|
||||
if config.STARTUP_WELCOME_SHOW:
|
||||
ws = WelcomeScreen(config.LCD,
|
||||
interrupt_pins=[config.PIN_IN_BTN_1, config.PIN_IN_BTN_2, config.PIN_IN_SWITCH],
|
||||
subtitle=config.STARTUP_PROJECT_NAME,
|
||||
starting_msg=config.STARTUP_MESSAGE_STARTING,
|
||||
started_msg=config.STARTUP_MESSAGE_FINISHED)
|
||||
ws.show(cycles=config.STARTUP_WELCOME_CYCLES)
|
||||
del ws
|
||||
collect()
|
||||
|
||||
# and run the main menu (will be an endless loop)
|
||||
main_menu.run()
|
||||
|
Loading…
Reference in New Issue
Block a user