Movement: give watch faces their index at setup time
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user