Initial seemingly stable version of movement using the RTC COUNTER32 mode

This commit is contained in:
Alessandro Genova
2025-07-26 21:40:22 -04:00
parent a1a255cd2a
commit eb9ec8659c
13 changed files with 1335 additions and 514 deletions
+16 -23
View File
@@ -134,6 +134,17 @@ typedef enum {
EVENT_DOUBLE_TAP, // Accelerometer detected a double tap. This event is not yet implemented.
} movement_event_type_t;
// Each different timeout type will use a different index when invoking watch_rtc_register_comp_callback
typedef enum {
LIGHT_BUTTON_TIMEOUT = 0, // Light button longpress timeout
MODE_BUTTON_TIMEOUT, // Mode button longpress timeout
ALARM_BUTTON_TIMEOUT, // Alarm button longpress timeout
LED_TIMEOUT, // LED off timeout
RESIGN_TIMEOUT, // Resign active face timeout
SLEEP_TIMEOUT, // Low-energy begin timeout
MINUTE_TIMEOUT, // Top of the Minute timeout
} movement_timeout_index_t;
typedef struct {
uint8_t event_type;
uint8_t subsecond;
@@ -249,37 +260,16 @@ typedef struct {
int16_t current_face_idx;
int16_t next_face_idx;
bool watch_face_changed;
bool fast_tick_enabled;
int16_t fast_ticks;
// LED stuff
int16_t light_ticks;
// alarm stuff
int16_t alarm_ticks;
bool is_buzzing;
watch_buzzer_note_t alarm_note;
// button tracking for long press
uint16_t light_down_timestamp;
uint16_t mode_down_timestamp;
uint16_t alarm_down_timestamp;
bool light_on;
// background task handling
bool woke_from_alarm_handler;
bool has_scheduled_background_task;
bool needs_wake;
// low energy mode countdown
int32_t le_mode_ticks;
// app resignation countdown (TODO: consolidate with LE countdown?)
int16_t timeout_ticks;
// stuff for subsecond tracking
uint8_t tick_frequency;
uint8_t last_second;
uint8_t subsecond;
uint8_t tick_pern;
// backup register stuff
uint8_t next_available_backup_register;
@@ -324,9 +314,11 @@ void movement_cancel_background_task_for_face(uint8_t watch_face_index);
void movement_request_sleep(void);
void movement_request_wake(void);
void movement_play_note(watch_buzzer_note_t note, uint16_t duration_ms);
void movement_play_signal(void);
void movement_play_alarm(void);
void movement_play_alarm_beeps(uint8_t rounds, watch_buzzer_note_t alarm_note);
void movement_play_sequence(int8_t *note_sequence, uint8_t priority);
uint8_t movement_claim_backup_register(void);
@@ -340,6 +332,7 @@ watch_date_time_t movement_get_utc_date_time(void);
watch_date_time_t movement_get_local_date_time(void);
watch_date_time_t movement_get_date_time_in_zone(uint8_t zone_index);
void movement_set_utc_date_time(watch_date_time_t date_time);
void movement_set_local_date_time(watch_date_time_t date_time);
bool movement_button_should_sound(void);