]> git.earman.xyz Git - sensor-watch.git/commitdiff
add demo watch face
authorJoey Castillo <joeycastillo@utexas.edu>
Fri, 10 Dec 2021 16:33:07 +0000 (11:33 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Fri, 10 Dec 2021 16:33:07 +0000 (11:33 -0500)
movement/make/Makefile
movement/movement_config.h
movement/watch_faces/demos/demo_face.c [new file with mode: 0644]
movement/watch_faces/demos/demo_face.h [new file with mode: 0644]

index 7a3e85ecccf90b928ff1f5f23dfe8a496f1e37b8..b7a0e6e2276d7bdd6c352f10dcde3d3665cd1719 100755 (executable)
@@ -39,6 +39,7 @@ SRCS += \
   ../watch_faces/demos/character_set_face.c \
   ../watch_faces/demos/voltage_face.c \
   ../watch_faces/demos/lis2dh_logging_face.c \
+  ../watch_faces/demos/demo_face.c \
   ../watch_faces/complications/beats_face.c \
   ../watch_faces/complications/day_one_face.c \
   ../watch_faces/complications/stopwatch_face.c \
index 2ef43ef024f03701c76c88817f29aa95f0a3edc2..6aeb0b83f2249343f414ab60008fc8b5a66018d7 100644 (file)
@@ -15,6 +15,7 @@
 #include "stopwatch_face.h"
 #include "totp_face.h"
 #include "lis2dh_logging_face.h"
+#include "demo_face.h"
 
 const watch_face_t watch_faces[] = {
     simple_clock_face,
diff --git a/movement/watch_faces/demos/demo_face.c b/movement/watch_faces/demos/demo_face.c
new file mode 100644 (file)
index 0000000..8225676
--- /dev/null
@@ -0,0 +1,91 @@
+#include <stdlib.h>
+#include <string.h>
+#include "demo_face.h"
+#include "watch.h"
+
+typedef enum {
+    DEMO_FACE_HELLO = 0,
+    DEMO_FACE_TIME,
+    DEMO_FACE_WORLD_TIME,
+    DEMO_FACE_BEATS,
+    DEMO_FACE_TEMP_F,
+    DEMO_FACE_TEMP_C,
+    DEMO_FACE_BATTERY_VOLTAGE,
+    DEMO_FACE_NUM_FACES
+} demo_face_index_t;
+
+void demo_face_setup(movement_settings_t *settings, void ** context_ptr) {
+    (void) settings;
+    if (*context_ptr == NULL) {
+        *context_ptr = malloc(sizeof(demo_face_index_t));
+        memset(*context_ptr, 0, sizeof(demo_face_index_t));
+    }
+}
+
+void demo_face_activate(movement_settings_t *settings, void *context) {
+    (void) settings;
+    (void) context;
+    movement_request_tick_frequency(0);
+    // ensure the watch never enters low energy mode
+    settings->bit.le_interval = 0;
+}
+
+bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
+    (void) settings;
+    demo_face_index_t *screen = (demo_face_index_t *)context;
+    switch (event.event_type) {
+        case EVENT_MODE_BUTTON_UP:
+            movement_move_to_next_face();
+            break;
+        case EVENT_LIGHT_BUTTON_DOWN:
+            movement_illuminate_led();
+            break;
+        case EVENT_ALARM_BUTTON_UP:
+            *screen = ((*screen) + 1) % DEMO_FACE_NUM_FACES;
+            // fall through
+        case EVENT_ACTIVATE:
+            switch (*screen) {
+                case DEMO_FACE_HELLO:
+                    watch_display_string("    Hello ", 0);
+                    watch_clear_colon();
+                    break;
+                case DEMO_FACE_TIME:
+                    watch_display_string("TH 6101036", 0);
+                    watch_set_colon();
+                    break;
+                case DEMO_FACE_WORLD_TIME:
+                    watch_display_string("MT 6 81036", 0);
+                    break;
+                case DEMO_FACE_BEATS:
+                    watch_display_string("bt   64125", 0);
+                    watch_clear_colon();
+                    break;
+                case DEMO_FACE_TEMP_F:
+                    watch_display_string("TE  72.1#F", 0);
+                    break;
+                case DEMO_FACE_TEMP_C:
+                    watch_display_string("TE  22.3#C", 0);
+                    break;
+                case DEMO_FACE_BATTERY_VOLTAGE:
+                    watch_display_string("BA  2.97 V", 0);
+                    break;
+                case DEMO_FACE_NUM_FACES:
+                    // we won't get here, but silence the warning
+                    break;
+            }
+            break;
+        case EVENT_TIMEOUT:
+            // ignore timeout
+            break;
+        default:
+            break;
+    }
+
+    return true;
+}
+
+void demo_face_resign(movement_settings_t *settings, void *context) {
+    (void) settings;
+    (void) context;
+    movement_request_tick_frequency(1);
+}
diff --git a/movement/watch_faces/demos/demo_face.h b/movement/watch_faces/demos/demo_face.h
new file mode 100644 (file)
index 0000000..b9e36ff
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef DEMO_FACE_H_
+#define DEMO_FACE_H_
+
+#include "movement.h"
+
+void demo_face_setup(movement_settings_t *settings, void ** context_ptr);
+void demo_face_activate(movement_settings_t *settings, void *context);
+bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
+void demo_face_resign(movement_settings_t *settings, void *context);
+
+static const watch_face_t demo_face = {
+    demo_face_setup,
+    demo_face_activate,
+    demo_face_loop,
+    demo_face_resign,
+    NULL
+};
+
+#endif // DEMO_FACE_H_
\ No newline at end of file