]> git.earman.xyz Git - sensor-watch.git/commitdiff
refactor LED dwell time to function call
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 12:58:28 +0000 (08:58 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 14:18:11 +0000 (10:18 -0400)
movement.c
movement.h
movement/watch_faces/demo/demo_face.c
watch-faces/settings/preferences_face.c

index 25ae93031713ed20e17862a6966b5935388b6cf3..6d7897eb2ee2866ac621baee9e914e9a765ae84e 100644 (file)
@@ -383,6 +383,14 @@ void movement_set_backlight_color(movement_color_t color) {
     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) {
     return movement_state.settings.bit.alarm_enabled;
 }
index f56f90b927f9bfeed4ed7c7f798857f52f768b5f..2ac312f943df5535d6556c3706e24a881d6fd6dc 100644 (file)
@@ -349,6 +349,9 @@ void movement_set_low_energy_timeout(uint8_t value);
 movement_color_t movement_backlight_color(void);
 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?
 /// 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.
index 2f4d0b931301b1233511826e4ad330662cd799fb..0587a06bd8d5efa4b857cfcd44b5177c18db06ac 100644 (file)
@@ -58,7 +58,7 @@ void demo_face_activate(movement_settings_t *settings, void *context) {
     movement_request_tick_frequency(0);
     // ensure the watch never enters low energy mode
     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) {
index db5bbac5a0970444849300baaec68d8547394663..95da02d44287cc603842f76cfc8ddb02fa51cd20 100644 (file)
@@ -140,12 +140,12 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings
                         }
                         break;
                     case PREFERENCES_PAGE_LED_DURATION:
-                        if (settings->bit.led_duration == 0) {
+                        if (movement_get_backlight_dwell() == 0) {
                             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");
                         } 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);
                         }
                         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));
                     break;
                 case PREFERENCES_PAGE_LED_DURATION:
-                    settings->bit.led_duration = settings->bit.led_duration + 1;
-                    if (settings->bit.led_duration > 3) {
+                    movement_set_backlight_dwell(movement_get_backlight_dwell() + 1);
+                    if (movement_get_backlight_dwell() > 3) {
                         // set all bits to disable the LED
-                        settings->bit.led_duration = 0b111;
+                        movement_set_backlight_dwell(0b111);
                     }
                     break;
                 case PREFERENCES_PAGE_LED_RED: