From 91a58cca616420cca8bb0906e46193b60fe2b7b0 Mon Sep 17 00:00:00 2001 From: BlueFox Date: Sat, 16 Nov 2024 16:38:54 +0100 Subject: [PATCH] Restructured main.py for better readability --- main.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index e7bf3a7..e1089a4 100644 --- a/main.py +++ b/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()