Improved the welcome screen enable/disable dialog

This commit is contained in:
BlueFox 2024-11-16 15:41:10 +01:00
parent e1075f8d84
commit 72bc662cb8
Signed by: BlueFox
GPG Key ID: 327233DA85435270

28
main.py
View File

@ -83,15 +83,25 @@ def timer():
return True # disable the "Quitting" message from lcdMenu
def settings():
settings_menu = lcdMenu(config.LCD, btn_mapping, scroll_direction=True, cycle=True, hide_menu_name=False, name="SETTINGS")
def swap_welcome():
config.STARTUP_WELCOME_SHOW = not config.STARTUP_WELCOME_SHOW
def toggle_show_welcome():
current_value = config.STARTUP_WELCOME_SHOW
config.LCD.clear()
config.LCD.putstr(f" Welcome Screen ")
if config.STARTUP_WELCOME_SHOW:
config.LCD.putstr("--- Enabled! ---")
else:
config.LCD.putstr("--- Disabled ---")
sleep(1)
config.LCD.putstr(f"Currently {'on' if current_value else 'off'}".center(16))
config.LCD.putstr("< keep change >")
keep_btn = config.PIN_IN_BTN_1
change_btn = config.PIN_IN_BTN_2
while True:
if keep_btn.value() == 1:
config.LCD.move_to(0,1) # move to the second row
config.LCD.putstr(f"Stay {'on' if current_value else 'off'}!".center(16))
sleep(0.5)
return True
if change_btn.value() == 1:
config.STARTUP_WELCOME_SHOW = not current_value
config.LCD.move_to(0,1) # move to the second row
config.LCD.putstr(f"Turned {'on' if not current_value else 'off'}!".center(16))
sleep(0.5)
return True
def welcome_cycles():
config.LCD.clear()
current_cycles = config.STARTUP_WELCOME_CYCLES
@ -290,7 +300,7 @@ def settings():
sleep(0.5)
return True
settings_programs = [("Show welcome", swap_welcome),
settings_programs = [("Show welcome", toggle_show_welcome),
("Welcome cycles", welcome_cycles),
("Timer 1", lambda: set_n_timer(0)),
("Timer 2", lambda: set_n_timer(1)),