]> git.earman.xyz Git - sensor-watch.git/commitdiff
Added continue screen
authorDavid Volovskiy <devolov@gmail.com>
Sun, 18 Aug 2024 22:33:38 +0000 (18:33 -0400)
committerDavid Volovskiy <devolov@gmail.com>
Tue, 3 Sep 2024 20:11:54 +0000 (16:11 -0400)
movement/watch_faces/complication/wordle_face.c
movement/watch_faces/complication/wordle_face.h

index 58ad55a0247a676c00f31104789fb927650fa238..363825527292d519384e5cf242d7d882bf095a1c 100644 (file)
@@ -307,6 +307,13 @@ static void display_title(wordle_state_t *state) {
     watch_display_string("WO  WordLE", 0);
 }
 
+static void display_continue(wordle_state_t *state) {
+    char buf[7];
+    state->curr_screen = SCREEN_CONTINUE;
+    sprintf(buf, "Cont %c", state->continuing ? 'y' : 'n');
+    watch_display_string(buf, 4);
+}
+
 static void display_streak(wordle_state_t *state) {
     char buf[12];
     state->curr_screen = SCREEN_STREAK;
@@ -389,7 +396,7 @@ static void display_result(wordle_state_t *state, uint8_t subsecond) {
     watch_display_string(buf, 5);
 }
 
-static bool act_on_btn(wordle_state_t *state) {
+static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
     switch (state->curr_screen)
     {
     case SCREEN_RESULT:
@@ -401,13 +408,15 @@ static bool act_on_btn(wordle_state_t *state) {
 #if USE_DAILY_STREAK
         if (state->prev_day == get_day_unix_time()) {
             display_wait(state);
-            return true;
         }
-#endif
-        if (state->playing)
-            display_playing(state);
+#else
+        if (state->playing) {
+            state->continuing = true;
+            display_continue(state);
+        }
         else
             display_streak(state);
+#endif
         return true;
     case SCREEN_STREAK:
 #if USE_DAILY_STREAK
@@ -424,6 +433,23 @@ static bool act_on_btn(wordle_state_t *state) {
         state->position = get_first_pos(state->word_elements_result);
         display_playing(state);
         return true;
+    case SCREEN_CONTINUE:
+        switch (pin)
+        {
+        case BTN_ALARM:
+            if (state->continuing)
+                display_playing(state);
+            else {
+                reset_board(state);
+                display_streak(state);
+            }
+            break;
+        case BTN_LIGHT:
+            state->continuing = !state->continuing;
+            display_continue(state);
+            break;
+        }
+        return true;
 #if USE_DAILY_STREAK
     case SCREEN_WAIT:
         display_title(state);
@@ -514,7 +540,7 @@ void wordle_face_activate(movement_settings_t *settings, void *context) {
     if (state->curr_day != now) state->playing = false;
 #endif
     state->using_random_guess = false;
-    if (state->playing && state->curr_screen >= SCREEN_WIN) {
+    if (state->playing && state->curr_screen >= SCREEN_RESULT) {
         reset_incorrect_elements(state);
         state->position = get_first_pos(state->word_elements_result); 
     }
@@ -550,7 +576,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
             }
             break;
         case EVENT_LIGHT_BUTTON_UP:
-            if (act_on_btn(state)) break;
+            if (act_on_btn(state, BTN_LIGHT)) break;
             get_next_letter(state->position, state->word_elements);
             display_letter(state, true);
             break;
@@ -560,7 +586,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
             display_letter(state, true);
             break; 
         case EVENT_ALARM_BUTTON_UP:
-            if (act_on_btn(state)) break;
+            if (act_on_btn(state, BTN_ALARM)) break;
             display_letter(state, true);
             if (state->word_elements[state->position] == _num_valid_letters) break;
             state->playing = true;
@@ -586,7 +612,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
         case EVENT_ACTIVATE:
             break;
         case EVENT_TIMEOUT:
-            if (state->curr_screen >= SCREEN_WIN)
+            if (state->curr_screen >= SCREEN_RESULT)
                 display_title(state);
             break;
         case EVENT_LOW_ENERGY_UPDATE:
index 8ad9155c035350732c77311c841742204ebe159b..fe924926fdfc0659df5dc121e0df30fc565e9f49 100644 (file)
@@ -89,12 +89,13 @@ typedef enum {
     SCREEN_PLAYING = 0,
     SCREEN_TITLE,
     SCREEN_STREAK,
+    SCREEN_CONTINUE,
 #if USE_DAILY_STREAK
     SCREEN_WAIT,
 #endif
+    SCREEN_RESULT,
     SCREEN_WIN,
     SCREEN_LOSE,
-    SCREEN_RESULT,
     SCREEN_NO_DICT,
     SCREEN_ALREADY_GUESSED,
     SCREEN_COUNT
@@ -108,8 +109,9 @@ typedef struct {
     uint8_t attempt : 4;
     uint8_t position : 3;
     bool playing : 1;
-    uint16_t curr_answer : 15;
+    uint16_t curr_answer : 14;
     bool using_random_guess : 1;
+    bool continuing : 1;
     uint8_t streak;
     WordleScreen curr_screen;
 #if USE_DAILY_STREAK