]> git.earman.xyz Git - sensor-watch.git/commitdiff
Refactored text display
authorDavid Volovskiy <devolov@gmail.com>
Tue, 19 Aug 2025 10:59:59 +0000 (06:59 -0400)
committerDavid Volovskiy <devolov@gmail.com>
Tue, 19 Aug 2025 10:59:59 +0000 (06:59 -0400)
movement_faces.h
watch-faces.mk
watch-faces/complication/simon_face.c
watch-faces/complication/simon_face.h

index fc43716d9f27621630ddcb169e373afe1214ddd2..d86e72d4e6136536a5e49e89fa6f49f73a6e3b2a 100644 (file)
@@ -73,4 +73,5 @@
 #include "wareki_face.h"
 #include "deadline_face.h"
 #include "wordle_face.h"
+#include "simon_face.h"
 // New includes go above this line.
index 22e262cffe6dd963ff106d23b97dafbb905c3e64..3f1f8946ef7663523ae153cc9af691027509429a 100644 (file)
@@ -48,4 +48,5 @@ SRCS += \
   ./watch-faces/sensor/lis2dw_monitor_face.c \
   ./watch-faces/complication/wareki_face.c \
   ./watch-faces/complication/deadline_face.c \
+  ./watch-faces/complication/simon_face.c \
 # New watch faces go above this line.
index 41bc5c3d629f03465874ef1711f740df87a3b75f..55f484bf204cac91a53c7e79f32f3678beb41e55 100644 (file)
@@ -47,18 +47,19 @@ static inline uint8_t _simon_get_rand_num(uint8_t num_values) {
 }
 
 static void _simon_clear_display(simon_state_t *state) {
-    if (state->playing_state == SIMON_NOT_PLAYING) {
-        watch_display_string("          ", 0);
-    } else {
-        sprintf(_simon_display_buf, "  %2d      ", state->sequence_length);
-        watch_display_string(_simon_display_buf, 0);
+    watch_clear_display();
+    if (state->playing_state != SIMON_NOT_PLAYING) {
+        sprintf(_simon_display_buf, "%2d", state->sequence_length);
+        watch_display_text(WATCH_POSITION_TOP_RIGHT, _simon_display_buf);
     }
 }
 
 static void _simon_not_playing_display(simon_state_t *state) {
     _simon_clear_display(state);
 
-    sprintf(_simon_display_buf, "SI  %d", state->best_score);
+    watch_display_text(WATCH_POSITION_TOP, "SI");
+    sprintf(_simon_display_buf, "%d", state->best_score);
+    watch_display_text(WATCH_POSITION_BOTTOM, _simon_display_buf);
     if (!state->soundOff)
         watch_set_indicator(WATCH_INDICATOR_BELL);
     else
@@ -67,14 +68,13 @@ static void _simon_not_playing_display(simon_state_t *state) {
         watch_set_indicator(WATCH_INDICATOR_SIGNAL);
     else
         watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
-    watch_display_string(_simon_display_buf, 0);
     switch (state->mode)
     {
     case SIMON_MODE_EASY:
-        watch_display_string("E", 9);
+        watch_display_text(WATCH_POSITION_SECONDS, " E");
         break;
     case SIMON_MODE_HARD:
-        watch_display_string("H", 9);
+        watch_display_text(WATCH_POSITION_SECONDS, " H");
         break;
     default:
         break;
@@ -90,24 +90,27 @@ static void _simon_reset(simon_state_t *state) {
 
 
 static void _simon_display_note(SimonNote note, simon_state_t *state) {
-    char *ndtemplate = NULL;
-
+    watch_clear_display();
+    if (note == SIMON_WRONG_NOTE) {
+        watch_display_text(WATCH_POSITION_TOP_LEFT, "OH");
+        watch_display_text(WATCH_POSITION_BOTTOM, "NOOOOO");
+        return;
+    }
+    sprintf(_simon_display_buf, "%2d", state->sequence_length);
+    watch_display_text(WATCH_POSITION_TOP_RIGHT, _simon_display_buf);
     switch (note) {
         case SIMON_LED_NOTE:
-            ndtemplate = "LI%2d      ";
+            watch_display_text(WATCH_POSITION_TOP_LEFT, "LI");
             break;
         case SIMON_ALARM_NOTE:
-            ndtemplate = "  %2d    AL";
+            watch_display_text(WATCH_POSITION_SECONDS, "AL");
             break;
         case SIMON_MODE_NOTE:
-            ndtemplate = "  %2dDE    ";
+            watch_display_text(WATCH_POSITION_HOURS, DE");
+            break;
+        default:
             break;
-        case SIMON_WRONG_NOTE:
-            ndtemplate = "OH  NOOOOO";
     }
-
-    sprintf(_simon_display_buf, ndtemplate, state->sequence_length);
-    watch_display_string(_simon_display_buf, 0);
 }
 
 static void _simon_play_note(SimonNote note, simon_state_t *state, bool skip_rest) {
@@ -220,7 +223,6 @@ void simon_face_setup(uint8_t watch_face_index,
 }
 
 void simon_face_activate(void *context) {
-  (void) settings;
   (void) context;
   simon_state_t *state = (simon_state_t *)context;
   _simon_change_speed(state);
index 63e8389521f23223cc2e1425980a0a295c7ddfe1..a3dd743bc51ad426214cffe31ced498931172a42 100644 (file)
@@ -95,8 +95,8 @@ void simon_face_activate(void *context);
 bool simon_face_loop(movement_event_t event, void *context);
 void simon_face_resign(void *context);
 
-#define simon_face                                                             \
-    ((const watch_face_t){                                                       \
+#define simon_face                                                            \
+    ((const watch_face_t){                                                    \
      simon_face_setup,                                                        \
      simon_face_activate,                                                     \
      simon_face_loop,                                                         \