refactor LED dwell time to function call

This commit is contained in:
joeycastillo 2024-09-29 08:58:28 -04:00
parent 379a795ad3
commit 1c2f1bad5d
4 changed files with 18 additions and 7 deletions

View File

@ -383,6 +383,14 @@ void movement_set_backlight_color(movement_color_t color) {
movement_state.settings.bit.led_blue_color = color.blue; movement_state.settings.bit.led_blue_color = color.blue;
} }
uint8_t movement_get_backlight_dwell(void) {
return movement_state.settings.bit.led_duration;
}
void movement_set_backlight_dwell(uint8_t value) {
movement_state.settings.bit.led_duration = value;
}
bool movement_alarm_enabled(void) { bool movement_alarm_enabled(void) {
return movement_state.settings.bit.alarm_enabled; return movement_state.settings.bit.alarm_enabled;
} }

View File

@ -349,6 +349,9 @@ 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);
uint8_t movement_get_backlight_dwell(void);
void movement_set_backlight_dwell(uint8_t value);
/// TODO: For #SecondMovement: Should we have a counter that watch faces increment when they enable an alarm, and decrement when they disable it? /// TODO: For #SecondMovement: Should we have a counter that watch faces increment when they enable an alarm, and decrement when they disable it?
/// Or should there be a watch face function where watch faces can tell us if they have an alarm enabled? /// Or should there be a watch face function where watch faces can tell us if they have an alarm enabled?
/// Worth considering a better way to handle this. /// Worth considering a better way to handle this.

View File

@ -58,7 +58,7 @@ void demo_face_activate(movement_settings_t *settings, 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
movement_set_low_energy_timeout(0); movement_set_low_energy_timeout(0);
settings->bit.led_duration = 3; movement_set_backlight_dwell(3);
} }
bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {

View File

@ -140,12 +140,12 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
} }
break; break;
case PREFERENCES_PAGE_LED_DURATION: case PREFERENCES_PAGE_LED_DURATION:
if (settings->bit.led_duration == 0) { if (movement_get_backlight_dwell() == 0) {
watch_display_text(WATCH_POSITION_BOTTOM, "instnt"); watch_display_text(WATCH_POSITION_BOTTOM, "instnt");
} else if (settings->bit.led_duration == 0b111) { } else if (movement_get_backlight_dwell() == 0b111) {
watch_display_text(WATCH_POSITION_BOTTOM, "no LEd"); watch_display_text(WATCH_POSITION_BOTTOM, "no LEd");
} else { } else {
sprintf(buf, " %1d SeC", settings->bit.led_duration * 2 - 1); sprintf(buf, " %1d SeC", (movement_get_backlight_dwell() * 2 - 1) % 10);
watch_display_text(WATCH_POSITION_BOTTOM, buf); watch_display_text(WATCH_POSITION_BOTTOM, buf);
} }
break; break;
@ -195,10 +195,10 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
movement_set_low_energy_timeout((movement_get_low_energy_timeout() + 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; movement_set_backlight_dwell(movement_get_backlight_dwell() + 1);
if (settings->bit.led_duration > 3) { if (movement_get_backlight_dwell() > 3) {
// set all bits to disable the LED // set all bits to disable the LED
settings->bit.led_duration = 0b111; movement_set_backlight_dwell(0b111);
} }
break; break;
case PREFERENCES_PAGE_LED_RED: case PREFERENCES_PAGE_LED_RED: