refactor: watch faces no longer need a pointer to settings!
This commit is contained in:
parent
3bd8f8d51f
commit
e88359d1d5
24
movement.c
24
movement.c
@ -103,10 +103,10 @@ static inline void _movement_disable_fast_tick_if_possible(void) {
|
||||
static void _movement_handle_background_tasks(void) {
|
||||
for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
|
||||
// For each face, if the watch face wants a background task...
|
||||
if (watch_faces[i].wants_background_task != NULL && watch_faces[i].wants_background_task(&movement_state.settings, watch_face_contexts[i])) {
|
||||
if (watch_faces[i].wants_background_task != NULL && watch_faces[i].wants_background_task(watch_face_contexts[i])) {
|
||||
// ...we give it one. pretty straightforward!
|
||||
movement_event_t background_event = { EVENT_BACKGROUND_TASK, 0 };
|
||||
watch_faces[i].loop(background_event, &movement_state.settings, watch_face_contexts[i]);
|
||||
watch_faces[i].loop(background_event, watch_face_contexts[i]);
|
||||
}
|
||||
}
|
||||
movement_state.needs_background_tasks_handled = false;
|
||||
@ -121,7 +121,7 @@ static void _movement_handle_scheduled_tasks(void) {
|
||||
if (scheduled_tasks[i].reg <= date_time.reg) {
|
||||
scheduled_tasks[i].reg = 0;
|
||||
movement_event_t background_event = { EVENT_BACKGROUND_TASK, 0 };
|
||||
watch_faces[i].loop(background_event, &movement_state.settings, watch_face_contexts[i]);
|
||||
watch_faces[i].loop(background_event, watch_face_contexts[i]);
|
||||
// check if loop scheduled a new task
|
||||
if (scheduled_tasks[i].reg) {
|
||||
num_active_tasks++;
|
||||
@ -181,9 +181,7 @@ void movement_force_led_off(void) {
|
||||
_movement_disable_fast_tick_if_possible();
|
||||
}
|
||||
|
||||
bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) {
|
||||
(void)settings;
|
||||
|
||||
bool movement_default_loop_handler(movement_event_t event) {
|
||||
switch (event.event_type) {
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
movement_move_to_next_face();
|
||||
@ -530,10 +528,10 @@ void app_setup(void) {
|
||||
movement_request_tick_frequency(1);
|
||||
|
||||
for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
|
||||
watch_faces[i].setup(&movement_state.settings, i, &watch_face_contexts[i]);
|
||||
watch_faces[i].setup(i, &watch_face_contexts[i]);
|
||||
}
|
||||
|
||||
watch_faces[movement_state.current_face_idx].activate(&movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
watch_faces[movement_state.current_face_idx].activate(watch_face_contexts[movement_state.current_face_idx]);
|
||||
event.subsecond = 0;
|
||||
event.event_type = EVENT_ACTIVATE;
|
||||
}
|
||||
@ -547,7 +545,7 @@ static void _sleep_mode_app_loop(void) {
|
||||
if (movement_state.needs_background_tasks_handled) _movement_handle_background_tasks();
|
||||
|
||||
event.event_type = EVENT_LOW_ENERGY_UPDATE;
|
||||
watch_faces[movement_state.current_face_idx].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
watch_faces[movement_state.current_face_idx].loop(event, watch_face_contexts[movement_state.current_face_idx]);
|
||||
|
||||
// if we need to wake immediately, do it!
|
||||
if (movement_state.needs_wake) return;
|
||||
@ -564,13 +562,13 @@ bool app_loop(void) {
|
||||
// low note for nonzero case, high note for return to watch_face 0
|
||||
watch_buzzer_play_note(movement_state.next_face_idx ? BUZZER_NOTE_C7 : BUZZER_NOTE_C8, 50);
|
||||
}
|
||||
wf->resign(&movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
wf->resign(watch_face_contexts[movement_state.current_face_idx]);
|
||||
movement_state.current_face_idx = movement_state.next_face_idx;
|
||||
// we have just updated the face idx, so we must recache the watch face pointer.
|
||||
wf = &watch_faces[movement_state.current_face_idx];
|
||||
watch_clear_display();
|
||||
movement_request_tick_frequency(1);
|
||||
wf->activate(&movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
wf->activate(watch_face_contexts[movement_state.current_face_idx]);
|
||||
event.subsecond = 0;
|
||||
event.event_type = EVENT_ACTIVATE;
|
||||
movement_state.watch_face_changed = false;
|
||||
@ -619,7 +617,7 @@ bool app_loop(void) {
|
||||
if (event.event_type) {
|
||||
event.subsecond = movement_state.subsecond;
|
||||
// the first trip through the loop overrides the can_sleep state
|
||||
can_sleep = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
can_sleep = wf->loop(event, watch_face_contexts[movement_state.current_face_idx]);
|
||||
|
||||
// Keep light on if user is still interacting with the watch.
|
||||
if (movement_state.light_ticks > 0) {
|
||||
@ -646,7 +644,7 @@ bool app_loop(void) {
|
||||
// first trip | can sleep | cannot sleep | can sleep | cannot sleep
|
||||
// second trip | can sleep | cannot sleep | cannot sleep | can sleep
|
||||
// && | can sleep | cannot sleep | cannot sleep | cannot sleep
|
||||
bool can_sleep2 = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
|
||||
bool can_sleep2 = wf->loop(event, watch_face_contexts[movement_state.current_face_idx]);
|
||||
can_sleep = can_sleep && can_sleep2;
|
||||
event.event_type = EVENT_NONE;
|
||||
}
|
||||
|
||||
19
movement.h
19
movement.h
@ -154,9 +154,6 @@ extern const char movement_valid_position_1_chars[];
|
||||
* like configuring a pin mode or a peripheral, you may want to do that here too.
|
||||
* This function will be called again after waking from sleep mode, since sleep mode disables all
|
||||
* of the device's pins and peripherals.
|
||||
* @param settings A pointer to the global Movement settings. You can use this to inform how you present your
|
||||
* display to the user (i.e. taking into account whether they have silenced the buttons, or if
|
||||
* they prefer 12 or 24-hour mode). You can also change these settings if you like.
|
||||
* @param watch_face_index The index of this watch face in the global array of watch faces; 0 is the first face,
|
||||
* 1 is the second, etc. You may stash this value in your context if you wish to reference
|
||||
* it later; your watch face's index is set at launch and will not change.
|
||||
@ -166,7 +163,7 @@ extern const char movement_valid_position_1_chars[];
|
||||
* data required for your watch face.
|
||||
*
|
||||
*/
|
||||
typedef void (*watch_face_setup)(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
typedef void (*watch_face_setup)(uint8_t watch_face_index, void ** context_ptr);
|
||||
|
||||
/** @brief Prepare to go on-screen.
|
||||
* @details This function is called just before your watch enters the foreground. If your watch face has any
|
||||
@ -174,11 +171,10 @@ typedef void (*watch_face_setup)(movement_settings_t *settings, uint8_t watch_fa
|
||||
* watch face depends on data from a peripheral (like an I2C sensor), you will likely want to enable
|
||||
* that peripheral here. In addition, if your watch face requires an update frequncy other than 1 Hz,
|
||||
* you may want to request that here using the movement_request_tick_frequency function.
|
||||
* @param settings A pointer to the global Movement settings. @see watch_face_setup.
|
||||
* @param context A pointer to your watch face's context. @see watch_face_setup.
|
||||
*
|
||||
*/
|
||||
typedef void (*watch_face_activate)(movement_settings_t *settings, void *context);
|
||||
typedef void (*watch_face_activate)(void *context);
|
||||
|
||||
/** @brief Handle events and update the display.
|
||||
* @details This function is called in response to an event. You should set up a switch statement that handles,
|
||||
@ -191,7 +187,6 @@ typedef void (*watch_face_activate)(movement_settings_t *settings, void *context
|
||||
* fail to do this, the user will become stuck on your watch face.
|
||||
* @param event A struct containing information about the event, including its type. @see movement_event_type_t
|
||||
* for a list of all possible event types.
|
||||
* @param settings A pointer to the global Movement settings. @see watch_face_setup.
|
||||
* @param context A pointer to your application's context. @see watch_face_setup.
|
||||
* @return true if your watch face is prepared for the system to enter STANDBY mode; false to keep the system awake.
|
||||
* You should almost always return true.
|
||||
@ -211,16 +206,15 @@ typedef void (*watch_face_activate)(movement_settings_t *settings, void *context
|
||||
unlikely the user is wearing or looking at the watch.
|
||||
EVENT_BACKGROUND_TASK is also a special case. @see watch_face_wants_background_task for details.
|
||||
*/
|
||||
typedef bool (*watch_face_loop)(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
typedef bool (*watch_face_loop)(movement_event_t event, void *context);
|
||||
|
||||
/** @brief Prepare to go off-screen.
|
||||
* @details This function is called before your watch face enters the background. If you requested a tick
|
||||
* frequency other than the standard 1 Hz, **you must call movement_request_tick_frequency(1) here**
|
||||
* to reset to 1 Hz. You should also disable any peripherals you enabled when you entered the foreground.
|
||||
* @param settings A pointer to the global Movement settings. @see watch_face_setup.
|
||||
* @param context A pointer to your application's context. @see watch_face_setup.
|
||||
*/
|
||||
typedef void (*watch_face_resign)(movement_settings_t *settings, void *context);
|
||||
typedef void (*watch_face_resign)(void *context);
|
||||
|
||||
/** @brief OPTIONAL. Request an opportunity to run a background task.
|
||||
* @details Most apps will not need this function, but if you provide it, Movement will call it once per minute in
|
||||
@ -240,11 +234,10 @@ typedef void (*watch_face_resign)(movement_settings_t *settings, void *context);
|
||||
* - If your background task involves an external pin or peripheral, request background tasks no more than once per hour.
|
||||
* - If you need to enable a pin or a peripheral to perform your task, return it to its original state afterwards.
|
||||
*
|
||||
* @param settings A pointer to the global Movement settings. @see watch_face_setup.
|
||||
* @param context A pointer to your application's context. @see watch_face_setup.
|
||||
* @return true to request a background task; false otherwise.
|
||||
*/
|
||||
typedef bool (*watch_face_wants_background_task)(movement_settings_t *settings, void *context);
|
||||
typedef bool (*watch_face_wants_background_task)(void *context);
|
||||
|
||||
typedef struct {
|
||||
watch_face_setup setup;
|
||||
@ -301,7 +294,7 @@ 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);
|
||||
bool movement_default_loop_handler(movement_event_t event);
|
||||
|
||||
void movement_illuminate_led(void);
|
||||
void movement_force_led_on(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
#include <string.h>
|
||||
#include "<#watch_face_name#>_face.h"
|
||||
|
||||
void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void <#watch_face_name#>_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(<#watch_face_name#>_state_t));
|
||||
@ -37,14 +36,13 @@ void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void <#watch_face_name#>_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void <#watch_face_name#>_face_activate(void *context) {
|
||||
<#watch_face_name#>_state_t *state = (<#watch_face_name#>_state_t *)context;
|
||||
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
}
|
||||
|
||||
bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool <#watch_face_name#>_face_loop(movement_event_t event, void *context) {
|
||||
<#watch_face_name#>_state_t *state = (<#watch_face_name#>_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -79,7 +77,7 @@ bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t *
|
||||
// * 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you should always return true.
|
||||
@ -91,8 +89,7 @@ bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t *
|
||||
return true;
|
||||
}
|
||||
|
||||
void <#watch_face_name#>_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void <#watch_face_name#>_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -39,10 +39,10 @@ typedef struct {
|
||||
uint8_t unused;
|
||||
} <#watch_face_name#>_state_t;
|
||||
|
||||
void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void <#watch_face_name#>_face_activate(movement_settings_t *settings, void *context);
|
||||
bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void <#watch_face_name#>_face_resign(movement_settings_t *settings, void *context);
|
||||
void <#watch_face_name#>_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void <#watch_face_name#>_face_activate(void *context);
|
||||
bool <#watch_face_name#>_face_loop(movement_event_t event, void *context);
|
||||
void <#watch_face_name#>_face_resign(void *context);
|
||||
|
||||
#define <#watch_face_name#>_face ((const watch_face_t){ \
|
||||
<#watch_face_name#>_face_setup, \
|
||||
|
||||
@ -61,8 +61,7 @@ static void _update_alarm_indicator(bool settings_alarm_enabled, close_enough_cl
|
||||
};
|
||||
}
|
||||
|
||||
void close_enough_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void close_enough_clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -70,7 +69,7 @@ void close_enough_clock_face_setup(movement_settings_t *settings, uint8_t watch_
|
||||
}
|
||||
}
|
||||
|
||||
void close_enough_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
void close_enough_clock_face_activate(void *context) {
|
||||
close_enough_clock_state_t *state = (close_enough_clock_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) {
|
||||
@ -89,7 +88,7 @@ void close_enough_clock_face_activate(movement_settings_t *settings, void *conte
|
||||
state->prev_min_checked = -1;
|
||||
}
|
||||
|
||||
bool close_enough_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool close_enough_clock_face_loop(movement_event_t event, void *context) {
|
||||
close_enough_clock_state_t *state = (close_enough_clock_state_t *)context;
|
||||
|
||||
char buf[11];
|
||||
@ -221,13 +220,12 @@ bool close_enough_clock_face_loop(movement_event_t event, movement_settings_t *s
|
||||
break;
|
||||
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void close_enough_clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void close_enough_clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -46,10 +46,10 @@ typedef struct {
|
||||
bool alarm_enabled;
|
||||
} close_enough_clock_state_t;
|
||||
|
||||
void close_enough_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void close_enough_clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool close_enough_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void close_enough_clock_face_resign(movement_settings_t *settings, void *context);
|
||||
void close_enough_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void close_enough_clock_face_activate(void *context);
|
||||
bool close_enough_clock_face_loop(movement_event_t event, void *context);
|
||||
void close_enough_clock_face_resign(void *context);
|
||||
|
||||
#define close_enough_clock_face ((const watch_face_t){ \
|
||||
close_enough_clock_face_setup, \
|
||||
|
||||
@ -55,8 +55,7 @@ static void recalculate(watch_date_time utc_now, day_night_percentage_state_t *s
|
||||
state->result = sun_rise_set(utc_now.unit.year + WATCH_RTC_REFERENCE_YEAR, utc_now.unit.month, utc_now.unit.day, lon, lat, &state->rise, &state->set);
|
||||
}
|
||||
|
||||
void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void day_night_percentage_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -67,12 +66,11 @@ void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watc
|
||||
}
|
||||
}
|
||||
|
||||
void day_night_percentage_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void day_night_percentage_face_activate(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool day_night_percentage_face_loop(movement_event_t event, void *context) {
|
||||
day_night_percentage_state_t *state = (day_night_percentage_state_t *)context;
|
||||
|
||||
char buf[12];
|
||||
@ -126,14 +124,13 @@ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t
|
||||
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void day_night_percentage_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void day_night_percentage_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -49,10 +49,10 @@ typedef struct {
|
||||
double daylen;
|
||||
} day_night_percentage_state_t;
|
||||
|
||||
void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void day_night_percentage_face_activate(movement_settings_t *settings, void *context);
|
||||
bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void day_night_percentage_face_resign(movement_settings_t *settings, void *context);
|
||||
void day_night_percentage_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void day_night_percentage_face_activate(void *context);
|
||||
bool day_night_percentage_face_loop(movement_event_t event, void *context);
|
||||
void day_night_percentage_face_resign(void *context);
|
||||
|
||||
#define day_night_percentage_face ((const watch_face_t){ \
|
||||
day_night_percentage_face_setup, \
|
||||
|
||||
@ -29,10 +29,9 @@
|
||||
|
||||
|
||||
|
||||
void decimal_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void decimal_time_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
// These next two lines just silence the compiler warnings associated with unused parameters.
|
||||
// We have no use for the settings or the watch_face_index, so we make that explicit here.
|
||||
(void) settings;
|
||||
(void) watch_face_index;
|
||||
(void) context_ptr;
|
||||
// At boot, context_ptr will be NULL indicating that we don't have anyplace to store our context.
|
||||
@ -48,10 +47,9 @@ void decimal_time_face_setup(movement_settings_t *settings, uint8_t watch_face_i
|
||||
}
|
||||
|
||||
|
||||
void decimal_time_face_activate(movement_settings_t *settings, void *context) {
|
||||
void decimal_time_face_activate(void *context) {
|
||||
|
||||
// same as above: silence the warning, we don't need to check the settings.
|
||||
(void) settings;
|
||||
|
||||
// we do however need to set some things in our context. Here we cast it to the correct type...
|
||||
decimal_time_face_state_t *state = (decimal_time_face_state_t *)context;
|
||||
@ -68,9 +66,8 @@ void decimal_time_face_activate(movement_settings_t *settings, void *context) {
|
||||
|
||||
|
||||
|
||||
bool decimal_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool decimal_time_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
(void) settings;
|
||||
decimal_time_face_state_t *state = (decimal_time_face_state_t *)context;
|
||||
|
||||
char buf[16];
|
||||
@ -147,7 +144,7 @@ bool decimal_time_face_loop(movement_event_t event, movement_settings_t *setting
|
||||
break;
|
||||
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -155,10 +152,9 @@ bool decimal_time_face_loop(movement_event_t event, movement_settings_t *setting
|
||||
return true;
|
||||
}
|
||||
|
||||
void decimal_time_face_resign(movement_settings_t *settings, void *context) {
|
||||
void decimal_time_face_resign(void *context) {
|
||||
// our watch face, like most watch faces, has nothing special to do when resigning.
|
||||
// there are no peripherals or sensors here to worry about turning off.
|
||||
(void) settings;
|
||||
(void) context;
|
||||
|
||||
}
|
||||
|
||||
@ -53,10 +53,10 @@ typedef struct {
|
||||
uint8_t features_to_show : 2 ; // what features are to be displayed?
|
||||
} decimal_time_face_state_t;
|
||||
|
||||
void decimal_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void decimal_time_face_activate(movement_settings_t *settings, void *context);
|
||||
bool decimal_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void decimal_time_face_resign(movement_settings_t *settings, void *context);
|
||||
void decimal_time_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void decimal_time_face_activate(void *context);
|
||||
bool decimal_time_face_loop(movement_event_t event, void *context);
|
||||
void decimal_time_face_resign(void *context);
|
||||
// void decimal_time_face_wants_background_task();
|
||||
|
||||
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
#include <string.h>
|
||||
#include "french_revolutionary_face.h"
|
||||
|
||||
void french_revolutionary_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void french_revolutionary_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(french_revolutionary_state_t));
|
||||
@ -42,15 +41,14 @@ void french_revolutionary_face_setup(movement_settings_t *settings, uint8_t watc
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void french_revolutionary_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void french_revolutionary_face_activate(void *context) {
|
||||
french_revolutionary_state_t *state = (french_revolutionary_state_t *)context;
|
||||
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
state->colon_set_after_splash = false;
|
||||
}
|
||||
|
||||
bool french_revolutionary_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool french_revolutionary_face_loop(movement_event_t event, void *context) {
|
||||
french_revolutionary_state_t *state = (french_revolutionary_state_t *)context;
|
||||
|
||||
char buf[11];
|
||||
@ -122,7 +120,7 @@ bool french_revolutionary_face_loop(movement_event_t event, movement_settings_t
|
||||
// * 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you should always return true.
|
||||
@ -134,8 +132,7 @@ bool french_revolutionary_face_loop(movement_event_t event, movement_settings_t
|
||||
return true;
|
||||
}
|
||||
|
||||
void french_revolutionary_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void french_revolutionary_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -63,10 +63,10 @@ typedef struct {
|
||||
uint8_t hour : 5; // 0-10
|
||||
} fr_decimal_time;
|
||||
|
||||
void french_revolutionary_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void french_revolutionary_face_activate(movement_settings_t *settings, void *context);
|
||||
bool french_revolutionary_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void french_revolutionary_face_resign(movement_settings_t *settings, void *context);
|
||||
void french_revolutionary_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void french_revolutionary_face_activate(void *context);
|
||||
bool french_revolutionary_face_loop(movement_event_t event, void *context);
|
||||
void french_revolutionary_face_resign(void *context);
|
||||
char fix_character_one(char digit);
|
||||
fr_decimal_time get_decimal_time(watch_date_time *date_time);
|
||||
void set_display_buffer(char *buf, french_revolutionary_state_t *state, fr_decimal_time *decimal_time, watch_date_time *date_time);
|
||||
|
||||
@ -67,7 +67,7 @@ static void _h_to_hms(mars_clock_hms_t *date_time, double h) {
|
||||
date_time->second = round(seconds % 60);
|
||||
}
|
||||
|
||||
static void _update(movement_settings_t *settings, mars_time_state_t *state) {
|
||||
static void _update(mars_time_state_t *state) {
|
||||
char buf[11];
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
@ -106,8 +106,7 @@ static void _update(movement_settings_t *settings, mars_time_state_t *state) {
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
void mars_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void mars_time_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(mars_time_state_t));
|
||||
@ -115,30 +114,29 @@ void mars_time_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
}
|
||||
}
|
||||
|
||||
void mars_time_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void mars_time_face_activate(void *context) {
|
||||
mars_time_state_t *state = (mars_time_state_t *)context;
|
||||
(void) state;
|
||||
}
|
||||
|
||||
bool mars_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool mars_time_face_loop(movement_event_t event, void *context) {
|
||||
mars_time_state_t *state = (mars_time_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
case EVENT_TICK:
|
||||
_update(settings, state);
|
||||
_update(state);
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
state->displaying_sol = !state->displaying_sol;
|
||||
_update(settings, state);
|
||||
_update(state);
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
movement_illuminate_led();
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
state->current_site = (state->current_site + 1) % MARS_TIME_NUM_SITES;
|
||||
_update(settings, state);
|
||||
_update(state);
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
// TODO: make this lower power so we can avoid timeout
|
||||
@ -152,15 +150,14 @@ bool mars_time_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void mars_time_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void mars_time_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -67,10 +67,10 @@ typedef struct {
|
||||
bool displaying_sol;
|
||||
} mars_time_state_t;
|
||||
|
||||
void mars_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void mars_time_face_activate(movement_settings_t *settings, void *context);
|
||||
bool mars_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void mars_time_face_resign(movement_settings_t *settings, void *context);
|
||||
void mars_time_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void mars_time_face_activate(void *context);
|
||||
bool mars_time_face_loop(movement_event_t event, void *context);
|
||||
void mars_time_face_resign(void *context);
|
||||
|
||||
#define mars_time_face ((const watch_face_t){ \
|
||||
mars_time_face_setup, \
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include <string.h>
|
||||
#include "minimal_clock_face.h"
|
||||
|
||||
static void _minimal_clock_face_update_display(movement_settings_t *settings) {
|
||||
static void _minimal_clock_face_update_display() {
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
char buffer[11];
|
||||
|
||||
@ -40,8 +40,7 @@ static void _minimal_clock_face_update_display(movement_settings_t *settings) {
|
||||
watch_display_string(buffer, 4);
|
||||
}
|
||||
|
||||
void minimal_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void minimal_clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(minimal_clock_state_t));
|
||||
@ -51,24 +50,23 @@ void minimal_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void minimal_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void minimal_clock_face_activate(void *context) {
|
||||
(void) context;
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
watch_set_colon();
|
||||
}
|
||||
|
||||
bool minimal_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool minimal_clock_face_loop(movement_event_t event, void *context) {
|
||||
(void) context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
// Show your initial UI here.
|
||||
_minimal_clock_face_update_display(settings);
|
||||
_minimal_clock_face_update_display();
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
// If needed, update your display here.
|
||||
_minimal_clock_face_update_display(settings);
|
||||
_minimal_clock_face_update_display();
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
// You can use the Light button for your own purposes. Note that by default, Movement will also
|
||||
@ -88,7 +86,7 @@ bool minimal_clock_face_loop(movement_event_t event, movement_settings_t *settin
|
||||
// Avoid displaying fast-updating values like seconds, since the display won't update again for 60 seconds.
|
||||
// You should also consider starting the tick animation, to show the wearer that this is sleep mode:
|
||||
// watch_start_tick_animation(500);
|
||||
_minimal_clock_face_update_display(settings);
|
||||
_minimal_clock_face_update_display();
|
||||
break;
|
||||
default:
|
||||
// Movement's default loop handler will step in for any cases you don't handle above:
|
||||
@ -96,7 +94,7 @@ bool minimal_clock_face_loop(movement_event_t event, movement_settings_t *settin
|
||||
// * 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you should always return true.
|
||||
@ -108,8 +106,7 @@ bool minimal_clock_face_loop(movement_event_t event, movement_settings_t *settin
|
||||
return true;
|
||||
}
|
||||
|
||||
void minimal_clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void minimal_clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -40,10 +40,10 @@ typedef struct {
|
||||
uint8_t unused;
|
||||
} minimal_clock_state_t;
|
||||
|
||||
void minimal_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void minimal_clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool minimal_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void minimal_clock_face_resign(movement_settings_t *settings, void *context);
|
||||
void minimal_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void minimal_clock_face_activate(void *context);
|
||||
bool minimal_clock_face_loop(movement_event_t event, void *context);
|
||||
void minimal_clock_face_resign(void *context);
|
||||
|
||||
#define minimal_clock_face ((const watch_face_t){ \
|
||||
minimal_clock_face_setup, \
|
||||
|
||||
@ -66,8 +66,7 @@ static void _update_alarm_indicator(bool settings_alarm_enabled, minute_repeater
|
||||
else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
|
||||
void minute_repeater_decimal_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void minute_repeater_decimal_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -78,7 +77,7 @@ void minute_repeater_decimal_face_setup(movement_settings_t *settings, uint8_t w
|
||||
}
|
||||
}
|
||||
|
||||
void minute_repeater_decimal_face_activate(movement_settings_t *settings, void *context) {
|
||||
void minute_repeater_decimal_face_activate(void *context) {
|
||||
minute_repeater_decimal_state_t *state = (minute_repeater_decimal_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
@ -98,7 +97,7 @@ void minute_repeater_decimal_face_activate(movement_settings_t *settings, void *
|
||||
state->previous_date_time = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool minute_repeater_decimal_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool minute_repeater_decimal_face_loop(movement_event_t event, void *context) {
|
||||
minute_repeater_decimal_state_t *state = (minute_repeater_decimal_state_t *)context;
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
@ -216,19 +215,17 @@ bool minute_repeater_decimal_face_loop(movement_event_t event, movement_settings
|
||||
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void minute_repeater_decimal_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void minute_repeater_decimal_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool minute_repeater_decimal_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool minute_repeater_decimal_face_wants_background_task(void *context) {
|
||||
minute_repeater_decimal_state_t *state = (minute_repeater_decimal_state_t *)context;
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
|
||||
@ -67,11 +67,11 @@ typedef struct {
|
||||
void mrd_play_hour_chime(void);
|
||||
void mrd_play_tens_chime(void);
|
||||
void mrd_play_minute_chime(void);
|
||||
void minute_repeater_decimal_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void minute_repeater_decimal_face_activate(movement_settings_t *settings, void *context);
|
||||
bool minute_repeater_decimal_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void minute_repeater_decimal_face_resign(movement_settings_t *settings, void *context);
|
||||
bool minute_repeater_decimal_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void minute_repeater_decimal_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void minute_repeater_decimal_face_activate(void *context);
|
||||
bool minute_repeater_decimal_face_loop(movement_event_t event, void *context);
|
||||
void minute_repeater_decimal_face_resign(void *context);
|
||||
bool minute_repeater_decimal_face_wants_background_task(void *context);
|
||||
|
||||
#define minute_repeater_decimal_face ((const watch_face_t){ \
|
||||
minute_repeater_decimal_face_setup, \
|
||||
|
||||
@ -51,8 +51,7 @@ static void _update_alarm_indicator(bool settings_alarm_enabled, repetition_minu
|
||||
else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
|
||||
void repetition_minute_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void repetition_minute_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -63,7 +62,7 @@ void repetition_minute_face_setup(movement_settings_t *settings, uint8_t watch_f
|
||||
}
|
||||
}
|
||||
|
||||
void repetition_minute_face_activate(movement_settings_t *settings, void *context) {
|
||||
void repetition_minute_face_activate(void *context) {
|
||||
repetition_minute_state_t *state = (repetition_minute_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
@ -83,7 +82,7 @@ void repetition_minute_face_activate(movement_settings_t *settings, void *contex
|
||||
state->previous_date_time = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool repetition_minute_face_loop(movement_event_t event, void *context) {
|
||||
repetition_minute_state_t *state = (repetition_minute_state_t *)context;
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
@ -199,19 +198,17 @@ bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *se
|
||||
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void repetition_minute_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void repetition_minute_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool repetition_minute_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool repetition_minute_face_wants_background_task(void *context) {
|
||||
repetition_minute_state_t *state = (repetition_minute_state_t *)context;
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
|
||||
@ -66,11 +66,11 @@ typedef struct {
|
||||
void play_hour_chime(void);
|
||||
void play_quarter_chime(void);
|
||||
void play_minute_chime(void);
|
||||
void repetition_minute_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void repetition_minute_face_activate(movement_settings_t *settings, void *context);
|
||||
bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void repetition_minute_face_resign(movement_settings_t *settings, void *context);
|
||||
bool repetition_minute_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void repetition_minute_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void repetition_minute_face_activate(void *context);
|
||||
bool repetition_minute_face_loop(movement_event_t event, void *context);
|
||||
void repetition_minute_face_resign(void *context);
|
||||
bool repetition_minute_face_wants_background_task(void *context);
|
||||
|
||||
#define repetition_minute_face ((const watch_face_t){ \
|
||||
repetition_minute_face_setup, \
|
||||
|
||||
@ -45,8 +45,7 @@ static void _display_left_aligned(uint8_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
void simple_clock_bin_led_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void simple_clock_bin_led_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(simple_clock_bin_led_state_t));
|
||||
memset(*context_ptr, 0, sizeof(simple_clock_bin_led_state_t));
|
||||
@ -55,7 +54,7 @@ void simple_clock_bin_led_face_setup(movement_settings_t *settings, uint8_t watc
|
||||
}
|
||||
}
|
||||
|
||||
void simple_clock_bin_led_face_activate(movement_settings_t *settings, void *context) {
|
||||
void simple_clock_bin_led_face_activate(void *context) {
|
||||
simple_clock_bin_led_state_t *state = (simple_clock_bin_led_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
@ -75,7 +74,7 @@ void simple_clock_bin_led_face_activate(movement_settings_t *settings, void *con
|
||||
state->previous_date_time = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool simple_clock_bin_led_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool simple_clock_bin_led_face_loop(movement_event_t event, void *context) {
|
||||
simple_clock_bin_led_state_t *state = (simple_clock_bin_led_state_t *)context;
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
@ -200,19 +199,17 @@ bool simple_clock_bin_led_face_loop(movement_event_t event, movement_settings_t
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void simple_clock_bin_led_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void simple_clock_bin_led_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool simple_clock_bin_led_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool simple_clock_bin_led_face_wants_background_task(void *context) {
|
||||
simple_clock_bin_led_state_t *state = (simple_clock_bin_led_state_t *)context;
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@ typedef struct {
|
||||
uint8_t ticks;
|
||||
} simple_clock_bin_led_state_t;
|
||||
|
||||
void simple_clock_bin_led_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void simple_clock_bin_led_face_activate(movement_settings_t *settings, void *context);
|
||||
bool simple_clock_bin_led_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void simple_clock_bin_led_face_resign(movement_settings_t *settings, void *context);
|
||||
bool simple_clock_bin_led_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void simple_clock_bin_led_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void simple_clock_bin_led_face_activate(void *context);
|
||||
bool simple_clock_bin_led_face_loop(movement_event_t event, void *context);
|
||||
void simple_clock_bin_led_face_resign(void *context);
|
||||
bool simple_clock_bin_led_face_wants_background_task(void *context);
|
||||
|
||||
#define simple_clock_bin_led_face ((const watch_face_t){ \
|
||||
simple_clock_bin_led_face_setup, \
|
||||
|
||||
@ -33,8 +33,7 @@ static void _update_alarm_indicator(bool settings_alarm_enabled, weeknumber_cloc
|
||||
else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
|
||||
void weeknumber_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void weeknumber_clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -45,7 +44,7 @@ void weeknumber_clock_face_setup(movement_settings_t *settings, uint8_t watch_fa
|
||||
}
|
||||
}
|
||||
|
||||
void weeknumber_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
void weeknumber_clock_face_activate(void *context) {
|
||||
weeknumber_clock_state_t *state = (weeknumber_clock_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
@ -65,7 +64,7 @@ void weeknumber_clock_face_activate(movement_settings_t *settings, void *context
|
||||
state->previous_date_time = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool weeknumber_clock_face_loop(movement_event_t event, void *context) {
|
||||
weeknumber_clock_state_t *state = (weeknumber_clock_state_t *)context;
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
@ -133,20 +132,18 @@ bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *set
|
||||
movement_play_signal();
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void weeknumber_clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void weeknumber_clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool weeknumber_clock_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool weeknumber_clock_face_wants_background_task(void *context) {
|
||||
weeknumber_clock_state_t *state = (weeknumber_clock_state_t *)context;
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
|
||||
@ -44,11 +44,11 @@ typedef struct {
|
||||
bool alarm_enabled;
|
||||
} weeknumber_clock_state_t;
|
||||
|
||||
void weeknumber_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void weeknumber_clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void weeknumber_clock_face_resign(movement_settings_t *settings, void *context);
|
||||
bool weeknumber_clock_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void weeknumber_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void weeknumber_clock_face_activate(void *context);
|
||||
bool weeknumber_clock_face_loop(movement_event_t event, void *context);
|
||||
void weeknumber_clock_face_resign(void *context);
|
||||
bool weeknumber_clock_face_wants_background_task(void *context);
|
||||
|
||||
#define weeknumber_clock_face ((const watch_face_t){ \
|
||||
weeknumber_clock_face_setup, \
|
||||
|
||||
@ -121,9 +121,8 @@ static void beep_disable() {
|
||||
watch_buzzer_play_note(BUZZER_NOTE_G7, 75);
|
||||
}
|
||||
|
||||
void world_clock2_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr)
|
||||
void world_clock2_face_setup(uint8_t watch_face_index, void **context_ptr)
|
||||
{
|
||||
(void) settings;
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -136,9 +135,8 @@ void world_clock2_face_setup(movement_settings_t *settings, uint8_t watch_face_i
|
||||
}
|
||||
}
|
||||
|
||||
void world_clock2_face_activate(movement_settings_t *settings, void *context)
|
||||
void world_clock2_face_activate(void *context)
|
||||
{
|
||||
(void) settings;
|
||||
world_clock2_state_t *state = (world_clock2_state_t *) context;
|
||||
|
||||
if (watch_tick_animation_is_running())
|
||||
@ -157,7 +155,7 @@ void world_clock2_face_activate(movement_settings_t *settings, void *context)
|
||||
refresh_face = true;
|
||||
}
|
||||
|
||||
static bool mode_display(movement_event_t event, movement_settings_t *settings, world_clock2_state_t *state)
|
||||
static bool mode_display(movement_event_t event, world_clock2_state_t *state)
|
||||
{
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
@ -260,13 +258,13 @@ static bool mode_display(movement_event_t event, movement_settings_t *settings,
|
||||
movement_move_to_next_face();
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool mode_settings(movement_event_t event, movement_settings_t *settings, world_clock2_state_t *state)
|
||||
static bool mode_settings(movement_event_t event, world_clock2_state_t *state)
|
||||
{
|
||||
char buf[11];
|
||||
int8_t hours, minutes;
|
||||
@ -352,26 +350,25 @@ static bool mode_settings(movement_event_t event, movement_settings_t *settings,
|
||||
movement_move_to_next_face();
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool world_clock2_face_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
bool world_clock2_face_loop(movement_event_t event, void *context)
|
||||
{
|
||||
world_clock2_state_t *state = (world_clock2_state_t *) context;
|
||||
switch (state->current_mode) {
|
||||
case WORLD_CLOCK2_MODE_DISPLAY:
|
||||
return mode_display(event, settings, state);
|
||||
return mode_display(event, state);
|
||||
case WORLD_CLOCK2_MODE_SETTINGS:
|
||||
return mode_settings(event, settings, state);
|
||||
return mode_settings(event, state);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void world_clock2_face_resign(movement_settings_t *settings, void *context)
|
||||
void world_clock2_face_resign(void *context)
|
||||
{
|
||||
(void) settings;
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -106,10 +106,10 @@ typedef struct {
|
||||
uint32_t previous_date_time;
|
||||
} world_clock2_state_t;
|
||||
|
||||
void world_clock2_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
|
||||
void world_clock2_face_activate(movement_settings_t *settings, void *context);
|
||||
bool world_clock2_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void world_clock2_face_resign(movement_settings_t *settings, void *context);
|
||||
void world_clock2_face_setup(uint8_t watch_face_index, void **context_ptr);
|
||||
void world_clock2_face_activate(void *context);
|
||||
bool world_clock2_face_loop(movement_event_t event, void *context);
|
||||
void world_clock2_face_resign(void *context);
|
||||
|
||||
#define world_clock2_face ((const watch_face_t){ \
|
||||
world_clock2_face_setup, \
|
||||
|
||||
@ -90,8 +90,7 @@ static const int32_t clock_mapping[6][7][2] = {
|
||||
{{2,4}, {2,5}, {1,6}, {0,6}, {0,5}, {1,4}, {1,5}},
|
||||
};
|
||||
|
||||
void wyoscan_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void wyoscan_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(wyoscan_state_t));
|
||||
@ -101,14 +100,13 @@ void wyoscan_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void wyoscan_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void wyoscan_face_activate(void *context) {
|
||||
wyoscan_state_t *state = (wyoscan_state_t *)context;
|
||||
movement_request_tick_frequency(32);
|
||||
state->total_frames = 64;
|
||||
}
|
||||
|
||||
bool wyoscan_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool wyoscan_face_loop(movement_event_t event, void *context) {
|
||||
wyoscan_state_t *state = (wyoscan_state_t *)context;
|
||||
|
||||
watch_date_time date_time;
|
||||
@ -195,14 +193,13 @@ bool wyoscan_face_loop(movement_event_t event, movement_settings_t *settings, vo
|
||||
case EVENT_BACKGROUND_TASK:
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wyoscan_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void wyoscan_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -73,11 +73,11 @@ typedef struct {
|
||||
uint32_t illuminated_segments[MAX_ILLUMINATED_SEGMENTS][2];
|
||||
} wyoscan_state_t;
|
||||
|
||||
void wyoscan_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void wyoscan_face_activate(movement_settings_t *settings, void *context);
|
||||
bool wyoscan_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void wyoscan_face_resign(movement_settings_t *settings, void *context);
|
||||
bool wyoscan_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void wyoscan_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void wyoscan_face_activate(void *context);
|
||||
bool wyoscan_face_loop(movement_event_t event, void *context);
|
||||
void wyoscan_face_resign(void *context);
|
||||
bool wyoscan_face_wants_background_task(void *context);
|
||||
|
||||
#define wyoscan_face ((const watch_face_t){ \
|
||||
wyoscan_face_setup, \
|
||||
|
||||
@ -169,11 +169,10 @@ static void _activity_clear_buffers() {
|
||||
}
|
||||
|
||||
static void _activity_display_choice(activity_state_t *state);
|
||||
static void _activity_update_logging_screen(movement_settings_t *settings, activity_state_t *state);
|
||||
static void _activity_update_logging_screen(activity_state_t *state);
|
||||
static uint8_t _activity_get_next_byte(uint8_t *next_byte);
|
||||
|
||||
void activity_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||
(void)settings;
|
||||
void activity_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
||||
(void)watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(activity_state_t));
|
||||
@ -184,8 +183,7 @@ void activity_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void activity_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void)settings;
|
||||
void activity_face_activate(void *context) {
|
||||
(void)context;
|
||||
|
||||
// Not using this function. Calling _activity_activate from the event handler.
|
||||
@ -194,7 +192,7 @@ void activity_face_activate(movement_settings_t *settings, void *context) {
|
||||
}
|
||||
|
||||
// Called from the ACTIVATE event handler in the loop
|
||||
static void _activity_activate(movement_settings_t *settings, activity_state_t *state) {
|
||||
static void _activity_activate(activity_state_t *state) {
|
||||
// If waking from low-energy state and currently logging: update seconds values
|
||||
// Those are not up-to-date because ticks have not been coming
|
||||
if (state->le_state != 0 && state->mode == ACTM_LOGGING) {
|
||||
@ -204,7 +202,7 @@ static void _activity_activate(movement_settings_t *settings, activity_state_t *
|
||||
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_time, 0);
|
||||
uint32_t total_seconds = now_timestamp - start_timestamp;
|
||||
state->curr_total_sec = total_seconds;
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
}
|
||||
// Regular activation: start from defaults
|
||||
else {
|
||||
@ -239,7 +237,7 @@ const uint8_t activity_anim_pixels[][2] = {
|
||||
// {2, 4}, // MID
|
||||
};
|
||||
|
||||
static void _activity_update_logging_screen(movement_settings_t *settings, activity_state_t *state) {
|
||||
static void _activity_update_logging_screen(activity_state_t *state) {
|
||||
watch_duration_t duration;
|
||||
|
||||
watch_display_string("AC ", 0);
|
||||
@ -450,7 +448,7 @@ static void _activity_finish_logging(activity_state_t *state) {
|
||||
watch_display_string("AC dONE ", 0);
|
||||
}
|
||||
|
||||
static void _activity_handle_tick(movement_settings_t *settings, activity_state_t *state) {
|
||||
static void _activity_handle_tick(activity_state_t *state) {
|
||||
// Display stopwatch-like duration while logging, alternating with time
|
||||
if (state->mode == ACTM_LOGGING || state->mode == ACTM_PAUSED) {
|
||||
++state->counter;
|
||||
@ -463,7 +461,7 @@ static void _activity_handle_tick(movement_settings_t *settings, activity_state_
|
||||
}
|
||||
// Still logging: refresh display
|
||||
else {
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
}
|
||||
}
|
||||
// Display countown animation, and exit face when down
|
||||
@ -536,7 +534,7 @@ static void _activity_handle_tick(movement_settings_t *settings, activity_state_
|
||||
}
|
||||
}
|
||||
|
||||
static void _activity_alarm_long(movement_settings_t *settings, activity_state_t *state) {
|
||||
static void _activity_alarm_long(activity_state_t *state) {
|
||||
// On choose face: start logging activity
|
||||
if (state->mode == ACTM_CHOOSE) {
|
||||
// If buffer is full: Ignore this long press
|
||||
@ -549,7 +547,7 @@ static void _activity_alarm_long(movement_settings_t *settings, activity_state_t
|
||||
state->counter = -1;
|
||||
state->mode = ACTM_LOGGING;
|
||||
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
}
|
||||
// If logging or paused: end logging
|
||||
else if (state->mode == ACTM_LOGGING || state->mode == ACTM_PAUSED) {
|
||||
@ -589,7 +587,7 @@ static void _activity_alarm_long(movement_settings_t *settings, activity_state_t
|
||||
}
|
||||
}
|
||||
|
||||
static void _activity_alarm_short(movement_settings_t *settings, activity_state_t *state) {
|
||||
static void _activity_alarm_short(activity_state_t *state) {
|
||||
// In the choose face, short ALARM cycles through activities
|
||||
if (state->mode == ACTM_CHOOSE) {
|
||||
state->type_ix = (state->type_ix + 1) % num_enabled_activities;
|
||||
@ -599,13 +597,13 @@ static void _activity_alarm_short(movement_settings_t *settings, activity_state_
|
||||
else if (state->mode == ACTM_LOGGING) {
|
||||
state->mode = ACTM_PAUSED;
|
||||
state->counter = 0;
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
}
|
||||
// If paused: Update paused seconds count and return to logging
|
||||
else if (state->mode == ACTM_PAUSED) {
|
||||
state->mode = ACTM_LOGGING;
|
||||
state->counter = 0;
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
}
|
||||
// If chirping: stoppit
|
||||
else if (state->mode == ACTM_CHIRPING) {
|
||||
@ -649,15 +647,15 @@ static void _activity_light_short(activity_state_t *state) {
|
||||
// Otherwise, we don't do light.
|
||||
}
|
||||
|
||||
bool activity_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool activity_face_loop(movement_event_t event, void *context) {
|
||||
activity_state_t *state = (activity_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
_activity_activate(settings, state);
|
||||
_activity_activate(state);
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
_activity_handle_tick(settings, state);
|
||||
_activity_handle_tick(state);
|
||||
break;
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
if (state->mode != ACTM_LOGGING && state->mode != ACTM_PAUSED && state->mode != ACTM_CHIRPING) {
|
||||
@ -672,12 +670,12 @@ bool activity_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
// We also receive ALARM press that woke us up from LE state
|
||||
// Don't want to act on that as if it were a real button press for us
|
||||
if (state->le_state != 2)
|
||||
_activity_alarm_short(settings, state);
|
||||
_activity_alarm_short(state);
|
||||
else
|
||||
state->le_state = 0;
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
_activity_alarm_long(settings, state);
|
||||
_activity_alarm_long(state);
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
if (state->mode != ACTM_LOGGING && state->mode != ACTM_PAUSED &&
|
||||
@ -698,12 +696,12 @@ bool activity_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
}
|
||||
else {
|
||||
_activity_update_logging_screen(settings, state);
|
||||
_activity_update_logging_screen(state);
|
||||
watch_start_tick_animation(500);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -714,8 +712,7 @@ bool activity_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
return true;
|
||||
}
|
||||
|
||||
void activity_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void)settings;
|
||||
void activity_face_resign(void *context) {
|
||||
(void)context;
|
||||
|
||||
// Face should only ever temporarily request a higher frequency, so by the time we're resigning,
|
||||
|
||||
@ -71,10 +71,10 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void activity_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void activity_face_activate(movement_settings_t *settings, void *context);
|
||||
bool activity_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void activity_face_resign(movement_settings_t *settings, void *context);
|
||||
void activity_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void activity_face_activate(void *context);
|
||||
bool activity_face_loop(movement_event_t event, void *context);
|
||||
void activity_face_resign(void *context);
|
||||
|
||||
#define activity_face ((const watch_face_t){ \
|
||||
activity_face_setup, \
|
||||
|
||||
@ -63,7 +63,7 @@ static void _alarm_set_signal(alarm_state_t *state) {
|
||||
watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
|
||||
static void _alarm_face_draw(movement_settings_t *settings, alarm_state_t *state, uint8_t subsecond) {
|
||||
static void _alarm_face_draw(alarm_state_t *state, uint8_t subsecond) {
|
||||
char buf[12];
|
||||
|
||||
uint8_t i = 0;
|
||||
@ -119,20 +119,20 @@ static void _alarm_face_draw(movement_settings_t *settings, alarm_state_t *state
|
||||
_alarm_set_signal(state);
|
||||
}
|
||||
|
||||
static void _alarm_initiate_setting(movement_settings_t *settings, alarm_state_t *state, uint8_t subsecond) {
|
||||
static void _alarm_initiate_setting(alarm_state_t *state, uint8_t subsecond) {
|
||||
state->is_setting = true;
|
||||
state->setting_state = 0;
|
||||
movement_request_tick_frequency(4);
|
||||
_alarm_face_draw(settings, state, subsecond);
|
||||
_alarm_face_draw(state, subsecond);
|
||||
}
|
||||
|
||||
static void _alarm_resume_setting(movement_settings_t *settings, alarm_state_t *state, uint8_t subsecond) {
|
||||
static void _alarm_resume_setting(alarm_state_t *state, uint8_t subsecond) {
|
||||
state->is_setting = false;
|
||||
movement_request_tick_frequency(1);
|
||||
_alarm_face_draw(settings, state, subsecond);
|
||||
_alarm_face_draw(state, subsecond);
|
||||
}
|
||||
|
||||
static void _alarm_update_alarm_enabled(movement_settings_t *settings, alarm_state_t *state) {
|
||||
static void _alarm_update_alarm_enabled(alarm_state_t *state) {
|
||||
// save indication for active alarms to movement settings
|
||||
bool active_alarms = false;
|
||||
watch_date_time now;
|
||||
@ -199,8 +199,7 @@ static void _abort_quick_ticks(alarm_state_t *state) {
|
||||
}
|
||||
}
|
||||
|
||||
void alarm_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||
(void) settings;
|
||||
void alarm_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -218,24 +217,22 @@ void alarm_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
|
||||
}
|
||||
}
|
||||
|
||||
void alarm_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void alarm_face_activate(void *context) {
|
||||
(void) context;
|
||||
watch_set_colon();
|
||||
}
|
||||
|
||||
void alarm_face_resign(movement_settings_t *settings, void *context) {
|
||||
void alarm_face_resign(void *context) {
|
||||
alarm_state_t *state = (alarm_state_t *)context;
|
||||
state->is_setting = false;
|
||||
_alarm_update_alarm_enabled(settings, state);
|
||||
_alarm_update_alarm_enabled(state);
|
||||
watch_set_led_off();
|
||||
state->alarm_quick_ticks = false;
|
||||
_wait_ticks = -1;
|
||||
movement_request_tick_frequency(1);
|
||||
}
|
||||
|
||||
bool alarm_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool alarm_face_wants_background_task(void *context) {
|
||||
alarm_state_t *state = (alarm_state_t *)context;
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
// just a failsafe: never fire more than one alarm within a minute
|
||||
@ -258,12 +255,11 @@ bool alarm_face_wants_background_task(movement_settings_t *settings, void *conte
|
||||
}
|
||||
state->alarm_handled_minute = -1;
|
||||
// update the movement's alarm indicator five times an hour
|
||||
if (now.unit.minute % 12 == 0) _alarm_update_alarm_enabled(settings, state);
|
||||
if (now.unit.minute % 12 == 0) _alarm_update_alarm_enabled(state);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool alarm_face_loop(movement_event_t event, void *context) {
|
||||
alarm_state_t *state = (alarm_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -291,25 +287,25 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
}
|
||||
// fall through
|
||||
case EVENT_ACTIVATE:
|
||||
_alarm_face_draw(settings, state, event.subsecond);
|
||||
_alarm_face_draw(state, event.subsecond);
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
if (!state->is_setting) {
|
||||
movement_illuminate_led();
|
||||
_alarm_initiate_setting(settings, state, event.subsecond);
|
||||
_alarm_initiate_setting(state, event.subsecond);
|
||||
break;
|
||||
}
|
||||
state->setting_state += 1;
|
||||
if (state->setting_state >= ALARM_SETTING_STATES) {
|
||||
// we have done a full settings cycle, so resume to normal
|
||||
_alarm_resume_setting(settings, state, event.subsecond);
|
||||
_alarm_resume_setting(state, event.subsecond);
|
||||
}
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
if (state->is_setting) {
|
||||
_alarm_resume_setting(settings, state, event.subsecond);
|
||||
_alarm_resume_setting(state, event.subsecond);
|
||||
} else {
|
||||
_alarm_initiate_setting(settings, state, event.subsecond);
|
||||
_alarm_initiate_setting(state, event.subsecond);
|
||||
}
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
@ -357,7 +353,7 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
// auto enable an alarm if user sets anything
|
||||
if (state->setting_state > alarm_setting_idx_alarm) state->alarm[state->alarm_idx].enabled = true;
|
||||
}
|
||||
_alarm_face_draw(settings, state, event.subsecond);
|
||||
_alarm_face_draw(state, event.subsecond);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
if (!state->is_setting) {
|
||||
@ -382,7 +378,7 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
break;
|
||||
}
|
||||
}
|
||||
_alarm_face_draw(settings, state, event.subsecond);
|
||||
_alarm_face_draw(state, event.subsecond);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_UP:
|
||||
if (state->is_setting) {
|
||||
@ -414,7 +410,7 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
state->alarm[state->alarm_playing_idx].beeps = 5;
|
||||
state->alarm[state->alarm_playing_idx].pitch = 1;
|
||||
state->alarm[state->alarm_playing_idx].enabled = false;
|
||||
_alarm_update_alarm_enabled(settings, state);
|
||||
_alarm_update_alarm_enabled(state);
|
||||
}
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
@ -424,7 +420,7 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -85,11 +85,11 @@ typedef struct {
|
||||
} alarm_state_t;
|
||||
|
||||
|
||||
void alarm_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void alarm_face_activate(movement_settings_t *settings, void *context);
|
||||
bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void alarm_face_resign(movement_settings_t *settings, void *context);
|
||||
bool alarm_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void alarm_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void alarm_face_activate(void *context);
|
||||
bool alarm_face_loop(movement_event_t event, void *context);
|
||||
void alarm_face_resign(void *context);
|
||||
bool alarm_face_wants_background_task(void *context);
|
||||
|
||||
#define alarm_face ((const watch_face_t){ \
|
||||
alarm_face_setup, \
|
||||
|
||||
@ -59,7 +59,7 @@ static const char astronomy_celestial_body_names[NUM_AVAILABLE_BODIES][3] = {
|
||||
"NE" // Neptune
|
||||
};
|
||||
|
||||
static void _astronomy_face_recalculate(movement_settings_t *settings, astronomy_state_t *state) {
|
||||
static void _astronomy_face_recalculate(astronomy_state_t *state) {
|
||||
#if __EMSCRIPTEN__
|
||||
int16_t browser_lat = EM_ASM_INT({
|
||||
return lat;
|
||||
@ -116,7 +116,7 @@ static void _astronomy_face_recalculate(movement_settings_t *settings, astronomy
|
||||
state->distance);
|
||||
}
|
||||
|
||||
static void _astronomy_face_update(movement_event_t event, movement_settings_t *settings, astronomy_state_t *state) {
|
||||
static void _astronomy_face_update(movement_event_t event, astronomy_state_t *state) {
|
||||
char buf[16];
|
||||
switch (state->mode) {
|
||||
case ASTRONOMY_MODE_SELECTING_BODY:
|
||||
@ -150,7 +150,7 @@ static void _astronomy_face_update(movement_event_t event, movement_settings_t *
|
||||
watch_clear_display();
|
||||
// this takes a moment and locks the UI, flash C for "Calculating"
|
||||
watch_start_character_blink('C', 100);
|
||||
_astronomy_face_recalculate(settings, state);
|
||||
_astronomy_face_recalculate(state);
|
||||
watch_stop_blink();
|
||||
state->mode = ASTRONOMY_MODE_DISPLAYING_ALT;
|
||||
// fall through
|
||||
@ -188,8 +188,7 @@ static void _astronomy_face_update(movement_event_t event, movement_settings_t *
|
||||
}
|
||||
}
|
||||
|
||||
void astronomy_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void astronomy_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(astronomy_state_t));
|
||||
@ -197,8 +196,7 @@ void astronomy_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
}
|
||||
}
|
||||
|
||||
void astronomy_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void astronomy_face_activate(void *context) {
|
||||
astronomy_state_t *state = (astronomy_state_t *)context;
|
||||
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
|
||||
int16_t lat_centi = (int16_t)movement_location.bit.latitude;
|
||||
@ -211,13 +209,13 @@ void astronomy_face_activate(movement_settings_t *settings, void *context) {
|
||||
movement_request_tick_frequency(4);
|
||||
}
|
||||
|
||||
bool astronomy_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool astronomy_face_loop(movement_event_t event, void *context) {
|
||||
astronomy_state_t *state = (astronomy_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
case EVENT_TICK:
|
||||
_astronomy_face_update(event, settings, state);
|
||||
_astronomy_face_update(event, state);
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
switch (state->mode) {
|
||||
@ -237,19 +235,19 @@ bool astronomy_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
state->mode++;
|
||||
break;
|
||||
}
|
||||
_astronomy_face_update(event, settings, state);
|
||||
_astronomy_face_update(event, state);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
if (state->mode == ASTRONOMY_MODE_SELECTING_BODY) {
|
||||
// celestial body selected! this triggers a calculation in the update method.
|
||||
state->mode = ASTRONOMY_MODE_CALCULATING;
|
||||
movement_request_tick_frequency(1);
|
||||
_astronomy_face_update(event, settings, state);
|
||||
_astronomy_face_update(event, state);
|
||||
} else if (state->mode != ASTRONOMY_MODE_CALCULATING) {
|
||||
// in all modes except "doing a calculation", return to the selection screen.
|
||||
state->mode = ASTRONOMY_MODE_SELECTING_BODY;
|
||||
movement_request_tick_frequency(4);
|
||||
_astronomy_face_update(event, settings, state);
|
||||
_astronomy_face_update(event, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
@ -259,15 +257,14 @@ bool astronomy_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// TODO?
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void astronomy_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void astronomy_face_resign(void *context) {
|
||||
astronomy_state_t *state = (astronomy_state_t *)context;
|
||||
state->mode = ASTRONOMY_MODE_SELECTING_BODY;
|
||||
}
|
||||
|
||||
@ -93,10 +93,10 @@ typedef struct {
|
||||
double distance; // in AU
|
||||
} astronomy_state_t;
|
||||
|
||||
void astronomy_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void astronomy_face_activate(movement_settings_t *settings, void *context);
|
||||
bool astronomy_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void astronomy_face_resign(movement_settings_t *settings, void *context);
|
||||
void astronomy_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void astronomy_face_activate(void *context);
|
||||
bool astronomy_face_loop(movement_event_t event, void *context);
|
||||
void astronomy_face_resign(void *context);
|
||||
|
||||
#define astronomy_face ((const watch_face_t){ \
|
||||
astronomy_face_setup, \
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
#include "blinky_face.h"
|
||||
#include "watch.h"
|
||||
|
||||
void blinky_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void blinky_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(blinky_face_state_t));
|
||||
@ -36,8 +35,7 @@ void blinky_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
}
|
||||
}
|
||||
|
||||
void blinky_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void blinky_face_activate(void *context) {
|
||||
blinky_face_state_t *state = (blinky_face_state_t *)context;
|
||||
state->active = false;
|
||||
}
|
||||
@ -49,8 +47,7 @@ static void _blinky_face_update_lcd(blinky_face_state_t *state) {
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
bool blinky_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool blinky_face_loop(movement_event_t event, void *context) {
|
||||
blinky_face_state_t *state = (blinky_face_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -92,15 +89,14 @@ bool blinky_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
||||
if (!state->active) movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void blinky_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void blinky_face_resign(void *context) {
|
||||
(void) context;
|
||||
watch_set_led_off();
|
||||
}
|
||||
|
||||
@ -59,10 +59,10 @@ typedef struct {
|
||||
uint8_t color;
|
||||
} blinky_face_state_t;
|
||||
|
||||
void blinky_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void blinky_face_activate(movement_settings_t *settings, void *context);
|
||||
bool blinky_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void blinky_face_resign(movement_settings_t *settings, void *context);
|
||||
void blinky_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void blinky_face_activate(void *context);
|
||||
bool blinky_face_loop(movement_event_t event, void *context);
|
||||
void blinky_face_resign(void *context);
|
||||
|
||||
#define blinky_face ((const watch_face_t){ \
|
||||
blinky_face_setup, \
|
||||
|
||||
@ -37,10 +37,9 @@ static void beep_in_hold (void);
|
||||
static void beep_out (void);
|
||||
static void beep_out_hold (void);
|
||||
|
||||
void breathing_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void breathing_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
// These next two lines just silence the compiler warnings associated with unused parameters.
|
||||
// We have no use for the settings or the watch_face_index, so we make that explicit here.
|
||||
(void) settings;
|
||||
(void) watch_face_index;
|
||||
// At boot, context_ptr will be NULL indicating that we don't have anyplace to store our context.
|
||||
if (*context_ptr == NULL) {
|
||||
@ -49,9 +48,8 @@ void breathing_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
}
|
||||
}
|
||||
|
||||
void breathing_face_activate(movement_settings_t *settings, void *context) {
|
||||
void breathing_face_activate(void *context) {
|
||||
// same as above: silence the warning, we don't need to check the settings.
|
||||
(void) settings;
|
||||
// we do however need to set some things in our context. Here we cast it to the correct type...
|
||||
breathing_state_t *state = (breathing_state_t *)context;
|
||||
// ...and set the initial state of our watch face.
|
||||
@ -125,8 +123,7 @@ void beep_out_hold (void) {
|
||||
}
|
||||
}
|
||||
|
||||
bool breathing_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool breathing_face_loop(movement_event_t event, void *context) {
|
||||
breathing_state_t *state = (breathing_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -193,16 +190,15 @@ bool breathing_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void breathing_face_resign(movement_settings_t *settings, void *context) {
|
||||
void breathing_face_resign(void *context) {
|
||||
// our watch face, like most watch faces, has nothing special to do when resigning.
|
||||
// watch faces that enable a peripheral or interact with a sensor may want to turn it off here.
|
||||
(void) settings;
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void breathing_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void breathing_face_activate(movement_settings_t *settings, void *context);
|
||||
bool breathing_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void breathing_face_resign(movement_settings_t *settings, void *context);
|
||||
void breathing_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void breathing_face_activate(void *context);
|
||||
bool breathing_face_loop(movement_event_t event, void *context);
|
||||
void breathing_face_resign(void *context);
|
||||
|
||||
#define breathing_face ((const watch_face_t){ \
|
||||
breathing_face_setup, \
|
||||
|
||||
@ -416,8 +416,7 @@ static bool _splash_screen(movement_event_t event, butterfly_game_state_t *state
|
||||
return true;
|
||||
}
|
||||
|
||||
void butterfly_game_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void butterfly_game_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -433,14 +432,13 @@ void butterfly_game_face_setup(movement_settings_t *settings, uint8_t watch_face
|
||||
#endif
|
||||
}
|
||||
|
||||
void butterfly_game_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void butterfly_game_face_activate(void *context) {
|
||||
(void) context;
|
||||
|
||||
movement_request_tick_frequency(TICK_FREQ);
|
||||
}
|
||||
|
||||
bool butterfly_game_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool butterfly_game_face_loop(movement_event_t event, void *context) {
|
||||
butterfly_game_state_t *state = (butterfly_game_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -454,12 +452,11 @@ bool butterfly_game_face_loop(movement_event_t event, movement_settings_t *setti
|
||||
movement_move_to_face(0);
|
||||
return true;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
}
|
||||
|
||||
void butterfly_game_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void butterfly_game_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -108,10 +108,10 @@ typedef struct {
|
||||
uint8_t score_p2 : 5;
|
||||
} butterfly_game_state_t;
|
||||
|
||||
void butterfly_game_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void butterfly_game_face_activate(movement_settings_t *settings, void *context);
|
||||
bool butterfly_game_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void butterfly_game_face_resign(movement_settings_t *settings, void *context);
|
||||
void butterfly_game_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void butterfly_game_face_activate(void *context);
|
||||
bool butterfly_game_face_loop(movement_event_t event, void *context);
|
||||
void butterfly_game_face_resign(void *context);
|
||||
|
||||
#define butterfly_game_face ((const watch_face_t){ \
|
||||
butterfly_game_face_setup, \
|
||||
|
||||
@ -121,9 +121,8 @@ static void _display(couch_to_5k_state_t *state, char *buf){
|
||||
}
|
||||
|
||||
|
||||
void couch_to_5k_face_setup(movement_settings_t *settings, uint8_t
|
||||
void couch_to_5k_face_setup(uint8_t
|
||||
watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(couch_to_5k_state_t));
|
||||
@ -163,15 +162,14 @@ void couch_to_5k_face_setup(movement_settings_t *settings, uint8_t
|
||||
// watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void couch_to_5k_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void couch_to_5k_face_activate(void *context) {
|
||||
(void) context;
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
watch_set_colon();
|
||||
}
|
||||
|
||||
|
||||
bool couch_to_5k_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
bool couch_to_5k_face_loop(movement_event_t event,
|
||||
void *context) {
|
||||
couch_to_5k_state_t *state = (couch_to_5k_state_t *)context;
|
||||
static char buf[11];
|
||||
@ -241,7 +239,7 @@ bool couch_to_5k_face_loop(movement_event_t event, movement_settings_t *settings
|
||||
// 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you
|
||||
@ -258,8 +256,7 @@ bool couch_to_5k_face_loop(movement_event_t event, movement_settings_t *settings
|
||||
return true;
|
||||
}
|
||||
|
||||
void couch_to_5k_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void couch_to_5k_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -70,10 +70,10 @@ typedef struct {
|
||||
uint16_t timer;
|
||||
} couch_to_5k_state_t;
|
||||
|
||||
void couch_to_5k_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void couch_to_5k_face_activate(movement_settings_t *settings, void *context);
|
||||
bool couch_to_5k_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void couch_to_5k_face_resign(movement_settings_t *settings, void *context);
|
||||
void couch_to_5k_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void couch_to_5k_face_activate(void *context);
|
||||
bool couch_to_5k_face_loop(movement_event_t event, void *context);
|
||||
void couch_to_5k_face_resign(void *context);
|
||||
|
||||
#define couch_to_5k_face ((const watch_face_t){ \
|
||||
couch_to_5k_face_setup, \
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
#include "counter_face.h"
|
||||
#include "watch.h"
|
||||
|
||||
void counter_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void counter_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(counter_state_t));
|
||||
@ -38,16 +37,14 @@ void counter_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
}
|
||||
}
|
||||
|
||||
void counter_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void counter_face_activate(void *context) {
|
||||
counter_state_t *state = (counter_state_t *)context;
|
||||
if (state->beep_on) {
|
||||
watch_set_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
}
|
||||
|
||||
bool counter_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool counter_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
counter_state_t *state = (counter_state_t *)context;
|
||||
|
||||
@ -83,7 +80,7 @@ bool counter_face_loop(movement_event_t event, movement_settings_t *settings, vo
|
||||
// ignore timeout
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -143,7 +140,6 @@ void print_counter(counter_state_t *state) {
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
void counter_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void counter_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -44,10 +44,10 @@ typedef struct {
|
||||
} counter_state_t;
|
||||
|
||||
|
||||
void counter_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void counter_face_activate(movement_settings_t *settings, void *context);
|
||||
bool counter_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void counter_face_resign(movement_settings_t *settings, void *context);
|
||||
void counter_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void counter_face_activate(void *context);
|
||||
bool counter_face_loop(movement_event_t event, void *context);
|
||||
void counter_face_resign(void *context);
|
||||
|
||||
void print_counter(counter_state_t *state);
|
||||
void beep_counter(counter_state_t *state);
|
||||
|
||||
@ -46,18 +46,16 @@ struct {
|
||||
bool animating;
|
||||
} databank_state;
|
||||
|
||||
void databank_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void databank_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
// These next two lines just silence the compiler warnings associated with unused parameters.
|
||||
// We have no use for the settings or the watch_face_index, so we make that explicit here.
|
||||
(void) settings;
|
||||
(void) context_ptr;
|
||||
(void) watch_face_index;
|
||||
// At boot, context_ptr will be NULL indicating that we don't have anyplace to store our context.
|
||||
}
|
||||
|
||||
void databank_face_activate(movement_settings_t *settings, void *context) {
|
||||
void databank_face_activate(void *context) {
|
||||
// same as above: silence the warning, we don't need to check the settings.
|
||||
(void) settings;
|
||||
(void) context;
|
||||
// we do however need to set some things in our context. Here we cast it to the correct type...
|
||||
databank_state.current_word = 0;
|
||||
@ -85,8 +83,7 @@ static void display()
|
||||
}
|
||||
}
|
||||
|
||||
bool databank_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool databank_face_loop(movement_event_t event, void *context) {
|
||||
(void) context;
|
||||
int max_words = (strlen(pi_data[databank_state.databank_page * 2 + 1]) - 1) / 6 + 1;
|
||||
|
||||
@ -132,16 +129,15 @@ bool databank_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void databank_face_resign(movement_settings_t *settings, void *context) {
|
||||
void databank_face_resign(void *context) {
|
||||
// our watch face, like most watch faces, has nothing special to do when resigning.
|
||||
// watch faces that enable a peripheral or interact with a sensor may want to turn it off here.
|
||||
(void) settings;
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -44,10 +44,10 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void databank_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void databank_face_activate(movement_settings_t *settings, void *context);
|
||||
bool databank_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void databank_face_resign(movement_settings_t *settings, void *context);
|
||||
void databank_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void databank_face_activate(void *context);
|
||||
bool databank_face_loop(movement_event_t event, void *context);
|
||||
void databank_face_resign(void *context);
|
||||
|
||||
#define databank_face ((const watch_face_t){ \
|
||||
databank_face_setup, \
|
||||
|
||||
@ -73,8 +73,7 @@ static void _day_one_face_increment(day_one_state_t *state) {
|
||||
state->birth_day = 1;
|
||||
}
|
||||
|
||||
void day_one_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void day_one_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(day_one_state_t));
|
||||
@ -92,8 +91,7 @@ void day_one_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
}
|
||||
}
|
||||
|
||||
void day_one_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void day_one_face_activate(void *context) {
|
||||
day_one_state_t *state = (day_one_state_t *)context;
|
||||
|
||||
state->current_page = PAGE_DISPLAY;
|
||||
@ -107,8 +105,7 @@ void day_one_face_activate(movement_settings_t *settings, void *context) {
|
||||
state->birth_day = movement_birthdate.bit.day;
|
||||
}
|
||||
|
||||
bool day_one_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool day_one_face_loop(movement_event_t event, void *context) {
|
||||
day_one_state_t *state = (day_one_state_t *)context;
|
||||
|
||||
char buf[9];
|
||||
@ -252,15 +249,14 @@ bool day_one_face_loop(movement_event_t event, movement_settings_t *settings, vo
|
||||
}
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void day_one_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void day_one_face_resign(void *context) {
|
||||
day_one_state_t *state = (day_one_state_t *)context;
|
||||
|
||||
// if the user changed their birth date, store it to the birth date register
|
||||
|
||||
@ -67,10 +67,10 @@ typedef struct {
|
||||
uint8_t ticks;
|
||||
} day_one_state_t;
|
||||
|
||||
void day_one_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void day_one_face_activate(movement_settings_t *settings, void *context);
|
||||
bool day_one_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void day_one_face_resign(movement_settings_t *settings, void *context);
|
||||
void day_one_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void day_one_face_activate(void *context);
|
||||
bool day_one_face_loop(movement_event_t event, void *context);
|
||||
void day_one_face_resign(void *context);
|
||||
|
||||
#define day_one_face ((const watch_face_t){ \
|
||||
day_one_face_setup, \
|
||||
|
||||
@ -107,27 +107,26 @@
|
||||
const char settings_titles[SETTINGS_NUM][3] = { "YR", "MO", "DA", "HR", "M1" };
|
||||
|
||||
/* Local functions */
|
||||
static void _running_init(movement_settings_t *settings, deadline_state_t *state);
|
||||
static bool _running_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
static void _running_display(movement_event_t event, movement_settings_t *settings, deadline_state_t *state);
|
||||
static void _setting_init(movement_settings_t *settings, deadline_state_t *state);
|
||||
static bool _setting_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
static void _setting_display(movement_event_t event, movement_settings_t *settings, deadline_state_t *state, watch_date_time date);
|
||||
static void _running_init(deadline_state_t *state);
|
||||
static bool _running_loop(movement_event_t event, void *context);
|
||||
static void _running_display(movement_event_t event, deadline_state_t *state);
|
||||
static void _setting_init(deadline_state_t *state);
|
||||
static bool _setting_loop(movement_event_t event, void *context);
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time date);
|
||||
|
||||
/* Utility functions */
|
||||
static void _background_alarm_play(movement_settings_t *settings, deadline_state_t *state);
|
||||
static void _background_alarm_schedule(movement_settings_t *settings, deadline_state_t *state);
|
||||
static void _background_alarm_cancel(movement_settings_t *settings, deadline_state_t *state);
|
||||
static void _increment_date(movement_settings_t *settings, deadline_state_t *state, watch_date_time date_time);
|
||||
static inline int32_t _get_tz_offset(movement_settings_t *settings);
|
||||
static void _background_alarm_play(deadline_state_t *state);
|
||||
static void _background_alarm_schedule(deadline_state_t *state);
|
||||
static void _background_alarm_cancel(deadline_state_t *state);
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time date_time);
|
||||
static inline void _change_tick_freq(uint8_t freq, deadline_state_t *state);
|
||||
static inline bool _is_leap(int16_t y);
|
||||
static inline int _days_in_month(int16_t mpnth, int16_t y);
|
||||
static inline unsigned int _mod(int a, int b);
|
||||
static inline void _beep_button(movement_settings_t *settings);
|
||||
static inline void _beep_enable(movement_settings_t *settings);
|
||||
static inline void _beep_disable(movement_settings_t *settings);
|
||||
static inline void _reset_deadline(movement_settings_t *settings, deadline_state_t *state);
|
||||
static inline void _beep_button();
|
||||
static inline void _beep_enable();
|
||||
static inline void _beep_disable();
|
||||
static inline void _reset_deadline(deadline_state_t *state);
|
||||
|
||||
/* Check for leap year */
|
||||
static inline bool _is_leap(int16_t y)
|
||||
@ -156,14 +155,8 @@ static inline int _days_in_month(int16_t month, int16_t year)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return time zone offset */
|
||||
static inline int32_t _get_tz_offset(movement_settings_t *settings)
|
||||
{
|
||||
return movement_get_current_timezone_offset();
|
||||
}
|
||||
|
||||
/* Beep for a button press*/
|
||||
static inline void _beep_button(movement_settings_t *settings)
|
||||
static inline void _beep_button()
|
||||
{
|
||||
// Play a beep as confirmation for a button press (if applicable)
|
||||
if (!movement_button_should_sound())
|
||||
@ -173,7 +166,7 @@ static inline void _beep_button(movement_settings_t *settings)
|
||||
}
|
||||
|
||||
/* Beep for entering settings */
|
||||
static inline void _beep_enable(movement_settings_t *settings)
|
||||
static inline void _beep_enable()
|
||||
{
|
||||
if (!movement_button_should_sound())
|
||||
return;
|
||||
@ -184,7 +177,7 @@ static inline void _beep_enable(movement_settings_t *settings)
|
||||
}
|
||||
|
||||
/* Beep for leaving settings */
|
||||
static inline void _beep_disable(movement_settings_t *settings)
|
||||
static inline void _beep_disable()
|
||||
{
|
||||
if (!movement_button_should_sound())
|
||||
return;
|
||||
@ -204,10 +197,10 @@ static inline void _change_tick_freq(uint8_t freq, deadline_state_t *state)
|
||||
}
|
||||
|
||||
/* Determine index of closest deadline */
|
||||
static uint8_t _closest_deadline(movement_settings_t *settings, deadline_state_t *state)
|
||||
static uint8_t _closest_deadline(deadline_state_t *state)
|
||||
{
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, _get_tz_offset(settings));
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
uint32_t min_ts = UINT32_MAX;
|
||||
uint8_t min_index = 0;
|
||||
|
||||
@ -222,9 +215,8 @@ static uint8_t _closest_deadline(movement_settings_t *settings, deadline_state_t
|
||||
}
|
||||
|
||||
/* Play background alarm */
|
||||
static void _background_alarm_play(movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _background_alarm_play(deadline_state_t *state)
|
||||
{
|
||||
(void) settings;
|
||||
|
||||
/* Use the default alarm from movement and move to foreground */
|
||||
if (state->alarm_enabled) {
|
||||
@ -234,22 +226,21 @@ static void _background_alarm_play(movement_settings_t *settings, deadline_state
|
||||
}
|
||||
|
||||
/* Schedule background alarm */
|
||||
static void _background_alarm_schedule(movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _background_alarm_schedule(deadline_state_t *state)
|
||||
{
|
||||
/* We simply re-use the scheduling in the background task */
|
||||
deadline_face_wants_background_task(settings, state);
|
||||
deadline_face_wants_background_task(state);
|
||||
}
|
||||
|
||||
/* Cancel background alarm */
|
||||
static void _background_alarm_cancel(movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _background_alarm_cancel(deadline_state_t *state)
|
||||
{
|
||||
(void) settings;
|
||||
|
||||
movement_cancel_background_task_for_face(state->face_idx);
|
||||
}
|
||||
|
||||
/* Reset deadline to tomorrow */
|
||||
static inline void _reset_deadline(movement_settings_t *settings, deadline_state_t *state)
|
||||
static inline void _reset_deadline(deadline_state_t *state)
|
||||
{
|
||||
/* Get current time and reset hours/minutes/seconds */
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
@ -258,14 +249,14 @@ static inline void _reset_deadline(movement_settings_t *settings, deadline_state
|
||||
date_time.unit.hour = 0;
|
||||
|
||||
/* Add 24 hours to obtain first second of tomorrow */
|
||||
uint32_t ts = watch_utility_date_time_to_unix_time(date_time, _get_tz_offset(settings));
|
||||
uint32_t ts = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
ts += 24 * 60 * 60;
|
||||
|
||||
state->deadlines[state->current_index] = ts;
|
||||
}
|
||||
|
||||
/* Increment date in settings mode. Function taken from `set_time_face.c` */
|
||||
static void _increment_date(movement_settings_t *settings, deadline_state_t *state, watch_date_time date_time)
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time date_time)
|
||||
{
|
||||
const uint8_t days_in_month[12] = { 31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31 };
|
||||
|
||||
@ -296,15 +287,14 @@ static void _increment_date(movement_settings_t *settings, deadline_state_t *sta
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t ts = watch_utility_date_time_to_unix_time(date_time, _get_tz_offset(settings));
|
||||
uint32_t ts = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
state->deadlines[state->current_index] = ts;
|
||||
}
|
||||
|
||||
/* Update display in running mode */
|
||||
static void _running_display(movement_event_t event, movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _running_display(movement_event_t event, deadline_state_t *state)
|
||||
{
|
||||
(void) event;
|
||||
(void) settings;
|
||||
|
||||
/* Seconds, minutes, hours, days, months, years */
|
||||
int16_t unit[] = { 0, 0, 0, 0, 0, 0 };
|
||||
@ -318,7 +308,7 @@ static void _running_display(movement_event_t event, movement_settings_t *settin
|
||||
watch_clear_indicator(WATCH_INDICATOR_BELL);
|
||||
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, _get_tz_offset(settings));
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
|
||||
/* Deadline expired */
|
||||
if (state->deadlines[state->current_index] < now_ts) {
|
||||
@ -333,7 +323,7 @@ static void _running_display(movement_event_t event, movement_settings_t *settin
|
||||
}
|
||||
|
||||
/* Get date time structs */
|
||||
watch_date_time deadline = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], _get_tz_offset(settings)
|
||||
watch_date_time deadline = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], movement_get_current_timezone_offset()
|
||||
);
|
||||
|
||||
/* Calculate naive difference of dates */
|
||||
@ -378,9 +368,8 @@ static void _running_display(movement_event_t event, movement_settings_t *settin
|
||||
}
|
||||
|
||||
/* Init running mode */
|
||||
static void _running_init(movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _running_init(deadline_state_t *state)
|
||||
{
|
||||
(void) settings;
|
||||
(void) state;
|
||||
|
||||
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||
@ -392,22 +381,22 @@ static void _running_init(movement_settings_t *settings, deadline_state_t *state
|
||||
}
|
||||
|
||||
/* Loop of running mode */
|
||||
static bool _running_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
static bool _running_loop(movement_event_t event, void *context)
|
||||
{
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
|
||||
if (event.event_type != EVENT_BACKGROUND_TASK)
|
||||
_running_display(event, settings, state);
|
||||
_running_display(event, state);
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
_beep_button(settings);
|
||||
_beep_button();
|
||||
state->current_index = (state->current_index + 1) % DEADLINE_FACE_DATES;
|
||||
_running_display(event, settings, state);
|
||||
_running_display(event, state);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
_beep_enable(settings);
|
||||
_setting_init(settings, state);
|
||||
_beep_enable();
|
||||
_setting_init(state);
|
||||
state->mode = DEADLINE_FACE_SETTING;
|
||||
break;
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
@ -416,32 +405,32 @@ static bool _running_loop(movement_event_t event, movement_settings_t *settings,
|
||||
case EVENT_LIGHT_BUTTON_DOWN:
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
_beep_button(settings);
|
||||
_beep_button();
|
||||
state->alarm_enabled = !state->alarm_enabled;
|
||||
if (state->alarm_enabled) {
|
||||
_background_alarm_schedule(settings, context);
|
||||
} else {
|
||||
_background_alarm_cancel(settings, context);
|
||||
}
|
||||
_running_display(event, settings, state);
|
||||
_running_display(event, state);
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
case EVENT_BACKGROUND_TASK:
|
||||
_background_alarm_play(settings, state);
|
||||
_background_alarm_play(state);
|
||||
break;
|
||||
case EVENT_LOW_ENERGY_UPDATE:
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Update display in settings mode */
|
||||
static void _setting_display(movement_event_t event, movement_settings_t *settings, deadline_state_t *state, watch_date_time date_time)
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time date_time)
|
||||
{
|
||||
char buf[11];
|
||||
|
||||
@ -487,13 +476,13 @@ static void _setting_display(movement_event_t event, movement_settings_t *settin
|
||||
}
|
||||
|
||||
/* Init setting mode */
|
||||
static void _setting_init(movement_settings_t *settings, deadline_state_t *state)
|
||||
static void _setting_init(deadline_state_t *state)
|
||||
{
|
||||
state->current_page = 0;
|
||||
|
||||
/* Init fresh deadline to next day */
|
||||
if (state->deadlines[state->current_index] == 0) {
|
||||
_reset_deadline(settings, state);
|
||||
_reset_deadline(state);
|
||||
}
|
||||
|
||||
/* Ensure 1Hz updates only */
|
||||
@ -501,21 +490,21 @@ static void _setting_init(movement_settings_t *settings, deadline_state_t *state
|
||||
}
|
||||
|
||||
/* Loop of setting mode */
|
||||
static bool _setting_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
static bool _setting_loop(movement_event_t event, void *context)
|
||||
{
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
watch_date_time date_time;
|
||||
date_time = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], _get_tz_offset(settings));
|
||||
date_time = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], movement_get_current_timezone_offset());
|
||||
|
||||
if (event.event_type != EVENT_BACKGROUND_TASK)
|
||||
_setting_display(event, settings, state, date_time);
|
||||
_setting_display(event, state, date_time);
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_TICK:
|
||||
if (state->tick_freq == 8) {
|
||||
if (watch_get_pin_level(BTN_ALARM)) {
|
||||
_increment_date(settings, state, date_time);
|
||||
_setting_display(event, settings, state, date_time);
|
||||
_increment_date(state, date_time);
|
||||
_setting_display(event, state, date_time);
|
||||
} else {
|
||||
_change_tick_freq(4, state);
|
||||
}
|
||||
@ -528,48 +517,47 @@ static bool _setting_loop(movement_event_t event, movement_settings_t *settings,
|
||||
_change_tick_freq(4, state);
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
_beep_button(settings);
|
||||
_reset_deadline(settings, state);
|
||||
_beep_button();
|
||||
_reset_deadline(state);
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_DOWN:
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
state->current_page = (state->current_page + 1) % SETTINGS_NUM;
|
||||
_setting_display(event, settings, state, date_time);
|
||||
_setting_display(event, state, date_time);
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
_change_tick_freq(4, state);
|
||||
_increment_date(settings, state, date_time);
|
||||
_setting_display(event, settings, state, date_time);
|
||||
_increment_date(state, date_time);
|
||||
_setting_display(event, state, date_time);
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
_beep_button(settings);
|
||||
_beep_button();
|
||||
_background_alarm_schedule(settings, context);
|
||||
_change_tick_freq(1, state);
|
||||
state->mode = DEADLINE_FACE_RUNNING;
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
_beep_disable(settings);
|
||||
_beep_disable();
|
||||
_background_alarm_schedule(settings, context);
|
||||
_running_init(settings, state);
|
||||
_running_display(event, settings, state);
|
||||
_running_init(state);
|
||||
_running_display(event, state);
|
||||
state->mode = DEADLINE_FACE_RUNNING;
|
||||
break;
|
||||
case EVENT_BACKGROUND_TASK:
|
||||
_background_alarm_play(settings, state);
|
||||
_background_alarm_play(state);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Setup face */
|
||||
void deadline_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr)
|
||||
void deadline_face_setup(uint8_t watch_face_index, void **context_ptr)
|
||||
{
|
||||
(void) settings;
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr != NULL)
|
||||
return; /* Skip setup if context available */
|
||||
@ -584,21 +572,19 @@ void deadline_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
}
|
||||
|
||||
/* Activate face */
|
||||
void deadline_face_activate(movement_settings_t *settings, void *context)
|
||||
void deadline_face_activate(void *context)
|
||||
{
|
||||
(void) settings;
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
|
||||
/* Set display options */
|
||||
_running_init(settings, state);
|
||||
_running_init(state);
|
||||
state->mode = DEADLINE_FACE_RUNNING;
|
||||
state->current_index = _closest_deadline(settings, state);
|
||||
state->current_index = _closest_deadline(state);
|
||||
}
|
||||
|
||||
/* Loop face */
|
||||
bool deadline_face_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
bool deadline_face_loop(movement_event_t event, void *context)
|
||||
{
|
||||
(void) settings;
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
switch (state->mode) {
|
||||
case DEADLINE_FACE_SETTING:
|
||||
@ -614,14 +600,13 @@ bool deadline_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
}
|
||||
|
||||
/* Resign face */
|
||||
void deadline_face_resign(movement_settings_t *settings, void *context)
|
||||
void deadline_face_resign(void *context)
|
||||
{
|
||||
(void) settings;
|
||||
(void) context;
|
||||
}
|
||||
|
||||
/* Want background task */
|
||||
bool deadline_face_wants_background_task(movement_settings_t *settings, void *context)
|
||||
bool deadline_face_wants_background_task(void *context)
|
||||
{
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
|
||||
@ -630,8 +615,8 @@ bool deadline_face_wants_background_task(movement_settings_t *settings, void *co
|
||||
|
||||
/* Determine closest deadline */
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, _get_tz_offset(settings));
|
||||
uint32_t next_ts = state->deadlines[_closest_deadline(settings, state)];
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
uint32_t next_ts = state->deadlines[_closest_deadline(state)];
|
||||
|
||||
/* No active deadline */
|
||||
if (next_ts < now_ts)
|
||||
@ -642,7 +627,7 @@ bool deadline_face_wants_background_task(movement_settings_t *settings, void *co
|
||||
return false;
|
||||
|
||||
/* Deadline within next minute. Let's set up an alarm */
|
||||
watch_date_time next = watch_utility_date_time_from_unix_time(next_ts, _get_tz_offset(settings));
|
||||
watch_date_time next = watch_utility_date_time_from_unix_time(next_ts, movement_get_current_timezone_offset());
|
||||
movement_request_wake();
|
||||
movement_schedule_background_task_for_face(state->face_idx, next);
|
||||
return false;
|
||||
|
||||
@ -48,11 +48,11 @@ typedef struct {
|
||||
uint32_t deadlines[DEADLINE_FACE_DATES];
|
||||
} deadline_state_t;
|
||||
|
||||
void deadline_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
|
||||
void deadline_face_activate(movement_settings_t *settings, void *context);
|
||||
bool deadline_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void deadline_face_resign(movement_settings_t *settings, void *context);
|
||||
bool deadline_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void deadline_face_setup(uint8_t watch_face_index, void **context_ptr);
|
||||
void deadline_face_activate(void *context);
|
||||
bool deadline_face_loop(movement_event_t event, void *context);
|
||||
void deadline_face_resign(void *context);
|
||||
bool deadline_face_wants_background_task(void *context);
|
||||
|
||||
#define deadline_face ((const watch_face_t){ \
|
||||
deadline_face_setup, \
|
||||
|
||||
@ -87,7 +87,7 @@ static const char labels[][2] = {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Beep function */
|
||||
static inline void beep(movement_settings_t *settings) {
|
||||
static inline void beep() {
|
||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_C7, 50);
|
||||
}
|
||||
|
||||
@ -146,8 +146,7 @@ static inline void store_best(discgolf_state_t *state) {
|
||||
}
|
||||
|
||||
/* Configuration at boot, the high score array can be initialized with your high scores if they're known */
|
||||
void discgolf_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void discgolf_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -162,8 +161,7 @@ void discgolf_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
}
|
||||
}
|
||||
|
||||
void discgolf_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void discgolf_face_activate(void *context) {
|
||||
watch_clear_colon();
|
||||
discgolf_state_t *state = (discgolf_state_t *)context;
|
||||
|
||||
@ -178,8 +176,7 @@ void discgolf_face_activate(movement_settings_t *settings, void *context) {
|
||||
movement_request_tick_frequency(4);
|
||||
}
|
||||
|
||||
bool discgolf_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool discgolf_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
discgolf_state_t *state = (discgolf_state_t *)context;
|
||||
|
||||
@ -238,7 +235,7 @@ bool discgolf_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
state->mode = dg_idle;
|
||||
break;
|
||||
}
|
||||
beep(settings);
|
||||
beep();
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
switch (state->mode) {
|
||||
@ -264,14 +261,14 @@ bool discgolf_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
state->mode = dg_setting;
|
||||
store_best(state);
|
||||
reset(state);
|
||||
beep(settings);
|
||||
beep();
|
||||
}
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
/* Snap back to currently playing hole if we've established one*/
|
||||
if ( (state->mode == dg_idle) && (state->hole != state->playing) && (state->playing <= holes[state->course]) ) {
|
||||
state->hole = state->playing;
|
||||
beep(settings);
|
||||
beep();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -319,8 +316,7 @@ bool discgolf_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
return true;
|
||||
}
|
||||
|
||||
void discgolf_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void discgolf_face_resign(void *context) {
|
||||
(void) context;
|
||||
watch_clear_indicator(WATCH_INDICATOR_LAP);
|
||||
}
|
||||
|
||||
@ -78,10 +78,10 @@ typedef struct {
|
||||
discgolf_mode_t mode; // Watch face mode
|
||||
} discgolf_state_t;
|
||||
|
||||
void discgolf_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void discgolf_face_activate(movement_settings_t *settings, void *context);
|
||||
bool discgolf_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void discgolf_face_resign(movement_settings_t *settings, void *context);
|
||||
void discgolf_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void discgolf_face_activate(void *context);
|
||||
bool discgolf_face_loop(movement_event_t event, void *context);
|
||||
void discgolf_face_resign(void *context);
|
||||
|
||||
#define discgolf_face ((const watch_face_t){ \
|
||||
discgolf_face_setup, \
|
||||
|
||||
@ -226,8 +226,7 @@ static void dual_timer_display(dual_timer_state_t *state) {
|
||||
|
||||
// PUBLIC WATCH FACE FUNCTIONS ////////////////////////////////////////////////
|
||||
|
||||
void dual_timer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void dual_timer_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(dual_timer_state_t));
|
||||
@ -239,15 +238,14 @@ void dual_timer_face_setup(movement_settings_t *settings, uint8_t watch_face_ind
|
||||
}
|
||||
}
|
||||
|
||||
void dual_timer_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void dual_timer_face_activate(void *context) {
|
||||
(void) context;
|
||||
if (_is_running) {
|
||||
movement_schedule_background_task(distant_future);
|
||||
}
|
||||
}
|
||||
|
||||
bool dual_timer_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool dual_timer_face_loop(movement_event_t event, void *context) {
|
||||
dual_timer_state_t *state = (dual_timer_state_t *)context;
|
||||
|
||||
// timers stop at 99:23:59:59:99
|
||||
@ -319,14 +317,13 @@ bool dual_timer_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
dual_timer_display(state);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void dual_timer_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void dual_timer_face_resign(void *context) {
|
||||
(void) context;
|
||||
movement_cancel_background_task();
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -85,10 +85,10 @@ typedef struct {
|
||||
bool show;
|
||||
} dual_timer_state_t;
|
||||
|
||||
void dual_timer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void dual_timer_face_activate(movement_settings_t *settings, void *context);
|
||||
bool dual_timer_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void dual_timer_face_resign(movement_settings_t *settings, void *context);
|
||||
void dual_timer_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void dual_timer_face_activate(void *context);
|
||||
bool dual_timer_face_loop(movement_event_t event, void *context);
|
||||
void dual_timer_face_resign(void *context);
|
||||
|
||||
#if __EMSCRIPTEN__
|
||||
void em_dual_timer_cb_handler(void *userData);
|
||||
|
||||
@ -539,8 +539,7 @@ static void update_game(endless_runner_state_t *state, uint8_t subsecond) {
|
||||
display_fuel(subsecond, state -> difficulty);
|
||||
}
|
||||
|
||||
void endless_runner_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void endless_runner_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(endless_runner_state_t));
|
||||
@ -550,12 +549,11 @@ void endless_runner_face_setup(movement_settings_t *settings, uint8_t watch_face
|
||||
}
|
||||
}
|
||||
|
||||
void endless_runner_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void endless_runner_face_activate(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool endless_runner_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool endless_runner_face_loop(movement_event_t event, void *context) {
|
||||
endless_runner_state_t *state = (endless_runner_state_t *)context;
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
@ -605,13 +603,12 @@ bool endless_runner_face_loop(movement_event_t event, movement_settings_t *setti
|
||||
display_time(watch_rtc_get_date_time(), movement_clock_mode_24h());
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void endless_runner_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void endless_runner_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -45,10 +45,10 @@ typedef struct {
|
||||
/* 24 bits, likely aligned to 32 bits = 4 bytes */
|
||||
} endless_runner_state_t;
|
||||
|
||||
void endless_runner_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void endless_runner_face_activate(movement_settings_t *settings, void *context);
|
||||
bool endless_runner_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void endless_runner_face_resign(movement_settings_t *settings, void *context);
|
||||
void endless_runner_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void endless_runner_face_activate(void *context);
|
||||
bool endless_runner_face_loop(movement_event_t event, void *context);
|
||||
void endless_runner_face_resign(void *context);
|
||||
|
||||
#define endless_runner_face ((const watch_face_t){ \
|
||||
endless_runner_face_setup, \
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
#include <string.h>
|
||||
#include "flashlight_face.h"
|
||||
|
||||
void flashlight_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void flashlight_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(flashlight_state_t));
|
||||
@ -37,15 +36,14 @@ void flashlight_face_setup(movement_settings_t *settings, uint8_t watch_face_ind
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void flashlight_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void flashlight_face_activate(void *context) {
|
||||
(void) context;
|
||||
|
||||
watch_enable_digital_output(A2);
|
||||
watch_set_pin_level(A2, false);
|
||||
}
|
||||
|
||||
bool flashlight_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool flashlight_face_loop(movement_event_t event, void *context) {
|
||||
(void) context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -65,14 +63,13 @@ bool flashlight_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void flashlight_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void flashlight_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
watch_set_pin_level(A2, false);
|
||||
|
||||
@ -42,10 +42,10 @@ typedef struct {
|
||||
uint8_t unused;
|
||||
} flashlight_state_t;
|
||||
|
||||
void flashlight_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void flashlight_face_activate(movement_settings_t *settings, void *context);
|
||||
bool flashlight_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void flashlight_face_resign(movement_settings_t *settings, void *context);
|
||||
void flashlight_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void flashlight_face_activate(void *context);
|
||||
bool flashlight_face_loop(movement_event_t event, void *context);
|
||||
void flashlight_face_resign(void *context);
|
||||
|
||||
#define flashlight_face ((const watch_face_t){ \
|
||||
flashlight_face_setup, \
|
||||
|
||||
@ -71,21 +71,19 @@ static void _throw_animation(geomancy_state_t *state);
|
||||
|
||||
// WATCH FACE FUNCTIONS ///////////////////////////////////////////////////////
|
||||
|
||||
void geomancy_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void geomancy_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
(void) settings;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(geomancy_state_t));
|
||||
memset(*context_ptr, 0, sizeof(geomancy_state_t));
|
||||
}
|
||||
}
|
||||
|
||||
void geomancy_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void geomancy_face_activate(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool geomancy_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool geomancy_face_loop(movement_event_t event, void *context) {
|
||||
geomancy_state_t *state = (geomancy_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -137,13 +135,12 @@ bool geomancy_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
geomancy_face_display(state);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void geomancy_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void geomancy_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -82,10 +82,10 @@ typedef struct {
|
||||
bool animate;
|
||||
} geomancy_state_t;
|
||||
|
||||
void geomancy_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void geomancy_face_activate(movement_settings_t *settings, void *context);
|
||||
bool geomancy_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void geomancy_face_resign(movement_settings_t *settings, void *context);
|
||||
void geomancy_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void geomancy_face_activate(void *context);
|
||||
bool geomancy_face_loop(movement_event_t event, void *context);
|
||||
void geomancy_face_resign(void *context);
|
||||
|
||||
#define geomancy_face ((const watch_face_t){ \
|
||||
geomancy_face_setup, \
|
||||
|
||||
@ -48,9 +48,8 @@ typedef struct {
|
||||
bool display_total;
|
||||
} habit_state_t;
|
||||
|
||||
void habit_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
void habit_face_setup(uint8_t watch_face_index,
|
||||
void **context_ptr) {
|
||||
(void)settings;
|
||||
(void)watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(habit_state_t));
|
||||
@ -101,13 +100,12 @@ static inline void display_state(habit_state_t *state) {
|
||||
}
|
||||
}
|
||||
|
||||
void habit_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void)settings;
|
||||
void habit_face_activate(void *context) {
|
||||
habit_state_t *state = (habit_state_t *)context;
|
||||
display_state(state);
|
||||
}
|
||||
|
||||
bool habit_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
bool habit_face_loop(movement_event_t event,
|
||||
void *context) {
|
||||
habit_state_t *state = (habit_state_t *)context;
|
||||
|
||||
@ -146,12 +144,11 @@ bool habit_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void habit_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void)settings;
|
||||
void habit_face_resign(void *context) {
|
||||
(void)context;
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void habit_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
void habit_face_setup(uint8_t watch_face_index,
|
||||
void **context_ptr);
|
||||
void habit_face_activate(movement_settings_t *settings, void *context);
|
||||
bool habit_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void habit_face_resign(movement_settings_t *settings, void *context);
|
||||
void habit_face_activate(void *context);
|
||||
bool habit_face_loop(movement_event_t event, void *context);
|
||||
void habit_face_resign(void *context);
|
||||
|
||||
#define habit_face ((const watch_face_t){ \
|
||||
habit_face_setup, \
|
||||
|
||||
@ -327,8 +327,7 @@ static void alarm_button_handler(void) {
|
||||
do_game_loop(HL_GUESS_LOWER);
|
||||
}
|
||||
|
||||
void higher_lower_game_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||
(void) settings;
|
||||
void higher_lower_game_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -340,15 +339,14 @@ void higher_lower_game_face_setup(movement_settings_t *settings, uint8_t watch_f
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void higher_lower_game_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void higher_lower_game_face_activate(void *context) {
|
||||
higher_lower_game_face_state_t *state = (higher_lower_game_face_state_t *) context;
|
||||
(void) state;
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
game_state = HL_GS_TITLE_SCREEN;
|
||||
}
|
||||
|
||||
bool higher_lower_game_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool higher_lower_game_face_loop(movement_event_t event, void *context) {
|
||||
higher_lower_game_face_state_t *state = (higher_lower_game_face_state_t *) context;
|
||||
(void) state;
|
||||
|
||||
@ -376,7 +374,7 @@ bool higher_lower_game_face_loop(movement_event_t event, movement_settings_t *se
|
||||
// movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you should always return true.
|
||||
@ -388,8 +386,7 @@ bool higher_lower_game_face_loop(movement_event_t event, movement_settings_t *se
|
||||
return true;
|
||||
}
|
||||
|
||||
void higher_lower_game_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void higher_lower_game_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -90,10 +90,10 @@ typedef struct {
|
||||
// Anything you need to keep track of, put it here!
|
||||
} higher_lower_game_face_state_t;
|
||||
|
||||
void higher_lower_game_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void higher_lower_game_face_activate(movement_settings_t *settings, void *context);
|
||||
bool higher_lower_game_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void higher_lower_game_face_resign(movement_settings_t *settings, void *context);
|
||||
void higher_lower_game_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void higher_lower_game_face_activate(void *context);
|
||||
bool higher_lower_game_face_loop(movement_event_t event, void *context);
|
||||
void higher_lower_game_face_resign(void *context);
|
||||
|
||||
#define higher_lower_game_face ((const watch_face_t){ \
|
||||
higher_lower_game_face_setup, \
|
||||
|
||||
@ -97,7 +97,7 @@ static uint32_t _get_now_ts() {
|
||||
return watch_utility_date_time_to_unix_time(now, 0);
|
||||
}
|
||||
|
||||
static inline void _button_beep(movement_settings_t *settings) {
|
||||
static inline void _button_beep() {
|
||||
// play a beep as confirmation for a button press (if applicable)
|
||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_C7, 50);
|
||||
}
|
||||
@ -369,8 +369,7 @@ static void _resume_paused_timer(interval_face_state_t *state) {
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
}
|
||||
|
||||
void interval_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||
(void) settings;
|
||||
void interval_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(interval_face_state_t));
|
||||
@ -394,8 +393,7 @@ void interval_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
}
|
||||
}
|
||||
|
||||
void interval_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void interval_face_activate(void *context) {
|
||||
interval_face_state_t *state = (interval_face_state_t *)context;
|
||||
_erase_timer_flag = false;
|
||||
state->is_active = true;
|
||||
@ -407,8 +405,7 @@ void interval_face_activate(movement_settings_t *settings, void *context) {
|
||||
} else watch_set_colon();
|
||||
}
|
||||
|
||||
void interval_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void interval_face_resign(void *context) {
|
||||
interval_face_state_t *state = (interval_face_state_t *)context;
|
||||
if (state->face_state <= interval_state_setting) state->face_state = interval_state_waiting;
|
||||
watch_set_led_off();
|
||||
@ -416,7 +413,7 @@ void interval_face_resign(movement_settings_t *settings, void *context) {
|
||||
state->is_active = false;
|
||||
}
|
||||
|
||||
bool interval_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool interval_face_loop(movement_event_t event, void *context) {
|
||||
interval_face_state_t *state = (interval_face_state_t *)context;
|
||||
interval_timer_setting_t *timer = &state->timer[state->timer_idx];
|
||||
|
||||
@ -618,7 +615,7 @@ bool interval_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -111,10 +111,10 @@ typedef struct {
|
||||
interval_timer_setting_t timer[INTERVAL_TIMERS];
|
||||
} interval_face_state_t;
|
||||
|
||||
void interval_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void interval_face_activate(movement_settings_t *settings, void *context);
|
||||
bool interval_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void interval_face_resign(movement_settings_t *settings, void *context);
|
||||
void interval_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void interval_face_activate(void *context);
|
||||
bool interval_face_loop(movement_event_t event, void *context);
|
||||
void interval_face_resign(void *context);
|
||||
|
||||
#define interval_face ((const watch_face_t) { \
|
||||
interval_face_setup, \
|
||||
|
||||
@ -203,8 +203,7 @@ static bool _move_invaders() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void invaders_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void invaders_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(invaders_state_t));
|
||||
@ -220,14 +219,13 @@ void invaders_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
#endif
|
||||
}
|
||||
|
||||
void invaders_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void invaders_face_activate(void *context) {
|
||||
(void) context;
|
||||
_current_state = invaders_state_activated;
|
||||
_signals.suspend_buttons = false;
|
||||
}
|
||||
|
||||
bool invaders_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool invaders_face_loop(movement_event_t event, void *context) {
|
||||
invaders_state_t *state = (invaders_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -414,7 +412,7 @@ bool invaders_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
// * 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
// return true if the watch can enter standby mode. Generally speaking, you should always return true.
|
||||
@ -426,8 +424,7 @@ bool invaders_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
return true;
|
||||
}
|
||||
|
||||
void invaders_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void invaders_face_resign(void *context) {
|
||||
(void) context;
|
||||
_current_state = invaders_state_game_over;
|
||||
}
|
||||
|
||||
@ -65,10 +65,10 @@ typedef struct {
|
||||
bool sound_on;
|
||||
} invaders_state_t;
|
||||
|
||||
void invaders_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void invaders_face_activate(movement_settings_t *settings, void *context);
|
||||
bool invaders_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void invaders_face_resign(movement_settings_t *settings, void *context);
|
||||
void invaders_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void invaders_face_activate(void *context);
|
||||
bool invaders_face_loop(movement_event_t event, void *context);
|
||||
void invaders_face_resign(void *context);
|
||||
|
||||
#define invaders_face ((const watch_face_t){ \
|
||||
invaders_face_setup, \
|
||||
|
||||
@ -79,7 +79,7 @@ static int8_t calc_success_seq[5] = {BUZZER_NOTE_G6, 10, BUZZER_NOTE_C7, 10, 0};
|
||||
static int8_t calc_fail_seq[5] = {BUZZER_NOTE_C7, 10, BUZZER_NOTE_G6, 10, 0};
|
||||
|
||||
// Resets all state variables to 0
|
||||
static void reset_state(kitchen_conversions_state_t *state, movement_settings_t *settings)
|
||||
static void reset_state(kitchen_conversions_state_t *state)
|
||||
{
|
||||
state->pg = measurement;
|
||||
state->measurement_i = 0;
|
||||
@ -92,9 +92,8 @@ static void reset_state(kitchen_conversions_state_t *state, movement_settings_t
|
||||
state->light_held = false;
|
||||
}
|
||||
|
||||
void kitchen_conversions_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr)
|
||||
void kitchen_conversions_face_setup(uint8_t watch_face_index, void **context_ptr)
|
||||
{
|
||||
(void)settings;
|
||||
(void)watch_face_index;
|
||||
if (*context_ptr == NULL)
|
||||
{
|
||||
@ -105,9 +104,8 @@ void kitchen_conversions_face_setup(movement_settings_t *settings, uint8_t watch
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void kitchen_conversions_face_activate(movement_settings_t *settings, void *context)
|
||||
void kitchen_conversions_face_activate(void *context)
|
||||
{
|
||||
(void)settings;
|
||||
kitchen_conversions_state_t *state = (kitchen_conversions_state_t *)context;
|
||||
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
@ -168,7 +166,7 @@ static void display_units(uint8_t measurement_i, uint8_t list_i)
|
||||
watch_display_string(get_unit_list(measurement_i)[list_i].name, 4);
|
||||
}
|
||||
|
||||
static void display(kitchen_conversions_state_t *state, movement_settings_t *settings, uint8_t subsec)
|
||||
static void display(kitchen_conversions_state_t *state, uint8_t subsec)
|
||||
{
|
||||
watch_clear_display();
|
||||
|
||||
@ -290,7 +288,7 @@ static void display(kitchen_conversions_state_t *state, movement_settings_t *set
|
||||
}
|
||||
}
|
||||
|
||||
bool kitchen_conversions_face_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
bool kitchen_conversions_face_loop(movement_event_t event, void *context)
|
||||
{
|
||||
kitchen_conversions_state_t *state = (kitchen_conversions_state_t *)context;
|
||||
|
||||
@ -465,15 +463,14 @@ bool kitchen_conversions_face_loop(movement_event_t event, movement_settings_t *
|
||||
break;
|
||||
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void kitchen_conversions_face_resign(movement_settings_t *settings, void *context)
|
||||
void kitchen_conversions_face_resign(void *context)
|
||||
{
|
||||
(void)settings;
|
||||
(void)context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -71,10 +71,10 @@ typedef struct
|
||||
bool light_held;
|
||||
} kitchen_conversions_state_t;
|
||||
|
||||
void kitchen_conversions_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
|
||||
void kitchen_conversions_face_activate(movement_settings_t *settings, void *context);
|
||||
bool kitchen_conversions_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void kitchen_conversions_face_resign(movement_settings_t *settings, void *context);
|
||||
void kitchen_conversions_face_setup(uint8_t watch_face_index, void **context_ptr);
|
||||
void kitchen_conversions_face_activate(void *context);
|
||||
bool kitchen_conversions_face_loop(movement_event_t event, void *context);
|
||||
void kitchen_conversions_face_resign(void *context);
|
||||
|
||||
#define kitchen_conversions_face ((const watch_face_t){ \
|
||||
kitchen_conversions_face_setup, \
|
||||
|
||||
@ -85,7 +85,7 @@ const char menstrual_cycle_face_titles[MENSTRUAL_CYCLE_FACE_NUM_PAGES][11] = {
|
||||
};
|
||||
|
||||
/* Beep function */
|
||||
static inline void beep(movement_settings_t *settings) {
|
||||
static inline void beep() {
|
||||
if (movement_button_should_sound())
|
||||
watch_buzzer_play_note(BUZZER_NOTE_E8, 75);
|
||||
}
|
||||
@ -250,9 +250,8 @@ static inline void update_shortest_longest_cycle(menstrual_cycle_state_t *state)
|
||||
state->cycles.bit.longest_cycle = cycle_length;
|
||||
}
|
||||
|
||||
void menstrual_cycle_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void menstrual_cycle_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
(void) settings;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(menstrual_cycle_state_t));
|
||||
@ -295,8 +294,7 @@ void menstrual_cycle_face_setup(movement_settings_t *settings, uint8_t watch_fac
|
||||
}
|
||||
}
|
||||
|
||||
void menstrual_cycle_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void menstrual_cycle_face_activate(void *context) {
|
||||
menstrual_cycle_state_t *state = (menstrual_cycle_state_t *)context;
|
||||
state->period_today = 0;
|
||||
state->current_page = 0;
|
||||
@ -305,7 +303,7 @@ void menstrual_cycle_face_activate(movement_settings_t *settings, void *context)
|
||||
movement_request_tick_frequency(4); // we need to manually blink some pixels
|
||||
}
|
||||
|
||||
bool menstrual_cycle_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool menstrual_cycle_face_loop(movement_event_t event, void *context) {
|
||||
menstrual_cycle_state_t *state = (menstrual_cycle_state_t *)context;
|
||||
watch_date_time date_period;
|
||||
uint8_t current_page = state->current_page;
|
||||
@ -406,7 +404,7 @@ bool menstrual_cycle_face_loop(movement_event_t event, movement_settings_t *sett
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
watch_display_string((char *)menstrual_cycle_face_titles[current_page], 0);
|
||||
@ -466,7 +464,6 @@ bool menstrual_cycle_face_loop(movement_event_t event, movement_settings_t *sett
|
||||
return true;
|
||||
}
|
||||
|
||||
void menstrual_cycle_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void menstrual_cycle_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
@ -64,10 +64,10 @@ typedef struct {
|
||||
bool reset_tracking;
|
||||
} menstrual_cycle_state_t;
|
||||
|
||||
void menstrual_cycle_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void menstrual_cycle_face_activate(movement_settings_t *settings, void *context);
|
||||
bool menstrual_cycle_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void menstrual_cycle_face_resign(movement_settings_t *settings, void *context);
|
||||
void menstrual_cycle_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void menstrual_cycle_face_activate(void *context);
|
||||
bool menstrual_cycle_face_loop(movement_event_t event, void *context);
|
||||
void menstrual_cycle_face_resign(void *context);
|
||||
|
||||
#define menstrual_cycle_face ((const watch_face_t){ \
|
||||
menstrual_cycle_face_setup, \
|
||||
|
||||
@ -30,8 +30,7 @@
|
||||
static const int8_t _sound_seq_start[] = {BUZZER_NOTE_C8, 2, 0};
|
||||
static const int8_t _sound_seq_beat[] = {BUZZER_NOTE_C6, 2, 0};
|
||||
|
||||
void metronome_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void metronome_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(metronome_state_t));
|
||||
@ -39,8 +38,7 @@ void metronome_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
}
|
||||
}
|
||||
|
||||
void metronome_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void metronome_face_activate(void *context) {
|
||||
metronome_state_t *state = (metronome_state_t *)context;
|
||||
movement_request_tick_frequency(2);
|
||||
if (state->bpm == 0) {
|
||||
@ -200,7 +198,7 @@ static void _metronome_update_setting(metronome_state_t *state) {
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
bool metronome_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool metronome_face_loop(movement_event_t event, void *context) {
|
||||
metronome_state_t *state = (metronome_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -251,13 +249,12 @@ bool metronome_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
case EVENT_LOW_ENERGY_UPDATE:
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void metronome_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void metronome_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -69,10 +69,10 @@ typedef struct {
|
||||
bool soundOn;
|
||||
} metronome_state_t;
|
||||
|
||||
void metronome_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void metronome_face_activate(movement_settings_t *settings, void *context);
|
||||
bool metronome_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void metronome_face_resign(movement_settings_t *settings, void *context);
|
||||
void metronome_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void metronome_face_activate(void *context);
|
||||
bool metronome_face_loop(movement_event_t event, void *context);
|
||||
void metronome_face_resign(void *context);
|
||||
|
||||
#define metronome_face ((const watch_face_t){ \
|
||||
metronome_face_setup, \
|
||||
|
||||
@ -41,8 +41,7 @@
|
||||
|
||||
static const float phase_changes[] = {0, 1, 6.38264692644, 8.38264692644, 13.76529385288, 15.76529385288, 21.14794077932, 23.14794077932, 28.53058770576, 29.53058770576};
|
||||
|
||||
void moon_phase_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void moon_phase_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(moon_phase_state_t));
|
||||
@ -50,12 +49,11 @@ void moon_phase_face_setup(movement_settings_t *settings, uint8_t watch_face_ind
|
||||
}
|
||||
}
|
||||
|
||||
void moon_phase_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void moon_phase_face_activate(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
static void _update(movement_settings_t *settings, moon_phase_state_t *state, uint32_t offset) {
|
||||
static void _update(moon_phase_state_t *state, uint32_t offset) {
|
||||
(void)state;
|
||||
char buf[11];
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
@ -132,23 +130,23 @@ static void _update(movement_settings_t *settings, moon_phase_state_t *state, ui
|
||||
watch_display_string(buf, 2);
|
||||
}
|
||||
|
||||
bool moon_phase_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool moon_phase_face_loop(movement_event_t event, void *context) {
|
||||
moon_phase_state_t *state = (moon_phase_state_t *)context;
|
||||
watch_date_time date_time;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
_update(settings, state, state->offset);
|
||||
_update(state, state->offset);
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
// only update once an hour
|
||||
date_time = watch_rtc_get_date_time();
|
||||
if ((date_time.unit.minute == 0) && (date_time.unit.second == 0)) _update(settings, state, state->offset);
|
||||
if ((date_time.unit.minute == 0) && (date_time.unit.second == 0)) _update(state, state->offset);
|
||||
break;
|
||||
case EVENT_LOW_ENERGY_UPDATE:
|
||||
// update at the top of the hour OR if we're entering sleep mode with an offset.
|
||||
// also, in sleep mode, always show the current moon phase (offset = 0).
|
||||
if (state->offset || (watch_rtc_get_date_time().unit.minute == 0)) _update(settings, state, 0);
|
||||
if (state->offset || (watch_rtc_get_date_time().unit.minute == 0)) _update(state, 0);
|
||||
// and kill the offset so when the wearer wakes up, it matches what's on screen.
|
||||
state->offset = 0;
|
||||
// finally: clear out the last two digits and replace them with the sleep mode indicator
|
||||
@ -159,24 +157,23 @@ bool moon_phase_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// Pressing the alarm adds an offset of one day to the displayed value,
|
||||
// so you can see moon phases in the future.
|
||||
state->offset += 86400;
|
||||
_update(settings, state, state->offset);
|
||||
_update(state, state->offset);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
state->offset = 0;
|
||||
_update(settings, state, state->offset);
|
||||
_update(state, state->offset);
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
// QUESTION: Should timeout reset offset to 0?
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void moon_phase_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void moon_phase_face_resign(void *context) {
|
||||
moon_phase_state_t *state = (moon_phase_state_t *)context;
|
||||
state->offset = 0;
|
||||
}
|
||||
|
||||
@ -55,10 +55,10 @@ typedef struct {
|
||||
uint32_t offset;
|
||||
} moon_phase_state_t;
|
||||
|
||||
void moon_phase_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void moon_phase_face_activate(movement_settings_t *settings, void *context);
|
||||
bool moon_phase_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void moon_phase_face_resign(movement_settings_t *settings, void *context);
|
||||
void moon_phase_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void moon_phase_face_activate(void *context);
|
||||
bool moon_phase_face_loop(movement_event_t event, void *context);
|
||||
void moon_phase_face_resign(void *context);
|
||||
|
||||
#define moon_phase_face ((const watch_face_t){ \
|
||||
moon_phase_face_setup, \
|
||||
|
||||
@ -106,8 +106,7 @@ void morsecalc_input(morsecalc_state_t * mcs) {
|
||||
return;
|
||||
}
|
||||
|
||||
void morsecalc_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void morsecalc_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(morsecalc_state_t));
|
||||
@ -122,15 +121,14 @@ void morsecalc_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
return;
|
||||
}
|
||||
|
||||
void morsecalc_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void morsecalc_face_activate(void *context) {
|
||||
morsecalc_state_t *mcs = (morsecalc_state_t *) context;
|
||||
mcs->mc = 0;
|
||||
morsecalc_display_stack(mcs);
|
||||
return;
|
||||
}
|
||||
|
||||
bool morsecalc_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool morsecalc_face_loop(movement_event_t event, void *context) {
|
||||
morsecalc_state_t *mcs = (morsecalc_state_t *) context;
|
||||
switch(event.event_type) {
|
||||
// input
|
||||
@ -190,15 +188,14 @@ bool morsecalc_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void morsecalc_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void morsecalc_face_resign(void *context) {
|
||||
morsecalc_state_t *mcs = (morsecalc_state_t *) context;
|
||||
mcs->led_is_on = 0;
|
||||
watch_set_led_off();
|
||||
|
||||
@ -136,10 +136,10 @@
|
||||
*/
|
||||
static const char MORSECODE_TREE[] = " etianmsurwdkgohvf\0l\0pjbxcyzq\0C\x35\x34V\x33\0R\0\x32W\0+\0\0\0\0\x31\x36=/\0\0S(\0\x37\0\0\0\x38\0\x39\x30\0\0\0\0\0E\0\0\0\0\0\0?_\0\0\0\0\"\0\0.\0\0\0\0@\0\0\0'\0\0-\0\0\0\0\0\0\0\0;!\0)\0\0\0\0\0,\0\0\0\0:\0\0\0\0\0\0";
|
||||
|
||||
void morsecalc_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void morsecalc_face_activate(movement_settings_t *settings, void *context);
|
||||
bool morsecalc_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void morsecalc_face_resign(movement_settings_t *settings, void *context);
|
||||
void morsecalc_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void morsecalc_face_activate(void *context);
|
||||
bool morsecalc_face_loop(movement_event_t event, void *context);
|
||||
void morsecalc_face_resign(void *context);
|
||||
|
||||
typedef struct {
|
||||
calc_state_t *cs;
|
||||
|
||||
@ -46,7 +46,7 @@ static const char orrery_celestial_body_names[NUM_AVAILABLE_BODIES][3] = {
|
||||
"NE" // Neptune
|
||||
};
|
||||
|
||||
static void _orrery_face_recalculate(movement_settings_t *settings, orrery_state_t *state) {
|
||||
static void _orrery_face_recalculate(orrery_state_t *state) {
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
date_time = watch_utility_date_time_from_unix_time(timestamp, 0);
|
||||
@ -94,7 +94,7 @@ static void _orrery_face_recalculate(movement_settings_t *settings, orrery_state
|
||||
state->coords[2] = r[2];
|
||||
}
|
||||
|
||||
static void _orrery_face_update(movement_event_t event, movement_settings_t *settings, orrery_state_t *state) {
|
||||
static void _orrery_face_update(movement_event_t event, orrery_state_t *state) {
|
||||
char buf[11];
|
||||
switch (state->mode) {
|
||||
case ORRERY_MODE_SELECTING_BODY:
|
||||
@ -127,7 +127,7 @@ static void _orrery_face_update(movement_event_t event, movement_settings_t *set
|
||||
watch_clear_display();
|
||||
// this takes a moment and locks the UI, flash C for "Calculating"
|
||||
watch_start_character_blink('C', 100);
|
||||
_orrery_face_recalculate(settings, state);
|
||||
_orrery_face_recalculate(state);
|
||||
watch_stop_blink();
|
||||
state->mode = ORRERY_MODE_DISPLAYING_X;
|
||||
// fall through
|
||||
@ -149,8 +149,7 @@ static void _orrery_face_update(movement_event_t event, movement_settings_t *set
|
||||
}
|
||||
}
|
||||
|
||||
void orrery_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void orrery_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(orrery_state_t));
|
||||
@ -158,20 +157,18 @@ void orrery_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
}
|
||||
}
|
||||
|
||||
void orrery_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void orrery_face_activate(void *context) {
|
||||
(void) context;
|
||||
movement_request_tick_frequency(4);
|
||||
}
|
||||
|
||||
bool orrery_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool orrery_face_loop(movement_event_t event, void *context) {
|
||||
orrery_state_t *state = (orrery_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
case EVENT_TICK:
|
||||
_orrery_face_update(event, settings, state);
|
||||
_orrery_face_update(event, state);
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
switch (state->mode) {
|
||||
@ -191,34 +188,33 @@ bool orrery_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
||||
state->mode++;
|
||||
break;
|
||||
}
|
||||
_orrery_face_update(event, settings, state);
|
||||
_orrery_face_update(event, state);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
if (state->mode == ORRERY_MODE_SELECTING_BODY) {
|
||||
// celestial body selected! this triggers a calculation in the update method.
|
||||
state->mode = ORRERY_MODE_CALCULATING;
|
||||
movement_request_tick_frequency(1);
|
||||
_orrery_face_update(event, settings, state);
|
||||
_orrery_face_update(event, state);
|
||||
} else if (state->mode != ORRERY_MODE_CALCULATING) {
|
||||
// in all modes except "doing a calculation", return to the selection screen.
|
||||
state->mode = ORRERY_MODE_SELECTING_BODY;
|
||||
movement_request_tick_frequency(4);
|
||||
_orrery_face_update(event, settings, state);
|
||||
_orrery_face_update(event, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void orrery_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void orrery_face_resign(void *context) {
|
||||
orrery_state_t *state = (orrery_state_t *)context;
|
||||
state->mode = ORRERY_MODE_SELECTING_BODY;
|
||||
}
|
||||
|
||||
@ -85,10 +85,10 @@ typedef struct {
|
||||
uint8_t animation_state;
|
||||
} orrery_state_t;
|
||||
|
||||
void orrery_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void orrery_face_activate(movement_settings_t *settings, void *context);
|
||||
bool orrery_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void orrery_face_resign(movement_settings_t *settings, void *context);
|
||||
void orrery_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void orrery_face_activate(void *context);
|
||||
bool orrery_face_loop(movement_event_t event, void *context);
|
||||
void orrery_face_resign(void *context);
|
||||
|
||||
#define orrery_face ((const watch_face_t){ \
|
||||
orrery_face_setup, \
|
||||
|
||||
@ -36,9 +36,8 @@ static int16_t _text_pos;
|
||||
static const char* _text_looping;
|
||||
static const char title_text[] = "Periodic Table";
|
||||
|
||||
void periodic_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr)
|
||||
void periodic_face_setup(uint8_t watch_face_index, void **context_ptr)
|
||||
{
|
||||
(void)settings;
|
||||
(void)watch_face_index;
|
||||
if (*context_ptr == NULL)
|
||||
{
|
||||
@ -47,9 +46,8 @@ void periodic_face_setup(movement_settings_t *settings, uint8_t watch_face_index
|
||||
}
|
||||
}
|
||||
|
||||
void periodic_face_activate(movement_settings_t *settings, void *context)
|
||||
void periodic_face_activate(void *context)
|
||||
{
|
||||
(void)settings;
|
||||
periodic_state_t *state = (periodic_state_t *)context;
|
||||
|
||||
state->atomic_num = 0;
|
||||
@ -390,7 +388,7 @@ static void _handle_mode_still_pressed(periodic_state_t *state, bool should_soun
|
||||
}
|
||||
}
|
||||
|
||||
bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, void *context)
|
||||
bool periodic_face_loop(movement_event_t event, void *context)
|
||||
{
|
||||
periodic_state_t *state = (periodic_state_t *)context;
|
||||
switch (event.event_type)
|
||||
@ -488,15 +486,14 @@ bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
watch_start_tick_animation(500);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void periodic_face_resign(movement_settings_t *settings, void *context)
|
||||
void periodic_face_resign(void *context)
|
||||
{
|
||||
(void)settings;
|
||||
(void)context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -72,10 +72,10 @@ typedef struct {
|
||||
uint8_t selection_index;
|
||||
} periodic_state_t;
|
||||
|
||||
void periodic_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void periodic_face_activate(movement_settings_t *settings, void *context);
|
||||
bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void periodic_face_resign(movement_settings_t *settings, void *context);
|
||||
void periodic_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void periodic_face_activate(void *context);
|
||||
bool periodic_face_loop(movement_event_t event, void *context);
|
||||
void periodic_face_resign(void *context);
|
||||
|
||||
#define periodic_face ((const watch_face_t){ \
|
||||
periodic_face_setup, \
|
||||
|
||||
@ -113,7 +113,7 @@ static void _planetary_icon(uint8_t planet) {
|
||||
* This function calculates the start and end of the current phase based on a given geographic location.
|
||||
* It also calculates the start of the next following phase.
|
||||
*/
|
||||
static void _planetary_solar_phases(movement_settings_t *settings, planetary_hours_state_t *state) {
|
||||
static void _planetary_solar_phases(planetary_hours_state_t *state) {
|
||||
uint8_t phase, h;
|
||||
double sunrise, sunset;
|
||||
double hour_duration, next_hour_duration;
|
||||
@ -222,7 +222,7 @@ static void _planetary_solar_phases(movement_settings_t *settings, planetary_hou
|
||||
* This function calculates the current planetary hour and divides it up into relative minutes and seconds.
|
||||
* It also calculates the current planetary ruler of the hour and of the day.
|
||||
*/
|
||||
static void _planetary_hours(movement_settings_t *settings, planetary_hours_state_t *state) {
|
||||
static void _planetary_hours(planetary_hours_state_t *state) {
|
||||
char buf[14];
|
||||
char ruler[3];
|
||||
uint8_t weekday, planet, planetary_hour;
|
||||
@ -249,7 +249,7 @@ static void _planetary_hours(movement_settings_t *settings, planetary_hours_stat
|
||||
|
||||
// when current phase ends calculate the next phase
|
||||
if ( watch_utility_date_time_to_unix_time(utc_now, 0) >= state->phase_end ) {
|
||||
_planetary_solar_phases(settings, state);
|
||||
_planetary_solar_phases(state);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -334,17 +334,15 @@ static void _planetary_hours(movement_settings_t *settings, planetary_hours_stat
|
||||
|
||||
// PUBLIC WATCH FACE FUNCTIONS ////////////////////////////////////////////////
|
||||
|
||||
void planetary_hours_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void planetary_hours_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
(void) settings;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(planetary_hours_state_t));
|
||||
memset(*context_ptr, 0, sizeof(planetary_hours_state_t));
|
||||
}
|
||||
}
|
||||
|
||||
void planetary_hours_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void planetary_hours_face_activate(void *context) {
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
|
||||
#if __EMSCRIPTEN__
|
||||
@ -359,11 +357,11 @@ void planetary_hours_face_activate(movement_settings_t *settings, void *context)
|
||||
#endif
|
||||
|
||||
planetary_hours_state_t *state = (planetary_hours_state_t *)context;
|
||||
_planetary_solar_phases(settings, state);
|
||||
_planetary_solar_phases(state);
|
||||
|
||||
}
|
||||
|
||||
bool planetary_hours_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool planetary_hours_face_loop(movement_event_t event, void *context) {
|
||||
planetary_hours_state_t *state = (planetary_hours_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -371,32 +369,31 @@ bool planetary_hours_face_loop(movement_event_t event, movement_settings_t *sett
|
||||
// Show your initial UI here.
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||
_planetary_hours(settings, state);
|
||||
_planetary_hours(state);
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
state->ruler = (state->ruler + 1) % 3;
|
||||
_planetary_hours(settings, state);
|
||||
_planetary_hours(state);
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
state->skip_to_current = true;
|
||||
_planetary_hours(settings, state);
|
||||
_planetary_hours(state);
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
state->hour++;
|
||||
_planetary_hours(settings, state);
|
||||
_planetary_hours(state);
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
state->hour--;
|
||||
_planetary_hours(settings, state);
|
||||
_planetary_hours(state);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void planetary_hours_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void planetary_hours_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@ -92,10 +92,10 @@ typedef struct {
|
||||
sunrise_sunset_state_t sunstate;
|
||||
} planetary_hours_state_t;
|
||||
|
||||
void planetary_hours_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void planetary_hours_face_activate(movement_settings_t *settings, void *context);
|
||||
bool planetary_hours_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void planetary_hours_face_resign(movement_settings_t *settings, void *context);
|
||||
void planetary_hours_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void planetary_hours_face_activate(void *context);
|
||||
bool planetary_hours_face_loop(movement_event_t event, void *context);
|
||||
void planetary_hours_face_resign(void *context);
|
||||
|
||||
#define planetary_hours_face ((const watch_face_t){ \
|
||||
planetary_hours_face_setup, \
|
||||
|
||||
@ -112,7 +112,7 @@ static void _planetary_icon(uint8_t planet) {
|
||||
/** @details solar phase can be a day phase between sunrise and sunset or an alternating night phase.
|
||||
* This function calculates the start and end of the current phase based on a given geographic location.
|
||||
*/
|
||||
static void _planetary_solar_phase(movement_settings_t *settings, planetary_time_state_t *state) {
|
||||
static void _planetary_solar_phase(planetary_time_state_t *state) {
|
||||
uint8_t phase;
|
||||
double sunrise, sunset;
|
||||
uint32_t now_epoch, sunrise_epoch, sunset_epoch, midnight_epoch;
|
||||
@ -200,7 +200,7 @@ static void _planetary_solar_phase(movement_settings_t *settings, planetary_time
|
||||
* This function calculates the current planetary hour and divides it up into relative minutes and seconds.
|
||||
* It also calculates the current planetary ruler of the hour and of the day.
|
||||
*/
|
||||
static void _planetary_time(movement_event_t event, movement_settings_t *settings, planetary_time_state_t *state) {
|
||||
static void _planetary_time(movement_event_t event, planetary_time_state_t *state) {
|
||||
char buf[14];
|
||||
char ruler[3];
|
||||
double night_hour_count = 0.0;
|
||||
@ -214,7 +214,7 @@ static void _planetary_time(movement_event_t event, movement_settings_t *setting
|
||||
|
||||
// when current phase ends calculate the next phase
|
||||
if ( watch_utility_date_time_to_unix_time(state->scratch, 0) >= state->phase_end ) {
|
||||
_planetary_solar_phase(settings, state);
|
||||
_planetary_solar_phase(state);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -270,17 +270,15 @@ static void _planetary_time(movement_event_t event, movement_settings_t *setting
|
||||
|
||||
// PUBLIC WATCH FACE FUNCTIONS ////////////////////////////////////////////////
|
||||
|
||||
void planetary_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
void planetary_time_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
(void) settings;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(planetary_time_state_t));
|
||||
memset(*context_ptr, 0, sizeof(planetary_time_state_t));
|
||||
}
|
||||
}
|
||||
|
||||
void planetary_time_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void planetary_time_face_activate(void *context) {
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
|
||||
#if __EMSCRIPTEN__
|
||||
@ -297,21 +295,21 @@ void planetary_time_face_activate(movement_settings_t *settings, void *context)
|
||||
planetary_time_state_t *state = (planetary_time_state_t *)context;
|
||||
|
||||
// calculate phase
|
||||
_planetary_solar_phase(settings, state);
|
||||
_planetary_solar_phase(state);
|
||||
}
|
||||
|
||||
bool planetary_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool planetary_time_face_loop(movement_event_t event, void *context) {
|
||||
planetary_time_state_t *state = (planetary_time_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
_planetary_time(event, settings, state);
|
||||
_planetary_time(event, state);
|
||||
if ( state->freq > 1 )
|
||||
// for hours with shorter seconds let's increase the tick to not skip seconds in the display
|
||||
movement_request_tick_frequency( 8 );
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
_planetary_time(event, settings, state);
|
||||
_planetary_time(event, state);
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
state->ruler = (state->ruler + 1) % 3;
|
||||
@ -324,14 +322,13 @@ bool planetary_time_face_loop(movement_event_t event, movement_settings_t *setti
|
||||
watch_start_tick_animation(500);
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void planetary_time_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void planetary_time_face_resign(void *context) {
|
||||
(void) context;
|
||||
movement_request_tick_frequency( 1 );
|
||||
}
|
||||
|
||||
@ -93,10 +93,10 @@ typedef struct {
|
||||
watch_date_time scratch;
|
||||
} planetary_time_state_t;
|
||||
|
||||
void planetary_time_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void planetary_time_face_activate(movement_settings_t *settings, void *context);
|
||||
bool planetary_time_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void planetary_time_face_resign(movement_settings_t *settings, void *context);
|
||||
void planetary_time_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void planetary_time_face_activate(void *context);
|
||||
bool planetary_time_face_loop(movement_event_t event, void *context);
|
||||
void planetary_time_face_resign(void *context);
|
||||
|
||||
#define planetary_time_face ((const watch_face_t){ \
|
||||
planetary_time_face_setup, \
|
||||
|
||||
@ -104,8 +104,7 @@ static void display_dice_roll_animation(probability_state_t *state) {
|
||||
// ---------------------------
|
||||
// Standard watch face methods
|
||||
// ---------------------------
|
||||
void probability_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void probability_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(probability_state_t));
|
||||
@ -117,8 +116,7 @@ void probability_face_setup(movement_settings_t *settings, uint8_t watch_face_in
|
||||
#endif
|
||||
}
|
||||
|
||||
void probability_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void probability_face_activate(void *context) {
|
||||
probability_state_t *state = (probability_state_t *)context;
|
||||
|
||||
state->dice_sides = DEFAULT_DICE_SIDES;
|
||||
@ -126,8 +124,7 @@ void probability_face_activate(movement_settings_t *settings, void *context) {
|
||||
watch_display_string("PR", 0);
|
||||
}
|
||||
|
||||
bool probability_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool probability_face_loop(movement_event_t event, void *context) {
|
||||
probability_state_t *state = (probability_state_t *)context;
|
||||
|
||||
if (state->is_rolling && event.event_type != EVENT_TICK) {
|
||||
@ -167,14 +164,13 @@ bool probability_face_loop(movement_event_t event, movement_settings_t *settings
|
||||
watch_display_string("SLEEP ", 4);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void probability_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void probability_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -46,10 +46,10 @@ typedef struct {
|
||||
bool is_rolling;
|
||||
} probability_state_t;
|
||||
|
||||
void probability_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void probability_face_activate(movement_settings_t *settings, void *context);
|
||||
bool probability_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void probability_face_resign(movement_settings_t *settings, void *context);
|
||||
void probability_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void probability_face_activate(void *context);
|
||||
bool probability_face_loop(movement_event_t event, void *context);
|
||||
void probability_face_resign(void *context);
|
||||
|
||||
#define probability_face ((const watch_face_t){ \
|
||||
probability_face_setup, \
|
||||
|
||||
@ -134,8 +134,7 @@ static void pulsometer_cycle_calibration(pulsometer_state_t *pulsometer, int8_t
|
||||
pulsometer_display_calibration(pulsometer);
|
||||
}
|
||||
|
||||
void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void pulsometer_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -149,8 +148,7 @@ void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_ind
|
||||
}
|
||||
}
|
||||
|
||||
void pulsometer_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void pulsometer_face_activate(void *context) {
|
||||
|
||||
pulsometer_state_t *pulsometer = context;
|
||||
|
||||
@ -161,8 +159,7 @@ void pulsometer_face_activate(movement_settings_t *settings, void *context) {
|
||||
pulsometer_display_measurement(pulsometer);
|
||||
}
|
||||
|
||||
bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool pulsometer_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
pulsometer_state_t *pulsometer = (pulsometer_state_t *) context;
|
||||
|
||||
@ -190,14 +187,13 @@ bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pulsometer_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void pulsometer_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -71,10 +71,10 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void pulsometer_face_activate(movement_settings_t *settings, void *context);
|
||||
bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void pulsometer_face_resign(movement_settings_t *settings, void *context);
|
||||
void pulsometer_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void pulsometer_face_activate(void *context);
|
||||
bool pulsometer_face_loop(movement_event_t event, void *context);
|
||||
void pulsometer_face_resign(void *context);
|
||||
|
||||
#define pulsometer_face ((const watch_face_t){ \
|
||||
pulsometer_face_setup, \
|
||||
|
||||
@ -50,8 +50,7 @@ static void _get_entropy(randonaut_state_t *state);
|
||||
|
||||
// MOVEMENT WATCH FACE FUNCTIONS //////////////////////////////////////////////
|
||||
|
||||
void randonaut_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void randonaut_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(randonaut_state_t));
|
||||
@ -61,8 +60,7 @@ void randonaut_face_setup(movement_settings_t *settings, uint8_t watch_face_inde
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void randonaut_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void randonaut_face_activate(void *context) {
|
||||
randonaut_state_t *state = (randonaut_state_t *)context;
|
||||
_get_location_from_file(state);
|
||||
state->face.mode = 0;
|
||||
@ -72,7 +70,7 @@ void randonaut_face_activate(movement_settings_t *settings, void *context) {
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
}
|
||||
|
||||
bool randonaut_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool randonaut_face_loop(movement_event_t event, void *context) {
|
||||
randonaut_state_t *state = (randonaut_state_t *)context;
|
||||
|
||||
switch (event.event_type) {
|
||||
@ -178,7 +176,7 @@ bool randonaut_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
// * 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 movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
_randonaut_face_display(state);
|
||||
@ -192,8 +190,7 @@ bool randonaut_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
return true;
|
||||
}
|
||||
|
||||
void randonaut_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void randonaut_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -96,10 +96,10 @@ typedef struct {
|
||||
char scratchpad[10];
|
||||
} randonaut_state_t;
|
||||
|
||||
void randonaut_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void randonaut_face_activate(movement_settings_t *settings, void *context);
|
||||
bool randonaut_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void randonaut_face_resign(movement_settings_t *settings, void *context);
|
||||
void randonaut_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void randonaut_face_activate(void *context);
|
||||
bool randonaut_face_loop(movement_event_t event, void *context);
|
||||
void randonaut_face_resign(void *context);
|
||||
|
||||
#define randonaut_face ((const watch_face_t){ \
|
||||
randonaut_face_setup, \
|
||||
|
||||
@ -30,19 +30,16 @@
|
||||
#define RATEMETER_FACE_FREQUENCY_FACTOR (4ul) // refresh rate will be 2 to this power Hz (0 for 1 Hz, 2 for 4 Hz, etc.)
|
||||
#define RATEMETER_FACE_FREQUENCY (1 << RATEMETER_FACE_FREQUENCY_FACTOR)
|
||||
|
||||
void ratemeter_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void ratemeter_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) *context_ptr = malloc(sizeof(ratemeter_state_t));
|
||||
}
|
||||
|
||||
void ratemeter_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void ratemeter_face_activate(void *context) {
|
||||
memset(context, 0, sizeof(ratemeter_state_t));
|
||||
}
|
||||
|
||||
bool ratemeter_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool ratemeter_face_loop(movement_event_t event, void *context) {
|
||||
ratemeter_state_t *ratemeter_state = (ratemeter_state_t *)context;
|
||||
char buf[14];
|
||||
switch (event.event_type) {
|
||||
@ -79,14 +76,13 @@ bool ratemeter_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
movement_move_to_face(0);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ratemeter_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void ratemeter_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@ -42,10 +42,10 @@ typedef struct {
|
||||
int16_t ticks;
|
||||
} ratemeter_state_t;
|
||||
|
||||
void ratemeter_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void ratemeter_face_activate(movement_settings_t *settings, void *context);
|
||||
bool ratemeter_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void ratemeter_face_resign(movement_settings_t *settings, void *context);
|
||||
void ratemeter_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void ratemeter_face_activate(void *context);
|
||||
bool ratemeter_face_loop(movement_event_t event, void *context);
|
||||
void ratemeter_face_resign(void *context);
|
||||
|
||||
#define ratemeter_face ((const watch_face_t){ \
|
||||
ratemeter_face_setup, \
|
||||
|
||||
@ -30,8 +30,7 @@
|
||||
|
||||
static void show_fn(calculator_state_t *state, uint8_t subsecond);
|
||||
|
||||
void rpn_calculator_alt_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void rpn_calculator_alt_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -125,8 +124,7 @@ static void show_number(double num) {
|
||||
#define PUSH(x) (s->stack[++s->stack_size - 1] = x)
|
||||
#define POP() (s->stack[s->stack_size-- - 1])
|
||||
|
||||
void rpn_calculator_alt_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void rpn_calculator_alt_face_activate(void *context) {
|
||||
calculator_state_t *s = (calculator_state_t *)context;
|
||||
s->min = s->max = NAN;
|
||||
}
|
||||
@ -344,9 +342,8 @@ static void show_stack_top(calculator_state_t *s) {
|
||||
}
|
||||
}
|
||||
|
||||
bool rpn_calculator_alt_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool rpn_calculator_alt_face_loop(movement_event_t event, void *context) {
|
||||
calculator_state_t *s = (calculator_state_t *)context;
|
||||
(void) settings;
|
||||
|
||||
int proposed_stack_size;
|
||||
|
||||
@ -410,7 +407,7 @@ bool rpn_calculator_alt_face_loop(movement_event_t event, movement_settings_t *s
|
||||
case EVENT_LOW_ENERGY_UPDATE:
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -419,8 +416,7 @@ bool rpn_calculator_alt_face_loop(movement_event_t event, movement_settings_t *s
|
||||
return true;
|
||||
}
|
||||
|
||||
void rpn_calculator_alt_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void rpn_calculator_alt_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -79,10 +79,10 @@ typedef struct {
|
||||
enum calculator_mode mode;
|
||||
} calculator_state_t;
|
||||
|
||||
void rpn_calculator_alt_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void rpn_calculator_alt_face_activate(movement_settings_t *settings, void *context);
|
||||
bool rpn_calculator_alt_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void rpn_calculator_alt_face_resign(movement_settings_t *settings, void *context);
|
||||
void rpn_calculator_alt_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void rpn_calculator_alt_face_activate(void *context);
|
||||
bool rpn_calculator_alt_face_loop(movement_event_t event, void *context);
|
||||
void rpn_calculator_alt_face_resign(void *context);
|
||||
|
||||
#define rpn_calculator_alt_face ((const watch_face_t){ \
|
||||
rpn_calculator_alt_face_setup, \
|
||||
|
||||
@ -232,8 +232,7 @@ static void draw(rpn_calculator_state_t *state, uint8_t subsecond) {
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
void rpn_calculator_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void rpn_calculator_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(rpn_calculator_state_t));
|
||||
@ -245,15 +244,13 @@ void rpn_calculator_face_setup(movement_settings_t *settings, uint8_t watch_face
|
||||
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||
}
|
||||
|
||||
void rpn_calculator_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void rpn_calculator_face_activate(void *context) {
|
||||
(void) context;
|
||||
|
||||
// Handle any tasks related to your watch face coming on screen.
|
||||
}
|
||||
|
||||
bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool rpn_calculator_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
rpn_calculator_state_t *state = (rpn_calculator_state_t *)context;
|
||||
|
||||
@ -333,7 +330,7 @@ bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *setti
|
||||
case EVENT_LOW_ENERGY_UPDATE:
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -342,8 +339,7 @@ bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *setti
|
||||
return true;
|
||||
}
|
||||
|
||||
void rpn_calculator_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void rpn_calculator_face_resign(void *context) {
|
||||
(void) context;
|
||||
|
||||
// handle any cleanup before your watch face goes off-screen.
|
||||
|
||||
@ -64,10 +64,10 @@ typedef struct {
|
||||
uint8_t selection;
|
||||
} rpn_calculator_state_t;
|
||||
|
||||
void rpn_calculator_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void rpn_calculator_face_activate(movement_settings_t *settings, void *context);
|
||||
bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void rpn_calculator_face_resign(movement_settings_t *settings, void *context);
|
||||
void rpn_calculator_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void rpn_calculator_face_activate(void *context);
|
||||
bool rpn_calculator_face_loop(movement_event_t event, void *context);
|
||||
void rpn_calculator_face_resign(void *context);
|
||||
|
||||
#define rpn_calculator_face ((const watch_face_t){ \
|
||||
rpn_calculator_face_setup, \
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#define sl_SELECTIONS 6
|
||||
#define DEFAULT_MINUTES { 5,4,1,0,0,0 }
|
||||
|
||||
static inline int32_t get_tz_offset(movement_settings_t *settings) {
|
||||
static inline int32_t get_tz_offset() {
|
||||
return movement_get_current_timezone_offset();
|
||||
}
|
||||
|
||||
@ -62,8 +62,7 @@ static void counting(sailing_state_t *state) {
|
||||
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||
}
|
||||
|
||||
static void draw(sailing_state_t *state, uint8_t subsecond, movement_settings_t *settings) {
|
||||
(void) settings;
|
||||
static void draw(sailing_state_t *state, uint8_t subsecond) {
|
||||
|
||||
char tmp[24];
|
||||
char buf[16];
|
||||
@ -152,7 +151,7 @@ static void draw(sailing_state_t *state, uint8_t subsecond, movement_settings_t
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
static void ring(sailing_state_t *state, movement_settings_t *settings) {
|
||||
static void ring(sailing_state_t *state) {
|
||||
// if ring is called in background (while on another face), a button press can interrupt and cancel the execution.
|
||||
// To reduce the probability of cancelling all future alarms, the new alarm is set as soon as possible after calling ring.
|
||||
movement_cancel_background_task();
|
||||
@ -185,7 +184,7 @@ static void ring(sailing_state_t *state, movement_settings_t *settings) {
|
||||
beepflag++;
|
||||
}
|
||||
|
||||
static void start(sailing_state_t *state, movement_settings_t *settings) {//gets called by starting / switching to next signal
|
||||
static void start(sailing_state_t *state) {//gets called by starting / switching to next signal
|
||||
while (beepseconds[beepflag] < state->minutes[state->index]*60) {
|
||||
state->index++;
|
||||
}
|
||||
@ -234,8 +233,7 @@ static void settings_increment(sailing_state_t *state) {
|
||||
return;
|
||||
}
|
||||
|
||||
void sailing_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void sailing_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@ -248,8 +246,7 @@ void sailing_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
||||
}
|
||||
}
|
||||
|
||||
void sailing_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void sailing_face_activate(void *context) {
|
||||
sailing_state_t *state = (sailing_state_t *)context;
|
||||
if(state->mode == sl_running) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
@ -281,8 +278,7 @@ void sailing_face_activate(movement_settings_t *settings, void *context) {
|
||||
}
|
||||
|
||||
|
||||
bool sailing_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool sailing_face_loop(movement_event_t event, void *context) {
|
||||
sailing_state_t *state = (sailing_state_t *)context;
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
@ -397,15 +393,14 @@ bool sailing_face_loop(movement_event_t event, movement_settings_t *settings, vo
|
||||
// don't light up every time light is hit
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void sailing_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void sailing_face_resign(void *context) {
|
||||
sailing_state_t *state = (sailing_state_t *)context;
|
||||
if (state->mode == sl_setting) {
|
||||
state->selection = 0;
|
||||
|
||||
@ -81,10 +81,10 @@ typedef struct {
|
||||
} sailing_state_t;
|
||||
|
||||
|
||||
void sailing_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void sailing_face_activate(movement_settings_t *settings, void *context);
|
||||
bool sailing_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void sailing_face_resign(movement_settings_t *settings, void *context);
|
||||
void sailing_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void sailing_face_activate(void *context);
|
||||
bool sailing_face_loop(movement_event_t event, void *context);
|
||||
void sailing_face_resign(void *context);
|
||||
|
||||
#define sailing_face ((const watch_face_t){ \
|
||||
sailing_face_setup, \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user