}
}
+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:
+ 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;
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);
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.
// 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_ALARM_BUTTON_UP moves to the next watch face in the list
+ // * EVENT_MODE_LONG_PRESS returns to the first watch face in the list
+ // 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,
// 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);
movement_play_signal();
break;
default:
- break;
+ return movement_default_loop_handler(event, settings);
}
return true;
}
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;
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.
// QUESTION: Should timeout reset offset to 0?
break;
default:
- break;
+ return movement_default_loop_handler(event, settings);
}
return true;
_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) {
}
break;
default:
- break;
+ return movement_default_loop_handler(event, settings);
}
return true;
_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++;
_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);
}
break;
default:
- break;
+ return movement_default_loop_handler(event, settings);
}
return true;
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;
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);
movement_move_to_face(0);
break;
default:
- break;
+ return movement_default_loop_handler(event, settings);
}
char buf[11];