|
@@ -65,30 +65,44 @@ menu_position = 0 # pylint: disable=invalid-name
|
|
|
def update_menu(event_arg: None):
|
|
|
# pylint: disable=unused-argument; callback
|
|
|
alarm_hour_text_box.setColor(
|
|
|
- lcd.GREEN if menu_position == 1 else DEFAULT_FONT_COLOR
|
|
|
+ lcd.GREEN
|
|
|
+ if menu_position == 1
|
|
|
+ else (lcd.RED if menu_position == 2 else DEFAULT_FONT_COLOR)
|
|
|
)
|
|
|
alarm_minute_text_box.setColor(
|
|
|
- lcd.GREEN if menu_position == 2 else DEFAULT_FONT_COLOR
|
|
|
+ lcd.GREEN
|
|
|
+ if menu_position == 3
|
|
|
+ else (lcd.RED if menu_position == 4 else DEFAULT_FONT_COLOR)
|
|
|
)
|
|
|
|
|
|
|
|
|
def button_a_pressed():
|
|
|
global menu_position # pylint: disable=global-statement,invalid-name
|
|
|
- menu_position = (menu_position + 1) % 3
|
|
|
+ menu_position = (menu_position + 1) % 5
|
|
|
# https://docs.micropython.org/en/latest/library/micropython.html#micropython.schedule
|
|
|
- micropython.schedule(update_menu, menu_position)
|
|
|
+ micropython.schedule(update_menu, None)
|
|
|
+
|
|
|
+
|
|
|
+def update_alarm_time(event_arg: None):
|
|
|
+ # pylint: disable=unused-argument; callback
|
|
|
+ alarm_hour_text_box.setText("{:02d}".format(alarm_time["hour"]))
|
|
|
+ alarm_minute_text_box.setText("{:02d}".format(alarm_time["minute"]))
|
|
|
+ # TODO persist alarm time
|
|
|
|
|
|
|
|
|
def button_b_pressed():
|
|
|
global menu_position # pylint: disable=global-statement,invalid-name
|
|
|
if menu_position == 1:
|
|
|
alarm_time["hour"] += 1
|
|
|
- alarm_hour_text_box.setText("{:02d}".format(alarm_time["hour"]))
|
|
|
elif menu_position == 2:
|
|
|
+ alarm_time["hour"] -= 1
|
|
|
+ elif menu_position == 3:
|
|
|
alarm_time["minute"] += 1
|
|
|
- alarm_minute_text_box.setText("{:02d}".format(alarm_time["minute"]))
|
|
|
- # TODO persist alarm time
|
|
|
- # micropython.schedule(update_menu, menu_position)
|
|
|
+ elif menu_position == 4:
|
|
|
+ alarm_time["minute"] -= 1
|
|
|
+ alarm_time["hour"] %= 24
|
|
|
+ alarm_time["minute"] %= 60
|
|
|
+ micropython.schedule(update_alarm_time, None)
|
|
|
|
|
|
|
|
|
btnA.wasPressed(button_a_pressed)
|