diff options
Diffstat (limited to 'movement')
-rw-r--r-- | movement/movement.c | 38 | ||||
-rw-r--r-- | movement/movement.h | 3 | ||||
-rw-r--r-- | movement/template/template.c | 16 | ||||
-rw-r--r-- | movement/watch_faces/clock/simple_clock_face.c | 8 | ||||
-rw-r--r-- | movement/watch_faces/clock/world_clock_face.c | 8 | ||||
-rw-r--r-- | movement/watch_faces/complication/moon_phase_face.c | 8 | ||||
-rw-r--r-- | movement/watch_faces/complication/stopwatch_face.c | 5 | ||||
-rw-r--r-- | movement/watch_faces/complication/sunrise_sunset_face.c | 7 | ||||
-rw-r--r-- | movement/watch_faces/settings/preferences_face.c | 8 | ||||
-rw-r--r-- | movement/watch_faces/settings/set_time_face.c | 2 |
10 files changed, 48 insertions, 55 deletions
diff --git a/movement/movement.c b/movement/movement.c index 6c5f93a0..1a646e25 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -218,6 +218,30 @@ void movement_illuminate_led(void) { } } +bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) { + (void)settings; + + switch (event.event_type) { + case EVENT_MODE_BUTTON_UP: + movement_move_to_next_face(); + break; + case EVENT_LIGHT_BUTTON_DOWN: + movement_illuminate_led(); + break; + case EVENT_MODE_LONG_PRESS: + if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_watch_face == 0) { + movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX); + } else { + movement_move_to_face(0); + } + break; + default: + break; + } + + return true; +} + void movement_move_to_face(uint8_t watch_face_index) { movement_state.watch_face_changed = true; movement_state.next_watch_face = watch_face_index; @@ -448,20 +472,6 @@ bool app_loop(void) { if (event.event_type) { event.subsecond = movement_state.subsecond; can_sleep = watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]); - - // Long-pressing MODE brings one back to the first face, provided that the watch face hasn't decided to send them elsewhere - // (and we're not currently on the first face). If we're currently on the first face, a long press - // of MODE sends us to the secondary faces (if defined). - // Note that it's the face's responsibility to provide some way to get to the next face, so if EVENT_MODE_BUTTON_* is - // used for face functionality EVENT_MODE_LONG_PRESS should probably be handled and next_face() triggered in the face - // (which would effectively disable the normal 'long press to face 0' behaviour). - if (event.event_type == EVENT_MODE_LONG_PRESS - && !movement_state.watch_face_changed) { - if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_watch_face == 0) { - movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX); - } - } - event.event_type = EVENT_NONE; } // if we have timed out of our timeout countdown, give the app a hint that they can resign. diff --git a/movement/movement.h b/movement/movement.h index 7b5c4647..66bf6af4 100644 --- a/movement/movement.h +++ b/movement/movement.h @@ -285,6 +285,9 @@ typedef struct { void movement_move_to_face(uint8_t watch_face_index); void movement_move_to_next_face(void); + +bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings); + void movement_illuminate_led(void); void movement_request_tick_frequency(uint8_t freq); diff --git a/movement/template/template.c b/movement/template/template.c index 91611d08..f0669d37 100644 --- a/movement/template/template.c +++ b/movement/template/template.c @@ -53,13 +53,10 @@ bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t * case EVENT_TICK: // If needed, update your display here. break; - case EVENT_MODE_BUTTON_UP: - // You shouldn't need to change this case; Mode almost always moves to the next watch face. - movement_move_to_next_face(); - break; case EVENT_LIGHT_BUTTON_UP: - // If you have other uses for the Light button, you can opt not to illuminate the LED for this event. - movement_illuminate_led(); + // You can use the Light button for your own purposes. Note that by default, Movement will also + // illuminatethe LED in response to EVENT_LIGHT_BUTTON_DOWN; to suppress that behavior, add an + // empty case for EVENT_LIGHT_BUTTON_DOWN. break; case EVENT_ALARM_BUTTON_UP: // Just in case you have need for another button. @@ -76,7 +73,12 @@ bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t * // watch_start_tick_animation(500); break; default: - break; + // Movement's default loop handler will step in for any cases you don't handle above: + // * EVENT_LIGHT_BUTTON_DOWN lights the LED + // * EVENT_MODE_BUTTON_UP moves to the next watch face in the list + // * EVENT_MODE_LONG_PRESS returns to the first watch face (or skips to the secondary watch face, if configured) + // You can override any of these behaviors by adding a case for these events to this switch statement. + return movement_default_loop_handler(event, settings); } // return true if the watch can enter standby mode. If you are PWM'ing an LED or buzzing the buzzer here, diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c index 179b23d6..91400b6c 100644 --- a/movement/watch_faces/clock/simple_clock_face.c +++ b/movement/watch_faces/clock/simple_clock_face.c @@ -128,12 +128,6 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting // handle alarm indicator if (state->alarm_enabled != settings->bit.alarm_enabled) _update_alarm_indicator(settings->bit.alarm_enabled, state); break; - case EVENT_MODE_BUTTON_UP: - movement_move_to_next_face(); - return false; - case EVENT_LIGHT_BUTTON_DOWN: - movement_illuminate_led(); - break; case EVENT_ALARM_LONG_PRESS: state->signal_enabled = !state->signal_enabled; if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL); @@ -155,7 +149,7 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting } break; default: - break; + return movement_default_loop_handler(event, settings); } return true; diff --git a/movement/watch_faces/clock/world_clock_face.c b/movement/watch_faces/clock/world_clock_face.c index 4004bab2..b12d9cdf 100644 --- a/movement/watch_faces/clock/world_clock_face.c +++ b/movement/watch_faces/clock/world_clock_face.c @@ -113,18 +113,12 @@ static bool world_clock_face_do_display_mode(movement_event_t event, movement_se } watch_display_string(buf, pos); break; - case EVENT_MODE_BUTTON_UP: - movement_move_to_next_face(); - return false; - case EVENT_LIGHT_BUTTON_DOWN: - movement_illuminate_led(); - break; case EVENT_ALARM_LONG_PRESS: movement_request_tick_frequency(4); state->current_screen = 1; break; default: - break; + return movement_default_loop_handler(event, settings); } return true; diff --git a/movement/watch_faces/complication/moon_phase_face.c b/movement/watch_faces/complication/moon_phase_face.c index eb919375..9aac374a 100644 --- a/movement/watch_faces/complication/moon_phase_face.c +++ b/movement/watch_faces/complication/moon_phase_face.c @@ -155,12 +155,6 @@ bool moon_phase_face_loop(movement_event_t event, movement_settings_t *settings, watch_display_string(" ", 8); if (!watch_tick_animation_is_running()) watch_start_tick_animation(1000); break; - case EVENT_MODE_BUTTON_UP: - movement_move_to_next_face(); - break; - case EVENT_LIGHT_BUTTON_DOWN: - movement_illuminate_led(); - break; case EVENT_ALARM_BUTTON_UP: // Pressing the alarm adds an offset of one day to the displayed value, // so you can see moon phases in the future. @@ -171,7 +165,7 @@ bool moon_phase_face_loop(movement_event_t event, movement_settings_t *settings, // QUESTION: Should timeout reset offset to 0? break; default: - break; + return movement_default_loop_handler(event, settings); } return true; diff --git a/movement/watch_faces/complication/stopwatch_face.c b/movement/watch_faces/complication/stopwatch_face.c index 2a69e9d5..03a74697 100644 --- a/movement/watch_faces/complication/stopwatch_face.c +++ b/movement/watch_faces/complication/stopwatch_face.c @@ -107,9 +107,6 @@ bool stopwatch_face_loop(movement_event_t event, movement_settings_t *settings, _stopwatch_face_update_display(stopwatch_state, true); } break; - case EVENT_MODE_BUTTON_UP: - movement_move_to_next_face(); - break; case EVENT_LIGHT_BUTTON_DOWN: movement_illuminate_led(); if (!stopwatch_state->running) { @@ -161,7 +158,7 @@ bool stopwatch_face_loop(movement_event_t event, movement_settings_t *settings, } break; default: - break; + return movement_default_loop_handler(event, settings); } return true; diff --git a/movement/watch_faces/complication/sunrise_sunset_face.c b/movement/watch_faces/complication/sunrise_sunset_face.c index 7807de83..82de9c6e 100644 --- a/movement/watch_faces/complication/sunrise_sunset_face.c +++ b/movement/watch_faces/complication/sunrise_sunset_face.c @@ -339,9 +339,6 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti _sunrise_sunset_face_update_settings_display(event, state); } break; - case EVENT_MODE_BUTTON_UP: - movement_move_to_next_face(); - break; case EVENT_LIGHT_BUTTON_DOWN: if (state->page) { state->active_digit++; @@ -360,8 +357,6 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti _sunrise_sunset_face_update(settings, state); } break; - case EVENT_LIGHT_BUTTON_UP: - break; case EVENT_ALARM_BUTTON_UP: if (state->page) { _sunrise_sunset_face_advance_digit(state); @@ -393,7 +388,7 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti } break; default: - break; + return movement_default_loop_handler(event, settings); } return true; diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index 790c9de5..d3e62f74 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -56,11 +56,15 @@ void preferences_face_activate(movement_settings_t *settings, void *context) { bool preferences_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { uint8_t current_page = *((uint8_t *)context); switch (event.event_type) { + case EVENT_TICK: + case EVENT_ACTIVATE: + // Do nothing; handled below. + break; case EVENT_MODE_BUTTON_UP: watch_set_led_off(); movement_move_to_next_face(); return false; - case EVENT_LIGHT_BUTTON_UP: + case EVENT_LIGHT_BUTTON_DOWN: current_page = (current_page + 1) % PREFERENCES_FACE_NUM_PREFEFENCES; *((uint8_t *)context) = current_page; break; @@ -93,7 +97,7 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings movement_move_to_face(0); break; default: - break; + return movement_default_loop_handler(event, settings); } watch_display_string((char *)preferences_face_titles[current_page], 0); diff --git a/movement/watch_faces/settings/set_time_face.c b/movement/watch_faces/settings/set_time_face.c index f6ac4935..bfaea9fc 100644 --- a/movement/watch_faces/settings/set_time_face.c +++ b/movement/watch_faces/settings/set_time_face.c @@ -128,7 +128,7 @@ bool set_time_face_loop(movement_event_t event, movement_settings_t *settings, v movement_move_to_face(0); break; default: - break; + return movement_default_loop_handler(event, settings); } char buf[11]; |