]> git.earman.xyz Git - sensor-watch.git/commitdiff
movement: long press on MODE always dismisses the active face
authorJoey Castillo <joeycastillo@utexas.edu>
Wed, 19 Jan 2022 19:32:33 +0000 (14:32 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Wed, 19 Jan 2022 19:32:33 +0000 (14:32 -0500)
movement/README.md
movement/movement.c
movement/movement.h

index 4b52bbd469d949b5489843b7449ec0357a2050c1..0e1c3b4006e23272f442b85d7cc5c52028fcce3f 100644 (file)
@@ -57,7 +57,7 @@ In addition to the settings and context, this function receives another paramete
 
 There is also a `subsecond` property on the event that contains the fractional second of the event. If you are using 1 Hz updates, subsecond will always be 0.
 
-You should set up a switch statement that handles, at the very least, the `EVENT_TICK` and `EVENT_MODE_BUTTON_UP` event types. The mode button up event occurs when the user presses the MODE button. **Your loop function SHOULD call the movement_move_to_next_face function in response to this event.** If you have a good reason to override this behavior (e.g. your user interface requires all three buttons), your watch face MUST call the movement_move_to_next_face function in response to the EVENT_MODE_LONG_PRESS event. If you fail to do this, the user will become stuck on your watch face.
+You should set up a switch statement that handles, at the very least, the `EVENT_TICK` and `EVENT_MODE_BUTTON_UP` event types. The mode button up event occurs when the user presses the MODE button. **Your loop function SHOULD call the movement_move_to_next_face function in response to this event.** If you have a very good reason to override this behavior (e.g. your user interface requires all three buttons), you may do so, but the user will have to long-press the Mode button to advance to the next watch face.
 
 ### watch_face_resign
 
index 2fc08d8039bedd3f75823ff3d34be9e836385497..3dc1c060e2db147716d6ef5cbbfc1f9fa234cb41 100644 (file)
@@ -332,6 +332,11 @@ bool app_loop(void) {
     if (event.event_type) {
         event.subsecond = movement_state.subsecond;
         can_sleep = watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
+        // escape hatch: a watch face may not resign on EVENT_MODE_BUTTON_DOWN. In that case, a long press of MODE should let them out.
+        if (event.event_type == EVENT_MODE_LONG_PRESS) {
+            movement_move_to_next_face();
+            can_sleep = false;
+        }
         event.event_type = EVENT_NONE;
     }
 
index e327bbdde317d89b77eee0577d3e06f93d50a842..8949d0264bcff1bf6eec039daab7e1a13d7f4a55 100644 (file)
@@ -112,7 +112,7 @@ typedef enum {
     EVENT_LIGHT_LONG_PRESS,     // The light button was held for >2 seconds, and released.
     EVENT_MODE_BUTTON_DOWN,     // The mode button has been pressed, but not yet released.
     EVENT_MODE_BUTTON_UP,       // The mode button was pressed and released.
-    EVENT_MODE_LONG_PRESS,      // The mode button was held for >2 seconds, and released.
+    EVENT_MODE_LONG_PRESS,      // The mode button was held for >2 seconds, and released. NOTE: your watch face will resign immediately after receiving this event.
     EVENT_ALARM_BUTTON_DOWN,    // The alarm button has been pressed, but not yet released.
     EVENT_ALARM_BUTTON_UP,      // The alarm button was pressed and released.
     EVENT_ALARM_LONG_PRESS,     // The alarm button was held for >2 seconds, and released.