refactor LE and TO intervals to function calls

This commit is contained in:
joeycastillo 2024-09-29 08:53:39 -04:00
parent 4deeb2b9be
commit 379a795ad3
6 changed files with 29 additions and 7 deletions

View File

@ -353,6 +353,22 @@ void movement_set_use_imperial_units(bool value) {
movement_state.settings.bit.use_imperial_units = value; movement_state.settings.bit.use_imperial_units = value;
} }
uint8_t movement_get_fast_tick_timeout(void) {
return movement_state.settings.bit.to_interval;
}
void movement_set_fast_tick_timeout(uint8_t value) {
movement_state.settings.bit.to_interval = value;
}
uint8_t movement_get_low_energy_timeout(void) {
return movement_state.settings.bit.le_interval;
}
void movement_set_low_energy_timeout(uint8_t value) {
movement_state.settings.bit.le_interval = value;
}
movement_color_t movement_backlight_color(void) { movement_color_t movement_backlight_color(void) {
return (movement_color_t) { return (movement_color_t) {
.red = movement_state.settings.bit.led_red_color, .red = movement_state.settings.bit.led_red_color,

View File

@ -340,6 +340,12 @@ void movement_set_clock_mode_24h(movement_clock_mode_t value);
bool movement_use_imperial_units(void); bool movement_use_imperial_units(void);
void movement_set_use_imperial_units(bool value); void movement_set_use_imperial_units(bool value);
uint8_t movement_get_fast_tick_timeout(void);
void movement_set_fast_tick_timeout(uint8_t value);
uint8_t movement_get_low_energy_timeout(void);
void movement_set_low_energy_timeout(uint8_t value);
movement_color_t movement_backlight_color(void); movement_color_t movement_backlight_color(void);
void movement_set_backlight_color(movement_color_t color); void movement_set_backlight_color(movement_color_t color);

View File

@ -57,7 +57,7 @@ void demo_face_activate(movement_settings_t *settings, void *context) {
(void) context; (void) context;
movement_request_tick_frequency(0); movement_request_tick_frequency(0);
// ensure the watch never enters low energy mode // ensure the watch never enters low energy mode
settings->bit.le_interval = 0; movement_set_low_energy_timeout(0);
settings->bit.led_duration = 3; settings->bit.led_duration = 3;
} }

View File

@ -82,7 +82,7 @@ void accel_interrupt_count_face_activate(movement_settings_t *settings, void *co
state->is_setting = false; state->is_setting = false;
// force LE interval to never sleep // force LE interval to never sleep
settings->bit.le_interval = 0; movement_set_low_energy_timeout(0);
} }
bool accel_interrupt_count_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { bool accel_interrupt_count_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {

View File

@ -46,7 +46,7 @@ void thermistor_testing_face_setup(movement_settings_t *settings, uint8_t watch_
(void) context_ptr; (void) context_ptr;
// force one setting: never enter low energy mode. // force one setting: never enter low energy mode.
// I'm using this watch face to test the temperature sensor boards; there's no need for it. // I'm using this watch face to test the temperature sensor boards; there's no need for it.
settings->bit.le_interval = 0; movement_set_low_energy_timeout(0);
} }
void thermistor_testing_face_activate(movement_settings_t *settings, void *context) { void thermistor_testing_face_activate(movement_settings_t *settings, void *context) {

View File

@ -96,7 +96,7 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
} }
break; break;
case PREFERENCES_PAGE_TIMEOUT: case PREFERENCES_PAGE_TIMEOUT:
switch (settings->bit.to_interval) { switch (movement_get_fast_tick_timeout()) {
case 0: case 0:
watch_display_text(WATCH_POSITION_BOTTOM, "60 SeC"); watch_display_text(WATCH_POSITION_BOTTOM, "60 SeC");
break; break;
@ -112,7 +112,7 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
} }
break; break;
case PREFERENCES_PAGE_LOW_ENERGY: case PREFERENCES_PAGE_LOW_ENERGY:
switch (settings->bit.le_interval) { switch (movement_get_low_energy_timeout()) {
case 0: case 0:
watch_display_text(WATCH_POSITION_BOTTOM, " Never"); watch_display_text(WATCH_POSITION_BOTTOM, " Never");
break; break;
@ -189,10 +189,10 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
movement_set_button_should_sound(!movement_button_should_sound()); movement_set_button_should_sound(!movement_button_should_sound());
break; break;
case PREFERENCES_PAGE_TIMEOUT: case PREFERENCES_PAGE_TIMEOUT:
settings->bit.to_interval = settings->bit.to_interval + 1; movement_set_fast_tick_timeout((movement_get_fast_tick_timeout() + 1));
break; break;
case PREFERENCES_PAGE_LOW_ENERGY: case PREFERENCES_PAGE_LOW_ENERGY:
settings->bit.le_interval = settings->bit.le_interval + 1; movement_set_low_energy_timeout((movement_get_low_energy_timeout() + 1));
break; break;
case PREFERENCES_PAGE_LED_DURATION: case PREFERENCES_PAGE_LED_DURATION:
settings->bit.led_duration = settings->bit.led_duration + 1; settings->bit.led_duration = settings->bit.led_duration + 1;