Movement: implement auto firing of long press events and introduce long up event. (Also re-implement alarm_enabled and alarm_note)

This commit is contained in:
TheOnePerson
2022-10-23 13:07:32 +02:00
parent f8f0ce479d
commit 1a80003775
2 changed files with 46 additions and 18 deletions

View File

@@ -61,7 +61,8 @@ typedef union {
// altimeter to display feet or meters as easily as it tells a thermometer to display degrees in F or C.
bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode.
bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial.
uint8_t reserved : 7; // room for more preferences if needed.
bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled.
uint8_t reserved : 6; // room for more preferences if needed.
} bit;
uint32_t reg;
} movement_settings_t;
@@ -109,13 +110,16 @@ typedef enum {
EVENT_TIMEOUT, // Your watch face has been inactive for a while. You may want to resign, depending on your watch face's intended use case.
EVENT_LIGHT_BUTTON_DOWN, // The light button has been pressed, but not yet released.
EVENT_LIGHT_BUTTON_UP, // The light button was pressed and released.
EVENT_LIGHT_LONG_PRESS, // The light button was held for >2 seconds, and released.
EVENT_LIGHT_LONG_PRESS, // The light button was held for >2 seconds, but not yet released.
EVENT_LIGHT_LONG_UP, // The light button was held for >2 seconds, and released.
EVENT_MODE_BUTTON_DOWN, // The mode button has been pressed, but not yet released.
EVENT_MODE_BUTTON_UP, // The mode button was pressed and released.
EVENT_MODE_LONG_PRESS, // The mode button was held for >2 seconds, and released. NOTE: your watch face will resign immediately after receiving this event.
EVENT_MODE_LONG_PRESS, // The mode button was held for >2 seconds, but not yet released.
EVENT_MODE_LONG_UP, // The mode button was held for >2 seconds, and released. NOTE: your watch face will resign immediately after receiving this event.
EVENT_ALARM_BUTTON_DOWN, // The alarm button has been pressed, but not yet released.
EVENT_ALARM_BUTTON_UP, // The alarm button was pressed and released.
EVENT_ALARM_LONG_PRESS, // The alarm button was held for >2 seconds, and released.
EVENT_ALARM_LONG_PRESS, // The alarm button was held for >2 seconds, but not yet released.
EVENT_ALARM_LONG_UP, // The alarm button was held for >2 seconds, and released.
} movement_event_type_t;
typedef struct {
@@ -252,11 +256,12 @@ typedef struct {
// alarm stuff
int16_t alarm_ticks;
bool is_buzzing;
BuzzerNote alarm_note;
// button tracking for long press
uint8_t light_down_timestamp;
uint8_t mode_down_timestamp;
uint8_t alarm_down_timestamp;
uint16_t light_down_timestamp;
uint16_t mode_down_timestamp;
uint16_t alarm_down_timestamp;
// background task handling
bool needs_background_tasks_handled;
@@ -300,6 +305,7 @@ void movement_request_wake(void);
void movement_play_signal(void);
void movement_play_alarm(void);
void movement_play_alarm_beeps(uint8_t rounds, BuzzerNote alarm_note);
uint8_t movement_claim_backup_register(void);