Implemented reset functionality in the settings menu
This commit is contained in:
parent
f0d6b49d6e
commit
7adcdb1624
23
main.py
23
main.py
@ -228,12 +228,35 @@ def settings():
|
|||||||
config.LCD.putstr("v " + f"{current_timer_div()[0]:02d}:{current_timer_div()[1]:02d}".center(12) + " ^")
|
config.LCD.putstr("v " + f"{current_timer_div()[0]:02d}:{current_timer_div()[1]:02d}".center(12) + " ^")
|
||||||
else:
|
else:
|
||||||
right_was_released = True
|
right_was_released = True
|
||||||
|
def reset(): # reset all user-settable configuration to the default values
|
||||||
|
config.LCD.clear()
|
||||||
|
config.LCD.putstr("Sure about that?")
|
||||||
|
config.LCD.putstr("< no yes >")
|
||||||
|
no_btn = config.PIN_IN_BTN_1
|
||||||
|
yes_btn = config.PIN_IN_BTN_2
|
||||||
|
while True:
|
||||||
|
if no_btn.value() == 1:
|
||||||
|
return None
|
||||||
|
if yes_btn.value() == 1:
|
||||||
|
config.LCD.putstr("Resetting...".center(16))
|
||||||
|
config.LCD.putstr("Welcome Screen".center(16))
|
||||||
|
config.STARTUP_WELCOME_SHOW = True
|
||||||
|
config.STARTUP_WELCOME_CYCLES = 1
|
||||||
|
sleep(0.5)
|
||||||
|
config.LCD.move_to(0,1)
|
||||||
|
config.LCD.putstr("Timers".center(16))
|
||||||
|
config.TIMER_1_DURATION = 60
|
||||||
|
config.TIMER_2_DURATION = 2400
|
||||||
|
config.TIMER_3_DURATION = 2700
|
||||||
|
sleep(0.5)
|
||||||
|
return True
|
||||||
|
|
||||||
settings_programs = [("Show welcome", swap_welcome),
|
settings_programs = [("Show welcome", swap_welcome),
|
||||||
("Welcome cycles", welcome_cycles),
|
("Welcome cycles", welcome_cycles),
|
||||||
("Timer 1", lambda: set_n_timer(0)),
|
("Timer 1", lambda: set_n_timer(0)),
|
||||||
("Timer 2", lambda: set_n_timer(1)),
|
("Timer 2", lambda: set_n_timer(1)),
|
||||||
("Timer 3", lambda: set_n_timer(2)),
|
("Timer 3", lambda: set_n_timer(2)),
|
||||||
|
("Reset", reset),
|
||||||
("Exit", settings_menu.stop)]
|
("Exit", settings_menu.stop)]
|
||||||
settings_menu.setup(settings_programs) # give it the callback list
|
settings_menu.setup(settings_programs) # give it the callback list
|
||||||
settings_menu.run() # run the menu until it's closed
|
settings_menu.run() # run the menu until it's closed
|
||||||
|
Loading…
Reference in New Issue
Block a user