]> git.earman.xyz Git - sensor-watch.git/commitdiff
LE mode in the endless runner now displays the current time.
authorDavid Volovskiy <devolov@gmail.com>
Thu, 25 Jul 2024 01:12:17 +0000 (21:12 -0400)
committerDavid Volovskiy <devolov@gmail.com>
Tue, 3 Sep 2024 20:20:11 +0000 (16:20 -0400)
movement/watch_faces/complication/endless_runner_face.c

index 6009015516a280c317538f119f726b59bd031c68..96dfa89673f2224e5c44218ba9ef26d5cc5b43dc 100644 (file)
@@ -319,6 +319,37 @@ static void display_title(endless_runner_state_t *state) {
     display_difficulty(difficulty);
 }
 
+static void display_time(watch_date_time date_time, bool clock_mode_24h) {
+    static watch_date_time previous_date_time;
+    char buf[6 + 1];
+
+    // If the hour needs updating
+    if (date_time.unit.hour != previous_date_time.unit.hour) {
+        uint8_t hour = date_time.unit.hour;
+
+        if (clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+        else {
+            if (hour >= 12) watch_set_indicator(WATCH_INDICATOR_PM);
+            hour %= 12;
+            if (hour == 0) hour = 12;
+        }
+        watch_set_colon();
+        sprintf( buf, "%2d%02d  ", hour, date_time.unit.minute);
+        watch_display_string(buf, 4);
+    }
+    // If both digits of the minute need updating
+    else if ((date_time.unit.minute / 10) != (previous_date_time.unit.minute / 10)) {
+        sprintf( buf, "%02d  ", date_time.unit.minute);
+        watch_display_string(buf, 6);
+    }
+    // If only the ones-place of the minute needs updating.
+    else if (date_time.unit.minute != previous_date_time.unit.minute) {
+        sprintf( buf, "%d  ", date_time.unit.minute % 10);
+        watch_display_string(buf, 7);
+    }
+    previous_date_time.reg = date_time.reg;
+}
+
 static void begin_playing(endless_runner_state_t *state) {
     uint8_t difficulty = state -> difficulty;
     game_state.curr_screen = SCREEN_PLAYING;
@@ -569,6 +600,7 @@ bool endless_runner_face_loop(movement_event_t event, movement_settings_t *setti
                 display_title(state);
             break;
         case EVENT_LOW_ENERGY_UPDATE:
+            display_time(watch_rtc_get_date_time(), settings->bit.clock_mode_24h);
             break;
         default:
             return movement_default_loop_handler(event, settings);