diff --git a/main.py b/main.py index 903c9b0..5efe8c6 100644 --- a/main.py +++ b/main.py @@ -118,6 +118,7 @@ def settings(): config.STARTUP_WELCOME_CYCLES = current_cycles config.LCD.move_to(0,1) # move to the second row config.LCD.putstr(f"Now set to {current_cycles}".center(16)) # show a little info that it is now set + sleep(0.5) while btn_right.value() == 1 or btn_left.value() == 1: # wait till both btns are released pass return True @@ -132,6 +133,7 @@ def settings(): config.STARTUP_WELCOME_CYCLES = current_cycles config.LCD.move_to(0,1) # move to the second row config.LCD.putstr(f"Now set to {current_cycles}".center(16)) # show a little info that it is now set + sleep(0.5) while btn_right.value() == 1 or btn_left.value() == 1: # wait till both btns are released pass return True @@ -228,6 +230,42 @@ def settings(): config.LCD.putstr("v " + f"{current_timer_div()[0]:02d}:{current_timer_div()[1]:02d}".center(12) + " ^") else: right_was_released = True + def set_log_level(): + config.LCD.clear() + current_level = config.LOG_LEVEL + + config.LCD.putstr(f"{'Log level'.center(16)}\nv {str(current_level).center(12)} ^") + btn_left = config.PIN_IN_BTN_1 + btn_right = config.PIN_IN_BTN_2 + while True: + if btn_left.value() == 1: + sleep(0.1) # this value is a good compromise between being able to press both buttons and a fast up/down speed + if btn_right.value() == 1: + config.LOG_LEVEL = current_level + config.LCD.move_to(0,1) # move to the second row + config.LCD.putstr(f"Now set to {current_level}".center(16)) # show a little info that it is now set + sleep(0.5) + while btn_right.value() == 1 or btn_left.value() == 1: # wait till both btns are released + pass + return True + + current_level -= 1 + if current_level < 1: current_level = 3 + config.LCD.putstr(f"{'Log level'.center(16)}\nv {str(current_level).center(12)} ^") + if btn_right.value() == 1: + sleep(0.1) + if btn_left.value() == 1: + config.LOG_LEVEL = current_level + config.LCD.move_to(0,1) # move to the second row + config.LCD.putstr(f"Now set to {current_level}".center(16)) # show a little info that it is now set + sleep(0.5) + while btn_right.value() == 1 or btn_left.value() == 1: # wait till both btns are released + pass + return True + current_level += 1 + if current_level > 3: current_level = 1 + config.LCD.putstr(f"{'Log level'.center(16)}\nv {str(current_level).center(12)} ^") + def reset(): # reset all user-settable configuration to the default values config.LCD.clear() config.LCD.putstr("Sure about that?") @@ -249,6 +287,10 @@ def settings(): config.TIMER_2_DURATION = 2400 config.TIMER_3_DURATION = 2700 sleep(0.5) + config.LCD.move_to(0,1) + config.LCD.putstr("Logging".center(16)) + config.LOG_LEVEL = 2 + sleep(0.5) return True settings_programs = [("Show welcome", swap_welcome), @@ -256,6 +298,7 @@ def settings(): ("Timer 1", lambda: set_n_timer(0)), ("Timer 2", lambda: set_n_timer(1)), ("Timer 3", lambda: set_n_timer(2)), + ("Log level", set_log_level), ("Reset", reset), ("Exit", settings_menu.stop)] settings_menu.setup(settings_programs) # give it the callback list