From 6e26c01de042480f5b843b4fce1cefb70fcfe307 Mon Sep 17 00:00:00 2001 From: voloved <36523934+voloved@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:18:56 -0400 Subject: [PATCH] Holding light button on a non-element screen will turn on the light (#2) * Holding light button on a non-element screen will turn on the light. * The alarm and led button press moves back to the currently-selected element symbol page rather than the next and previous one * Usage update --- .../watch_faces/complication/periodic_face.c | 44 +++++++++---------- .../watch_faces/complication/periodic_face.h | 15 +++---- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/movement/watch_faces/complication/periodic_face.c b/movement/watch_faces/complication/periodic_face.c index 162d3e42..85753ffb 100644 --- a/movement/watch_faces/complication/periodic_face.c +++ b/movement/watch_faces/complication/periodic_face.c @@ -35,7 +35,6 @@ static uint8_t _ts_ticks = 0; static int16_t _text_pos; static const char* _text_looping; static const char title_text[] = "Periodic Table"; -static bool _led_on = false; void periodic_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) { @@ -412,38 +411,39 @@ bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, v _handle_mode_still_pressed(state, settings->bit.button_should_sound); break; case EVENT_LIGHT_BUTTON_UP: - if (!_led_on) _handle_backward(state, settings->bit.button_should_sound); - if (!watch_get_pin_level(BTN_ALARM)) _led_on = false; + if (state->mode <= SCREEN_ELEMENT) { + _handle_backward(state, settings->bit.button_should_sound); + } + else { + state->mode = SCREEN_ELEMENT; + _display_screen(state, settings->bit.button_should_sound); + } + break; + case EVENT_LIGHT_BUTTON_DOWN: break; case EVENT_ALARM_BUTTON_UP: - if (!_led_on) _handle_forward(state, settings->bit.button_should_sound); - if (!watch_get_pin_level(BTN_LIGHT)) _led_on = false; + if (state->mode <= SCREEN_ELEMENT) { + _handle_forward(state, settings->bit.button_should_sound); + } + else { + state->mode = SCREEN_ELEMENT; + _display_screen(state, settings->bit.button_should_sound); + } break; case EVENT_ALARM_LONG_PRESS: - if (!_led_on) { + if (state->mode <= SCREEN_ELEMENT) { start_quick_cyc(); _handle_forward(state, settings->bit.button_should_sound); } break; case EVENT_LIGHT_LONG_PRESS: - if (!_led_on) { + if (state->mode <= SCREEN_ELEMENT) { start_quick_cyc(); _handle_backward(state, settings->bit.button_should_sound); } - break; - case EVENT_LIGHT_BUTTON_DOWN: - if (watch_get_pin_level(BTN_ALARM)) _led_on = true; - stop_quick_cyc(); - break; - case EVENT_ALARM_BUTTON_DOWN: - if (watch_get_pin_level(BTN_LIGHT)) _led_on = true; - stop_quick_cyc(); - break; - case EVENT_LIGHT_LONG_UP: - _led_on = false; - break; - case EVENT_ALARM_LONG_UP: - _led_on = false; + else { + movement_illuminate_led(); + } break; case EVENT_MODE_BUTTON_UP: if (state->mode == SCREEN_TITLE) movement_move_to_next_face(); @@ -488,8 +488,6 @@ bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, v return movement_default_loop_handler(event, settings); } - if (_led_on) movement_illuminate_led(); - return true; } diff --git a/movement/watch_faces/complication/periodic_face.h b/movement/watch_faces/complication/periodic_face.h index c3100824..730b0fe0 100644 --- a/movement/watch_faces/complication/periodic_face.h +++ b/movement/watch_faces/complication/periodic_face.h @@ -50,18 +50,17 @@ * If you are in a subscreen and just keep holding MODE, you will go through all of these menus without needing to depress. * * Light Press - * Previous Element + * On Title or Element Symbol Screen: Previous Element + * Else: Display currenlt-selected element symbol page * Light Hold - * Fast Cycle through Previous Elements + * On Title Screen or Element Symbol: Fast Cycle through Previous Elements + * Else: Activate LED backlight * * Alarm Press - * Next Element + * On Title or Element Symbol Screen: Next Element + * Else: Display currenlt-selected element symbol page * Alarm Hold - * Fast Cycle through Next Elements - * - * Light & Alarm Hold - * Activate LED backlight - * + * On Title Screen or Element Symbol: Fast Cycle through Next Elements */ #define MODE_VIEW 0