refactor: watch faces no longer need a pointer to settings!
This commit is contained in:
@@ -29,8 +29,7 @@
|
||||
|
||||
const uint8_t BEAT_REFRESH_FREQUENCY = 8;
|
||||
|
||||
void beats_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void beats_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
(void) context_ptr;
|
||||
if (*context_ptr == NULL) {
|
||||
@@ -38,16 +37,14 @@ void beats_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
|
||||
}
|
||||
}
|
||||
|
||||
void beats_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void beats_face_activate(void *context) {
|
||||
beats_face_state_t *state = (beats_face_state_t *)context;
|
||||
state->next_subsecond_update = 0;
|
||||
state->last_centibeat_displayed = 0;
|
||||
movement_request_tick_frequency(BEAT_REFRESH_FREQUENCY);
|
||||
}
|
||||
|
||||
bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool beats_face_loop(movement_event_t event, void *context) {
|
||||
beats_face_state_t *state = (beats_face_state_t *)context;
|
||||
if (event.event_type == EVENT_TICK && event.subsecond != state->next_subsecond_update) {
|
||||
return true; // math is hard, don't do it if we don't have to.
|
||||
@@ -82,15 +79,14 @@ bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
watch_display_text(WATCH_POSITION_FULL, buf);
|
||||
break;
|
||||
default:
|
||||
movement_default_loop_handler(event, settings);
|
||||
movement_default_loop_handler(event);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void beats_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void beats_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ typedef struct {
|
||||
} beats_face_state_t;
|
||||
|
||||
uint32_t clock2beats(uint32_t hours, uint32_t minutes, uint32_t seconds, uint32_t subseconds, int16_t utc_offset);
|
||||
void beats_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void beats_face_activate(movement_settings_t *settings, void *context);
|
||||
bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void beats_face_resign(movement_settings_t *settings, void *context);
|
||||
void beats_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void beats_face_activate(void *context);
|
||||
bool beats_face_loop(movement_event_t event, void *context);
|
||||
void beats_face_resign(void *context);
|
||||
|
||||
#define beats_face ((const watch_face_t){ \
|
||||
beats_face_setup, \
|
||||
|
||||
@@ -60,7 +60,7 @@ static void clock_indicate(watch_indicator_t indicator, bool on) {
|
||||
}
|
||||
}
|
||||
|
||||
static void clock_indicate_alarm(movement_settings_t *settings) {
|
||||
static void clock_indicate_alarm() {
|
||||
clock_indicate(WATCH_INDICATOR_SIGNAL, movement_alarm_enabled());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ static void clock_indicate_time_signal(clock_state_t *clock) {
|
||||
clock_indicate(WATCH_INDICATOR_BELL, clock->time_signal_enabled);
|
||||
}
|
||||
|
||||
static void clock_indicate_24h(movement_settings_t *settings) {
|
||||
static void clock_indicate_24h() {
|
||||
clock_indicate(WATCH_INDICATOR_24H, !!movement_clock_mode_24h());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ static bool clock_is_pm(watch_date_time date_time) {
|
||||
return date_time.unit.hour >= 12;
|
||||
}
|
||||
|
||||
static void clock_indicate_pm(movement_settings_t *settings, watch_date_time date_time) {
|
||||
static void clock_indicate_pm(watch_date_time date_time) {
|
||||
if (movement_clock_mode_24h()) { return; }
|
||||
clock_indicate(WATCH_INDICATOR_PM, clock_is_pm(date_time));
|
||||
}
|
||||
@@ -166,10 +166,10 @@ static bool clock_display_some(watch_date_time current, watch_date_time previous
|
||||
}
|
||||
}
|
||||
|
||||
static void clock_display_clock(movement_settings_t *settings, clock_state_t *clock, watch_date_time current) {
|
||||
static void clock_display_clock(clock_state_t *clock, watch_date_time current) {
|
||||
if (!clock_display_some(current, clock->date_time.previous)) {
|
||||
if (movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_12H) {
|
||||
clock_indicate_pm(settings, current);
|
||||
clock_indicate_pm(current);
|
||||
current = clock_24h_to_12h(current);
|
||||
}
|
||||
clock_display_all(current, movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_024H);
|
||||
@@ -204,8 +204,7 @@ static void clock_stop_tick_tock_animation(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@@ -216,14 +215,14 @@ void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
|
||||
}
|
||||
}
|
||||
|
||||
void clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
void clock_face_activate(void *context) {
|
||||
clock_state_t *clock = (clock_state_t *) context;
|
||||
|
||||
clock_stop_tick_tock_animation();
|
||||
|
||||
clock_indicate_time_signal(clock);
|
||||
clock_indicate_alarm(settings);
|
||||
clock_indicate_24h(settings);
|
||||
clock_indicate_alarm();
|
||||
clock_indicate_24h();
|
||||
|
||||
watch_set_colon();
|
||||
|
||||
@@ -231,7 +230,7 @@ void clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
clock->date_time.previous.reg = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool clock_face_loop(movement_event_t event, void *context) {
|
||||
clock_state_t *state = (clock_state_t *) context;
|
||||
watch_date_time current;
|
||||
|
||||
@@ -244,7 +243,7 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
case EVENT_ACTIVATE:
|
||||
current = watch_rtc_get_date_time();
|
||||
|
||||
clock_display_clock(settings, state, current);
|
||||
clock_display_clock(state, current);
|
||||
|
||||
clock_check_battery_periodically(state, current);
|
||||
|
||||
@@ -260,19 +259,17 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
|
||||
movement_play_signal();
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool clock_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool clock_face_wants_background_task(void *context) {
|
||||
clock_state_t *state = (clock_state_t *) context;
|
||||
if (!state->time_signal_enabled) return false;
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@
|
||||
|
||||
#include "movement.h"
|
||||
|
||||
void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void clock_face_resign(movement_settings_t *settings, void *context);
|
||||
bool clock_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void clock_face_activate(void *context);
|
||||
bool clock_face_loop(movement_event_t event, void *context);
|
||||
void clock_face_resign(void *context);
|
||||
bool clock_face_wants_background_task(void *context);
|
||||
|
||||
#define clock_face ((const watch_face_t) { \
|
||||
clock_face_setup, \
|
||||
|
||||
@@ -34,8 +34,7 @@ static void _update_alarm_indicator(bool settings_alarm_enabled, simple_clock_st
|
||||
else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
|
||||
void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void simple_clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
|
||||
if (*context_ptr == NULL) {
|
||||
@@ -46,7 +45,7 @@ void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_i
|
||||
}
|
||||
}
|
||||
|
||||
void simple_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
void simple_clock_face_activate(void *context) {
|
||||
simple_clock_state_t *state = (simple_clock_state_t *)context;
|
||||
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
@@ -66,7 +65,7 @@ void simple_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
state->previous_date_time = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool simple_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool simple_clock_face_loop(movement_event_t event, void *context) {
|
||||
simple_clock_state_t *state = (simple_clock_state_t *)context;
|
||||
char buf[11];
|
||||
|
||||
@@ -143,19 +142,17 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
|
||||
movement_play_signal();
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void simple_clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void simple_clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
bool simple_clock_face_wants_background_task(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
bool simple_clock_face_wants_background_task(void *context) {
|
||||
simple_clock_state_t *state = (simple_clock_state_t *)context;
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ typedef struct {
|
||||
bool alarm_enabled;
|
||||
} simple_clock_state_t;
|
||||
|
||||
void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void simple_clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool simple_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void simple_clock_face_resign(movement_settings_t *settings, void *context);
|
||||
bool simple_clock_face_wants_background_task(movement_settings_t *settings, void *context);
|
||||
void simple_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void simple_clock_face_activate(void *context);
|
||||
bool simple_clock_face_loop(movement_event_t event, void *context);
|
||||
void simple_clock_face_resign(void *context);
|
||||
bool simple_clock_face_wants_background_task(void *context);
|
||||
|
||||
#define simple_clock_face ((const watch_face_t){ \
|
||||
simple_clock_face_setup, \
|
||||
|
||||
@@ -35,8 +35,7 @@ void _update_timezone_offset(world_clock_state_t *state) {
|
||||
state->current_offset = movement_get_current_timezone_offset_for_zone(state->settings.bit.timezone_index);
|
||||
}
|
||||
|
||||
void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) settings;
|
||||
void world_clock_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
(void) watch_face_index;
|
||||
if (*context_ptr == NULL) {
|
||||
*context_ptr = malloc(sizeof(world_clock_state_t));
|
||||
@@ -51,8 +50,7 @@ void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_in
|
||||
}
|
||||
}
|
||||
|
||||
void world_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void world_clock_face_activate(void *context) {
|
||||
world_clock_state_t *state = (world_clock_state_t *)context;
|
||||
|
||||
state->current_screen = 0;
|
||||
@@ -61,7 +59,7 @@ void world_clock_face_activate(movement_settings_t *settings, void *context) {
|
||||
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
|
||||
}
|
||||
|
||||
static bool world_clock_face_do_display_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) {
|
||||
static bool world_clock_face_do_display_mode(movement_event_t event, world_clock_state_t *state) {
|
||||
char buf[11];
|
||||
|
||||
uint32_t previous_date_time;
|
||||
@@ -121,13 +119,13 @@ static bool world_clock_face_do_display_mode(movement_event_t event, movement_se
|
||||
state->current_screen = 1;
|
||||
break;
|
||||
default:
|
||||
return movement_default_loop_handler(event, settings);
|
||||
return movement_default_loop_handler(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) {
|
||||
static bool _world_clock_face_do_settings_mode(movement_event_t event, world_clock_state_t *state) {
|
||||
switch (event.event_type) {
|
||||
case EVENT_MODE_BUTTON_UP:
|
||||
if (state->backup_register) watch_store_backup_data(state->settings.reg, state->backup_register);
|
||||
@@ -141,7 +139,7 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_
|
||||
state->current_screen = 0;
|
||||
if (state->backup_register) watch_store_backup_data(state->settings.reg, state->backup_register);
|
||||
event.event_type = EVENT_ACTIVATE;
|
||||
return world_clock_face_do_display_mode(event, settings, state);
|
||||
return world_clock_face_do_display_mode(event, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_DOWN:
|
||||
@@ -198,17 +196,16 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_
|
||||
return true;
|
||||
}
|
||||
|
||||
bool world_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||
bool world_clock_face_loop(movement_event_t event, void *context) {
|
||||
world_clock_state_t *state = (world_clock_state_t *)context;
|
||||
|
||||
if (state->current_screen == 0) {
|
||||
return world_clock_face_do_display_mode(event, settings, state);
|
||||
return world_clock_face_do_display_mode(event, state);
|
||||
} else {
|
||||
return _world_clock_face_do_settings_mode(event, settings, state);
|
||||
return _world_clock_face_do_settings_mode(event, state);
|
||||
}
|
||||
}
|
||||
|
||||
void world_clock_face_resign(movement_settings_t *settings, void *context) {
|
||||
(void) settings;
|
||||
void world_clock_face_resign(void *context) {
|
||||
(void) context;
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ typedef struct {
|
||||
int32_t current_offset;
|
||||
} world_clock_state_t;
|
||||
|
||||
void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||
void world_clock_face_activate(movement_settings_t *settings, void *context);
|
||||
bool world_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||
void world_clock_face_resign(movement_settings_t *settings, void *context);
|
||||
void world_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
void world_clock_face_activate(void *context);
|
||||
bool world_clock_face_loop(movement_event_t event, void *context);
|
||||
void world_clock_face_resign(void *context);
|
||||
|
||||
uint8_t world_clock_face_get_weekday(uint16_t day, uint16_t month, uint16_t year);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user