movement: add low battery warning to simple clock
This commit is contained in:
parent
df0c2bfd80
commit
18302bf9c4
@ -68,6 +68,20 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
|
|||||||
previous_date_time = state->previous_date_time;
|
previous_date_time = state->previous_date_time;
|
||||||
state->previous_date_time = date_time.reg;
|
state->previous_date_time = date_time.reg;
|
||||||
|
|
||||||
|
// check the battery voltage once a day...
|
||||||
|
if (date_time.unit.day != state->last_battery_check) {
|
||||||
|
state->last_battery_check = date_time.unit.day;
|
||||||
|
watch_enable_adc();
|
||||||
|
uint16_t voltage = watch_get_vcc_voltage();
|
||||||
|
watch_disable_adc();
|
||||||
|
// 2.2 volts will happen when the battery has maybe 5-10% remaining?
|
||||||
|
// we can refine this later.
|
||||||
|
state->battery_low = (voltage < 2200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...and set the LAP indicator if low.
|
||||||
|
if (state->battery_low) watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
|
||||||
if (date_time.reg >> 6 == previous_date_time >> 6 && event.event_type != EVENT_LOW_ENERGY_UPDATE) {
|
if (date_time.reg >> 6 == previous_date_time >> 6 && event.event_type != EVENT_LOW_ENERGY_UPDATE) {
|
||||||
// everything before seconds is the same, don't waste cycles setting those segments.
|
// everything before seconds is the same, don't waste cycles setting those segments.
|
||||||
pos = 8;
|
pos = 8;
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t previous_date_time;
|
uint32_t previous_date_time;
|
||||||
|
uint8_t last_battery_check;
|
||||||
uint8_t watch_face_index;
|
uint8_t watch_face_index;
|
||||||
bool signal_enabled;
|
bool signal_enabled;
|
||||||
|
bool battery_low;
|
||||||
} simple_clock_state_t;
|
} 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_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user