]> git.earman.xyz Git - sensor-watch.git/commitdiff
Handle visibility for tomato watchface
authorPietro F. Maggi <pfm@pietromaggi.com>
Sun, 7 Jan 2024 11:40:42 +0000 (12:40 +0100)
committerPietro F. Maggi <pfm@pietromaggi.com>
Sun, 7 Jan 2024 11:43:18 +0000 (12:43 +0100)
(cherry picked from commit 547e8248ba3538693ee8c587a92ffece7b40d1a2)

movement/watch_faces/complication/tomato_face.c
movement/watch_faces/complication/tomato_face.h

index 698301e1c076ec6a5a6e0d95c0075fce42bc38da..3d46ba94c7035dfbc5569675c2fae4ca391e39b1 100644 (file)
@@ -84,8 +84,10 @@ static void tomato_draw(tomato_state_t *state) {
             sec = 0;
             break;
     }
-    sprintf(buf, "TO %c%2d%02d%2d", kind, min, sec, state->done_count);
-    watch_display_string(buf, 0);
+    if (state->visible) {
+        sprintf(buf, "TO %c%2d%02d%2d", kind, min, sec, state->done_count);
+        watch_display_string(buf, 0);
+    }
 }
 
 static void tomato_reset(tomato_state_t *state) {
@@ -116,6 +118,7 @@ void tomato_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
         state->mode=tomato_ready;
         state->kind= tomato_focus;
         state->done_count = 0;
+        state->visible = true;
     }
 }
 
@@ -127,6 +130,7 @@ void tomato_face_activate(movement_settings_t *settings, void *context) {
         watch_set_indicator(WATCH_INDICATOR_BELL);
     }
     watch_set_colon();
+    state->visible = true;
 }
 
 bool tomato_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
@@ -184,6 +188,8 @@ bool tomato_face_loop(movement_event_t event, movement_settings_t *settings, voi
 }
 
 void tomato_face_resign(movement_settings_t *settings, void *context) {
+    tomato_state_t *state = (tomato_state_t *)context;
+    state->visible = false;
     (void) settings;
     (void) context;
 }
index 33a086c6c59a9d2b0e11ae90a25da30555e513d3..25f7db0e5d0e16c0a8903eb031d81ce2b921b28c 100644 (file)
@@ -64,6 +64,7 @@ typedef struct {
     tomato_mode mode;
     tomato_kind kind;
     uint8_t done_count;
+    bool visible;
 } tomato_state_t;
 
 void tomato_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);