Movement: give watch faces their index at setup time

This commit is contained in:
Joey Castillo
2021-12-20 17:02:17 -06:00
parent 03e107b81a
commit 60fe969191
33 changed files with 49 additions and 34 deletions

View File

@@ -5,8 +5,9 @@
const uint8_t BEAT_REFRESH_FREQUENCY = 8;
void beats_face_setup(movement_settings_t *settings, void ** context_ptr) {
void beats_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
(void) context_ptr;
if (*context_ptr == NULL) {
*context_ptr = malloc(sizeof(beats_face_state_t));

View File

@@ -9,7 +9,7 @@ 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, void ** context_ptr);
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);

View File

@@ -17,8 +17,9 @@ static void _day_one_face_update(day_one_state_t state) {
watch_display_string(buf, 0);
}
void day_one_face_setup(movement_settings_t *settings, void ** context_ptr) {
void day_one_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
if (*context_ptr == NULL) {
*context_ptr = malloc(sizeof(day_one_state_t));
memset(*context_ptr, 0, sizeof(day_one_state_t));

View File

@@ -15,7 +15,7 @@ typedef struct {
bool birthday_changed;
} day_one_state_t;
void day_one_face_setup(movement_settings_t *settings, void ** context_ptr);
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);

View File

@@ -6,8 +6,9 @@
#define PULSOMETER_FACE_FREQUENCY_FACTOR (4ul) // refresh rate will be 2 to this power Hz (0 for 1 Hz, 2 for 4 Hz, etc.)
#define PULSOMETER_FACE_FREQUENCY (1 << PULSOMETER_FACE_FREQUENCY_FACTOR)
void pulsometer_face_setup(movement_settings_t *settings, void ** context_ptr) {
void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
if (*context_ptr == NULL) *context_ptr = malloc(sizeof(pulsometer_state_t));
}

View File

@@ -9,7 +9,7 @@ typedef struct {
int16_t ticks;
} pulsometer_state_t;
void pulsometer_face_setup(movement_settings_t *settings, void ** context_ptr);
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);

View File

@@ -3,8 +3,9 @@
#include "stopwatch_face.h"
#include "watch.h"
void stopwatch_face_setup(movement_settings_t *settings, void ** context_ptr) {
void stopwatch_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
if (*context_ptr == NULL) *context_ptr = malloc(sizeof(stopwatch_state_t));
}

View File

@@ -10,7 +10,7 @@ typedef struct {
uint8_t hours;
} stopwatch_state_t;
void stopwatch_face_setup(movement_settings_t *settings, void ** context_ptr);
void stopwatch_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
void stopwatch_face_activate(movement_settings_t *settings, void *context);
bool stopwatch_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void stopwatch_face_resign(movement_settings_t *settings, void *context);

View File

@@ -17,8 +17,9 @@ static uint8_t hmacKey[] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x21, 0xde, 0xad, 0xbe
static const uint32_t TIMESTEP = 30;
void totp_face_setup(movement_settings_t *settings, void ** context_ptr) {
void totp_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
if (*context_ptr == NULL) *context_ptr = malloc(sizeof(totp_state_t));
TOTP(hmacKey, sizeof(hmacKey), TIMESTEP);
}

View File

@@ -10,7 +10,7 @@ typedef struct {
} totp_state_t;
void totp_face_setup(movement_settings_t *settings, void ** context_ptr);
void totp_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
void totp_face_activate(movement_settings_t *settings, void *context);
bool totp_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void totp_face_resign(movement_settings_t *settings, void *context);