diff options
-rwxr-xr-x | movement/make/.gitignore (renamed from launcher/make/.gitignore) | 0 | ||||
-rwxr-xr-x | movement/make/Makefile (renamed from launcher/make/Makefile) | 4 | ||||
-rw-r--r-- | movement/movement.c (renamed from launcher/launcher.c) | 124 | ||||
-rw-r--r-- | movement/movement.h (renamed from launcher/launcher.h) | 32 | ||||
-rw-r--r-- | movement/movement_config.h (renamed from launcher/launcher_config.h) | 10 | ||||
-rw-r--r-- | movement/widgets/clock/simple_clock_widget.c (renamed from launcher/widgets/clock/simple_clock_widget.c) | 4 | ||||
-rw-r--r-- | movement/widgets/clock/simple_clock_widget.h (renamed from launcher/widgets/clock/simple_clock_widget.h) | 2 | ||||
-rw-r--r-- | movement/widgets/complications/pulseometer_widget.c (renamed from launcher/widgets/complications/pulseometer_widget.c) | 8 | ||||
-rw-r--r-- | movement/widgets/complications/pulseometer_widget.h (renamed from launcher/widgets/complications/pulseometer_widget.h) | 2 | ||||
-rw-r--r-- | movement/widgets/settings/preferences_widget.c (renamed from launcher/widgets/settings/preferences_widget.c) | 6 | ||||
-rw-r--r-- | movement/widgets/settings/preferences_widget.h (renamed from launcher/widgets/settings/preferences_widget.h) | 2 | ||||
-rw-r--r-- | movement/widgets/settings/set_time_widget.c (renamed from launcher/widgets/settings/set_time_widget.c) | 6 | ||||
-rw-r--r-- | movement/widgets/settings/set_time_widget.h (renamed from launcher/widgets/settings/set_time_widget.h) | 2 |
13 files changed, 101 insertions, 101 deletions
diff --git a/launcher/make/.gitignore b/movement/make/.gitignore index 3722ac63..3722ac63 100755 --- a/launcher/make/.gitignore +++ b/movement/make/.gitignore diff --git a/launcher/make/Makefile b/movement/make/Makefile index a1059bbd..35b80079 100755 --- a/launcher/make/Makefile +++ b/movement/make/Makefile @@ -18,11 +18,11 @@ INCLUDES += \ # If you add any other source files you wish to compile, add them after ../app.c # Note that you will need to add a backslash at the end of any line you wish to continue, i.e. # SRCS += \ -# ../launcher.c \ +# ../movement.c \ # ../drivers/lis2dh.c \ # ../widgets/fitness/step_count_widget.c SRCS += \ - ../launcher.c \ + ../movement.c \ ../widgets/clock/simple_clock_widget.c \ ../widgets/settings/preferences_widget.c \ ../widgets/settings/set_time_widget.c \ diff --git a/launcher/launcher.c b/movement/movement.c index 7adb01a8..9c15833c 100644 --- a/launcher/launcher.c +++ b/movement/movement.c @@ -2,12 +2,12 @@ #include <string.h> #include <limits.h> #include "watch.h" -#include "launcher.h" -#include "launcher_config.h" +#include "movement.h" +#include "movement_config.h" -LauncherState launcher_state; -void * widget_contexts[LAUNCHER_NUM_WIDGETS]; -const int32_t launcher_screensaver_deadlines[8] = {INT_MAX, 3600, 7200, 21600, 43200, 86400, 172800, 604800}; +LauncherState movement_state; +void * widget_contexts[MOVEMENT_NUM_WIDGETS]; +const int32_t movement_screensaver_deadlines[8] = {INT_MAX, 3600, 7200, 21600, 43200, 86400, 172800, 604800}; LauncherEvent event; void cb_mode_btn_interrupt(); @@ -17,38 +17,38 @@ void cb_alarm_btn_extwake(); void cb_alarm_fired(); void cb_tick(); -static inline void _launcher_reset_screensaver_countdown() { +static inline void _movement_reset_screensaver_countdown() { // for testing, make the timeout happen 60x faster. - launcher_state.screensaver_ticks = launcher_screensaver_deadlines[launcher_state.launcher_settings.bit.screensaver_interval] / 60; + movement_state.screensaver_ticks = movement_screensaver_deadlines[movement_state.movement_settings.bit.screensaver_interval] / 60; } -void launcher_request_tick_frequency(uint8_t freq) { +void movement_request_tick_frequency(uint8_t freq) { watch_rtc_disable_all_periodic_callbacks(); - launcher_state.subsecond = 0; - launcher_state.tick_frequency = freq; + movement_state.subsecond = 0; + movement_state.tick_frequency = freq; watch_rtc_register_periodic_callback(cb_tick, freq); } -void launcher_illuminate_led() { - launcher_state.light_ticks = 3; +void movement_illuminate_led() { + movement_state.light_ticks = 3; } -void launcher_move_to_widget(uint8_t widget_index) { - launcher_state.widget_changed = true; - launcher_state.next_widget = widget_index; +void movement_move_to_widget(uint8_t widget_index) { + movement_state.widget_changed = true; + movement_state.next_widget = widget_index; } -void launcher_move_to_next_widget() { - launcher_move_to_widget((launcher_state.current_widget + 1) % LAUNCHER_NUM_WIDGETS); +void movement_move_to_next_widget() { + movement_move_to_widget((movement_state.current_widget + 1) % MOVEMENT_NUM_WIDGETS); } void app_init() { - memset(&launcher_state, 0, sizeof(launcher_state)); + memset(&movement_state, 0, sizeof(movement_state)); - launcher_state.launcher_settings.bit.led_green_color = 0xF; - launcher_state.launcher_settings.bit.button_should_sound = true; - launcher_state.launcher_settings.bit.screensaver_interval = 1; - _launcher_reset_screensaver_countdown(); + movement_state.movement_settings.bit.led_green_color = 0xF; + movement_state.movement_settings.bit.button_should_sound = true; + movement_state.movement_settings.bit.screensaver_interval = 1; + _movement_reset_screensaver_countdown(); } void app_wake_from_deep_sleep() { @@ -59,12 +59,12 @@ void app_setup() { static bool is_first_launch = true; if (is_first_launch) { - for(uint8_t i = 0; i < LAUNCHER_NUM_WIDGETS; i++) { + for(uint8_t i = 0; i < MOVEMENT_NUM_WIDGETS; i++) { widget_contexts[i] = NULL; is_first_launch = false; } } - if (launcher_state.screensaver_ticks != -1) { + if (movement_state.screensaver_ticks != -1) { watch_disable_extwake_interrupt(BTN_ALARM); watch_rtc_disable_alarm_callback(); @@ -77,13 +77,13 @@ void app_setup() { watch_enable_leds(); watch_enable_display(); - launcher_request_tick_frequency(1); + movement_request_tick_frequency(1); - for(uint8_t i = 0; i < LAUNCHER_NUM_WIDGETS; i++) { - widgets[i].setup(&launcher_state.launcher_settings, &widget_contexts[i]); + for(uint8_t i = 0; i < MOVEMENT_NUM_WIDGETS; i++) { + widgets[i].setup(&movement_state.movement_settings, &widget_contexts[i]); } - widgets[0].activate(&launcher_state.launcher_settings, widget_contexts[0]); + widgets[0].activate(&movement_state.movement_settings, widget_contexts[0]); event.subsecond = 0; event.event_type = EVENT_ACTIVATE; } @@ -96,42 +96,42 @@ void app_wake_from_sleep() { } bool app_loop() { - if (launcher_state.widget_changed) { - if (launcher_state.launcher_settings.bit.button_should_sound) { + if (movement_state.widget_changed) { + if (movement_state.movement_settings.bit.button_should_sound) { // low note for nonzero case, high note for return to widget 0 - watch_buzzer_play_note(launcher_state.next_widget ? BUZZER_NOTE_C7 : BUZZER_NOTE_C8, 50); + watch_buzzer_play_note(movement_state.next_widget ? BUZZER_NOTE_C7 : BUZZER_NOTE_C8, 50); } - widgets[launcher_state.current_widget].resign(&launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]); - launcher_state.current_widget = launcher_state.next_widget; + widgets[movement_state.current_widget].resign(&movement_state.movement_settings, widget_contexts[movement_state.current_widget]); + movement_state.current_widget = movement_state.next_widget; watch_clear_display(); - widgets[launcher_state.current_widget].activate(&launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]); + widgets[movement_state.current_widget].activate(&movement_state.movement_settings, widget_contexts[movement_state.current_widget]); event.subsecond = 0; event.event_type = EVENT_ACTIVATE; - launcher_state.widget_changed = false; + movement_state.widget_changed = false; } // If the LED is off and should be on, turn it on - if (launcher_state.light_ticks > 0 && !launcher_state.led_on) { - watch_set_led_color(launcher_state.launcher_settings.bit.led_red_color ? (0xF | launcher_state.launcher_settings.bit.led_red_color << 4) : 0, - launcher_state.launcher_settings.bit.led_green_color ? (0xF | launcher_state.launcher_settings.bit.led_green_color << 4) : 0); - launcher_state.led_on = true; + if (movement_state.light_ticks > 0 && !movement_state.led_on) { + watch_set_led_color(movement_state.movement_settings.bit.led_red_color ? (0xF | movement_state.movement_settings.bit.led_red_color << 4) : 0, + movement_state.movement_settings.bit.led_green_color ? (0xF | movement_state.movement_settings.bit.led_green_color << 4) : 0); + movement_state.led_on = true; } // if the LED is on and should be off, turn it off - if (launcher_state.led_on && launcher_state.light_ticks == 0) { + if (movement_state.led_on && movement_state.light_ticks == 0) { // unless the user is holding down the LIGHT button, in which case, give them more time. if (watch_get_pin_level(BTN_LIGHT)) { - launcher_state.light_ticks = 3; + movement_state.light_ticks = 3; } else { watch_set_led_off(); - launcher_state.led_on = false; + movement_state.led_on = false; } } // if we have timed out of our screensaver countdown, enter screensaver mode. - if (launcher_state.screensaver_ticks == 0) { - launcher_state.screensaver_ticks = -1; + if (movement_state.screensaver_ticks == 0) { + movement_state.screensaver_ticks = -1; watch_date_time alarm_time; alarm_time.reg = 0; alarm_time.unit.second = 59; // after a match, the alarm fires at the next rising edge of CLK_RTC_CNT, so 59 seconds lets us update at :00 @@ -142,9 +142,9 @@ bool app_loop() { // this is a little mini-runloop. // as long as screensaver_ticks is -1 (i.e. screensaver is active), we wake up here, update the screen, and go right back to sleep. - while (launcher_state.screensaver_ticks == -1) { + while (movement_state.screensaver_ticks == -1) { event.event_type = EVENT_SCREENSAVER; - widgets[launcher_state.current_widget].loop(event, &launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]); + widgets[movement_state.current_widget].loop(event, &movement_state.movement_settings, widget_contexts[movement_state.current_widget]); watch_enter_shallow_sleep(true); } // as soon as screensaver_ticks is reset by the extwake handler, we bail out of the loop and reactivate ourselves. @@ -157,13 +157,13 @@ bool app_loop() { static bool can_sleep = true; if (event.event_type) { - event.subsecond = launcher_state.subsecond; - can_sleep = widgets[launcher_state.current_widget].loop(event, &launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]); + event.subsecond = movement_state.subsecond; + can_sleep = widgets[movement_state.current_widget].loop(event, &movement_state.movement_settings, widget_contexts[movement_state.current_widget]); event.event_type = EVENT_NONE; event.subsecond = 0; } - return can_sleep && !launcher_state.led_on; + return can_sleep && !movement_state.led_on; } LauncherEventType _figure_out_button_event(LauncherEventType button_down_event, uint8_t *down_timestamp) { @@ -180,23 +180,23 @@ LauncherEventType _figure_out_button_event(LauncherEventType button_down_event, } void cb_light_btn_interrupt() { - _launcher_reset_screensaver_countdown(); - event.event_type = _figure_out_button_event(EVENT_LIGHT_BUTTON_DOWN, &launcher_state.light_down_timestamp); + _movement_reset_screensaver_countdown(); + event.event_type = _figure_out_button_event(EVENT_LIGHT_BUTTON_DOWN, &movement_state.light_down_timestamp); } void cb_mode_btn_interrupt() { - _launcher_reset_screensaver_countdown(); - event.event_type = _figure_out_button_event(EVENT_MODE_BUTTON_DOWN, &launcher_state.mode_down_timestamp); + _movement_reset_screensaver_countdown(); + event.event_type = _figure_out_button_event(EVENT_MODE_BUTTON_DOWN, &movement_state.mode_down_timestamp); } void cb_alarm_btn_interrupt() { - _launcher_reset_screensaver_countdown(); - event.event_type = _figure_out_button_event(EVENT_ALARM_BUTTON_DOWN, &launcher_state.alarm_down_timestamp); + _movement_reset_screensaver_countdown(); + event.event_type = _figure_out_button_event(EVENT_ALARM_BUTTON_DOWN, &movement_state.alarm_down_timestamp); } void cb_alarm_btn_extwake() { // wake up! - _launcher_reset_screensaver_countdown(); + _movement_reset_screensaver_countdown(); } void cb_alarm_fired() { @@ -206,13 +206,13 @@ void cb_alarm_fired() { void cb_tick() { event.event_type = EVENT_TICK; watch_date_time date_time = watch_rtc_get_date_time(); - if (date_time.unit.second != launcher_state.last_second) { - if (launcher_state.light_ticks) launcher_state.light_ticks--; - if (launcher_state.launcher_settings.bit.screensaver_interval && launcher_state.screensaver_ticks > 0) launcher_state.screensaver_ticks--; + if (date_time.unit.second != movement_state.last_second) { + if (movement_state.light_ticks) movement_state.light_ticks--; + if (movement_state.movement_settings.bit.screensaver_interval && movement_state.screensaver_ticks > 0) movement_state.screensaver_ticks--; - launcher_state.last_second = date_time.unit.second; - launcher_state.subsecond = 0; + movement_state.last_second = date_time.unit.second; + movement_state.subsecond = 0; } else { - launcher_state.subsecond++; + movement_state.subsecond++; } } diff --git a/launcher/launcher.h b/movement/movement.h index 5c5315a3..025a5aa6 100644 --- a/launcher/launcher.h +++ b/movement/movement.h @@ -1,5 +1,5 @@ -#ifndef LAUNCHER_H_ -#define LAUNCHER_H_ +#ifndef MOVEMENT_H_ +#define MOVEMENT_H_ #include <stdio.h> #include <stdbool.h> @@ -42,21 +42,21 @@ typedef struct { uint8_t subsecond; } LauncherEvent; -typedef void (*launcher_widget_setup)(LauncherSettings *settings, void ** context_ptr); -typedef void (*launcher_widget_activate)(LauncherSettings *settings, void *context); -typedef bool (*launcher_widget_loop)(LauncherEvent event, LauncherSettings *settings, void *context); -typedef void (*launcher_widget_resign)(LauncherSettings *settings, void *context); +typedef void (*movement_widget_setup)(LauncherSettings *settings, void ** context_ptr); +typedef void (*movement_widget_activate)(LauncherSettings *settings, void *context); +typedef bool (*movement_widget_loop)(LauncherEvent event, LauncherSettings *settings, void *context); +typedef void (*movement_widget_resign)(LauncherSettings *settings, void *context); typedef struct { - launcher_widget_setup setup; - launcher_widget_activate activate; - launcher_widget_loop loop; - launcher_widget_resign resign; + movement_widget_setup setup; + movement_widget_activate activate; + movement_widget_loop loop; + movement_widget_resign resign; } WatchWidget; typedef struct { // properties stored in BACKUP register - LauncherSettings launcher_settings; + LauncherSettings movement_settings; // transient properties int16_t current_widget; @@ -81,9 +81,9 @@ typedef struct { uint8_t subsecond; } LauncherState; -void launcher_move_to_widget(uint8_t widget_index); -void launcher_move_to_next_widget(); -void launcher_illuminate_led(); -void launcher_request_tick_frequency(uint8_t freq); +void movement_move_to_widget(uint8_t widget_index); +void movement_move_to_next_widget(); +void movement_illuminate_led(); +void movement_request_tick_frequency(uint8_t freq); -#endif // LAUNCHER_H_ +#endif // MOVEMENT_H_ diff --git a/launcher/launcher_config.h b/movement/movement_config.h index ff656350..49f342ca 100644 --- a/launcher/launcher_config.h +++ b/movement/movement_config.h @@ -1,18 +1,18 @@ -#ifndef LAUNCHER_CONFIG_H_ -#define LAUNCHER_CONFIG_H_ +#ifndef MOVEMENT_CONFIG_H_ +#define MOVEMENT_CONFIG_H_ #include "simple_clock_widget.h" #include "preferences_widget.h" #include "set_time_widget.h" #include "pulseometer_widget.h" -#define LAUNCHER_NUM_WIDGETS 3 +#define MOVEMENT_NUM_WIDGETS 3 -WatchWidget widgets[LAUNCHER_NUM_WIDGETS] = { +WatchWidget widgets[MOVEMENT_NUM_WIDGETS] = { simple_clock_widget, preferences_widget, set_time_widget, }; -#endif // LAUNCHER_CONFIG_H_ +#endif // MOVEMENT_CONFIG_H_ diff --git a/launcher/widgets/clock/simple_clock_widget.c b/movement/widgets/clock/simple_clock_widget.c index 7fe0183d..22218860 100644 --- a/launcher/widgets/clock/simple_clock_widget.c +++ b/movement/widgets/clock/simple_clock_widget.c @@ -63,10 +63,10 @@ bool simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, v watch_display_string(buf, pos); break; case EVENT_MODE_BUTTON_UP: - launcher_move_to_next_widget(); + movement_move_to_next_widget(); return false; case EVENT_LIGHT_BUTTON_UP: - launcher_illuminate_led(); + movement_illuminate_led(); break; case EVENT_ALARM_BUTTON_UP: break; diff --git a/launcher/widgets/clock/simple_clock_widget.h b/movement/widgets/clock/simple_clock_widget.h index 739c942b..3bf4c9a3 100644 --- a/launcher/widgets/clock/simple_clock_widget.h +++ b/movement/widgets/clock/simple_clock_widget.h @@ -1,7 +1,7 @@ #ifndef SIMPLE_CLOCK_WIDGET_H_ #define SIMPLE_CLOCK_WIDGET_H_ -#include "launcher.h" +#include "movement.h" void simple_clock_widget_setup(LauncherSettings *settings, void ** context_ptr); void simple_clock_widget_activate(LauncherSettings *settings, void *context); diff --git a/launcher/widgets/complications/pulseometer_widget.c b/movement/widgets/complications/pulseometer_widget.c index 7b3f3efe..6384685a 100644 --- a/launcher/widgets/complications/pulseometer_widget.c +++ b/movement/widgets/complications/pulseometer_widget.c @@ -58,21 +58,21 @@ bool pulseometer_widget_loop(LauncherEvent event, LauncherSettings *settings, vo } return false; case EVENT_MODE_BUTTON_UP: - launcher_move_to_next_widget(); + movement_move_to_next_widget(); return false; case EVENT_LIGHT_BUTTON_UP: - launcher_illuminate_led(); + movement_illuminate_led(); break; case EVENT_ALARM_BUTTON_DOWN: pulsometer_state->ticks = 0; pulsometer_state->pulse = 0xFFFF; pulsometer_state->measuring = true; - launcher_request_tick_frequency(PULSOMETER_WIDGET_FREQUENCY); + movement_request_tick_frequency(PULSOMETER_WIDGET_FREQUENCY); break; case EVENT_ALARM_BUTTON_UP: case EVENT_ALARM_LONG_PRESS: pulsometer_state->measuring = false; - launcher_request_tick_frequency(1); + movement_request_tick_frequency(1); break; default: break; diff --git a/launcher/widgets/complications/pulseometer_widget.h b/movement/widgets/complications/pulseometer_widget.h index 5b18d7f3..e5947660 100644 --- a/launcher/widgets/complications/pulseometer_widget.h +++ b/movement/widgets/complications/pulseometer_widget.h @@ -1,7 +1,7 @@ #ifndef PULSEOMETER_WIDGET_H_ #define PULSEOMETER_WIDGET_H_ -#include "launcher.h" +#include "movement.h" typedef struct { bool measuring; diff --git a/launcher/widgets/settings/preferences_widget.c b/movement/widgets/settings/preferences_widget.c index 1618a72c..c4537329 100644 --- a/launcher/widgets/settings/preferences_widget.c +++ b/movement/widgets/settings/preferences_widget.c @@ -13,7 +13,7 @@ void preferences_widget_setup(LauncherSettings *settings, void ** context_ptr) { void preferences_widget_activate(LauncherSettings *settings, void *context) { (void) settings; *((uint8_t *)context) = 0; - launcher_request_tick_frequency(4); // we need to manually blink some pixels + movement_request_tick_frequency(4); // we need to manually blink some pixels } bool preferences_widget_loop(LauncherEvent event, LauncherSettings *settings, void *context) { @@ -22,7 +22,7 @@ bool preferences_widget_loop(LauncherEvent event, LauncherSettings *settings, vo switch (event.event_type) { case EVENT_MODE_BUTTON_UP: watch_set_led_off(); - launcher_move_to_next_widget(); + movement_move_to_next_widget(); return false; case EVENT_LIGHT_BUTTON_UP: current_page = (current_page + 1) % PREFERENCES_WIDGET_NUM_PREFEFENCES; @@ -116,5 +116,5 @@ void preferences_widget_resign(LauncherSettings *settings, void *context) { (void) settings; (void) context; watch_set_led_off(); - launcher_request_tick_frequency(1); + movement_request_tick_frequency(1); } diff --git a/launcher/widgets/settings/preferences_widget.h b/movement/widgets/settings/preferences_widget.h index 11a189f8..3d463027 100644 --- a/launcher/widgets/settings/preferences_widget.h +++ b/movement/widgets/settings/preferences_widget.h @@ -1,7 +1,7 @@ #ifndef PREFERENCES_WIDGET_H_ #define PREFERENCES_WIDGET_H_ -#include "launcher.h" +#include "movement.h" void preferences_widget_setup(LauncherSettings *settings, void ** context_ptr); void preferences_widget_activate(LauncherSettings *settings, void *context); diff --git a/launcher/widgets/settings/set_time_widget.c b/movement/widgets/settings/set_time_widget.c index d8cfb9fc..9464eb5b 100644 --- a/launcher/widgets/settings/set_time_widget.c +++ b/movement/widgets/settings/set_time_widget.c @@ -13,7 +13,7 @@ void set_time_widget_setup(LauncherSettings *settings, void ** context_ptr) { void set_time_widget_activate(LauncherSettings *settings, void *context) { (void) settings; *((uint8_t *)context) = 0; - launcher_request_tick_frequency(4); + movement_request_tick_frequency(4); } bool set_time_widget_loop(LauncherEvent event, LauncherSettings *settings, void *context) { @@ -23,7 +23,7 @@ bool set_time_widget_loop(LauncherEvent event, LauncherSettings *settings, void switch (event.event_type) { case EVENT_MODE_BUTTON_UP: - launcher_move_to_next_widget(); + movement_move_to_next_widget(); return false; case EVENT_LIGHT_BUTTON_UP: current_page = (current_page + 1) % SET_TIME_WIDGET_NUM_SETTINGS; @@ -105,5 +105,5 @@ void set_time_widget_resign(LauncherSettings *settings, void *context) { (void) settings; (void) context; watch_set_led_off(); - launcher_request_tick_frequency(1); + movement_request_tick_frequency(1); } diff --git a/launcher/widgets/settings/set_time_widget.h b/movement/widgets/settings/set_time_widget.h index dc492dce..363fd571 100644 --- a/launcher/widgets/settings/set_time_widget.h +++ b/movement/widgets/settings/set_time_widget.h @@ -1,7 +1,7 @@ #ifndef SET_TIME_WIDGET_H_ #define SET_TIME_WIDGET_H_ -#include "launcher.h" +#include "movement.h" void set_time_widget_setup(LauncherSettings *settings, void ** context_ptr); void set_time_widget_activate(LauncherSettings *settings, void *context); |