]> git.earman.xyz Git - sensor-watch.git/commitdiff
for testing: add NOSLEEP build option to remove sleep mode entirely
authorJoey Castillo <joeycastillo@utexas.edu>
Thu, 29 May 2025 11:16:50 +0000 (07:16 -0400)
committerJoey Castillo <joeycastillo@utexas.edu>
Thu, 29 May 2025 11:22:04 +0000 (07:22 -0400)
Makefile
movement.c
watch-faces/settings/settings_face.c
watch-faces/settings/settings_face.h

index 3f59c3454b621485c4b49cbd59275b4fd380684b..c4a9c20ec3d069f6553bb25e02524973b317fe43 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,10 @@ else
   endif
 endif
 
+ifdef NOSLEEP
+    DEFINES += -DMOVEMENT_LOW_ENERGY_MODE_FORBIDDEN
+endif
+
 ifdef EMSCRIPTEN
 all: $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).html
 $(BUILD)/$(BIN).html: $(OBJS)
index a767fa35c8ae5ebc79ecb38e08b668a75c91e108..cafa09fcc10867415e92b459a826ee9ad78f990d 100644 (file)
@@ -636,7 +636,11 @@ void app_init(void) {
         movement_state.settings.bit.button_should_sound = MOVEMENT_DEFAULT_BUTTON_SOUND;
         movement_state.settings.bit.button_volume = MOVEMENT_DEFAULT_BUTTON_VOLUME;
         movement_state.settings.bit.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL;
+#ifdef MOVEMENT_LOW_ENERGY_MODE_FORBIDDEN
+        movement_state.settings.bit.le_interval = 0;
+#else
         movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
+#endif
         movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION;
 
         movement_store_settings();
@@ -774,6 +778,8 @@ void app_setup(void) {
     }
 }
 
+#ifndef MOVEMENT_LOW_ENERGY_MODE_FORBIDDEN
+
 static void _sleep_mode_app_loop(void) {
     movement_state.needs_wake = false;
     // as long as le_mode_ticks is -1 (i.e. we are in low energy mode), we wake up here, update the screen, and go right back to sleep.
@@ -791,6 +797,8 @@ static void _sleep_mode_app_loop(void) {
     }
 }
 
+#endif
+
 bool app_loop(void) {
     const watch_face_t *wf = &watch_faces[movement_state.current_face_idx];
     bool woke_up_for_buzzer = false;
@@ -828,6 +836,7 @@ bool app_loop(void) {
     // if we have a scheduled background task, handle that here:
     if (event.event_type == EVENT_TICK && movement_state.has_scheduled_background_task) _movement_handle_scheduled_tasks();
 
+#ifndef MOVEMENT_LOW_ENERGY_MODE_FORBIDDEN
     // if we have timed out of our low energy mode countdown, enter low energy mode.
     if (movement_state.le_mode_ticks == 0) {
         movement_state.le_mode_ticks = -1;
@@ -848,6 +857,7 @@ bool app_loop(void) {
         // need to figure out if there's a better heuristic for determining how we woke up.
         app_setup();
     }
+#endif
 
     // default to being allowed to sleep by the face.
     bool can_sleep = true;
index 7d1b392c754f810671f49404aca879874bbd5a82..0a17985aacdffa9c7e16d4533bfe4da8350e0ebe 100644 (file)
@@ -243,12 +243,15 @@ void settings_face_setup(uint8_t watch_face_index, void ** context_ptr) {
         state->settings_screens[current_setting].display = timeout_setting_display;
         state->settings_screens[current_setting].advance = timeout_setting_advance;
         current_setting++;
+#ifndef MOVEMENT_LOW_ENERGY_MODE_FORBIDDEN
         state->settings_screens[current_setting].display = low_energy_setting_display;
         state->settings_screens[current_setting].advance = low_energy_setting_advance;
         current_setting++;
+#endif
         state->settings_screens[current_setting].display = led_duration_setting_display;
         state->settings_screens[current_setting].advance = led_duration_setting_advance;
         current_setting++;
+        state->led_color_start = current_setting;
 #ifdef WATCH_RED_TCC_CHANNEL
         state->settings_screens[current_setting].display = red_led_setting_display;
         state->settings_screens[current_setting].advance = red_led_setting_advance;
@@ -308,7 +311,7 @@ bool settings_face_loop(movement_event_t event, void *context) {
             return movement_default_loop_handler(event);
     }
 
-    if (state->current_page > 4) {
+    if (state->current_page >= state->led_color_start) {
         movement_color_t color = movement_backlight_color();
         // this bitwise math turns #000 into #000000, #111 into #111111, etc.
         movement_force_led_on(color.red | color.red << 4,
index 7f47ff7c73dabd78693d07650d1529e5241032cf..26a31d5d650c9f8e3f3799fa0775a56caf77c916 100644 (file)
@@ -80,6 +80,7 @@ typedef struct {
 typedef struct {
     int8_t current_page;
     int8_t num_settings;
+    int8_t led_color_start;
     settings_screen_t *settings_screens;
 } settings_state_t;