]> git.earman.xyz Git - sensor-watch.git/commitdiff
blink colon when clock is in sleep mode (custom LCD only)
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 19:49:51 +0000 (15:49 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 19:49:51 +0000 (15:49 -0400)
watch-faces/clock/clock_face.c
watch-library/hardware/watch/watch_slcd.c
watch-library/shared/watch/watch_slcd.h
watch-library/simulator/watch/watch_slcd.c

index f71a13be20ddf3055198cbd9b1ab72e8bdd82c4a..ab09dd9d35e2b6957a39432da35f3c38813f7330 100644 (file)
@@ -201,12 +201,14 @@ static void clock_display_low_energy(watch_date_time date_time) {
 static void clock_start_tick_tock_animation(void) {
     if (!watch_sleep_animation_is_running()) {
         watch_start_sleep_animation(500);
+        watch_start_indicator_blink_if_possible(WATCH_INDICATOR_COLON, 500);
     }
 }
 
 static void clock_stop_tick_tock_animation(void) {
     if (watch_sleep_animation_is_running()) {
         watch_stop_sleep_animation();
+        watch_stop_blink();
     }
 }
 
index ad47b3a42dde5cb5a6a37017a83a1faf71808fde..777558ee140d26a6c459037b15329376b7dfc93e 100644 (file)
@@ -106,9 +106,51 @@ void watch_start_character_blink(char character, uint32_t duration) {
     watch_display_character(character, 7);
     watch_clear_pixel(2, 10); // clear segment B of position 7 since it can't blink
 
+    slcd_disable();
+    slcd_set_blink_enabled(false);
+    slcd_configure_blink(false, 0x0F, 0x0F, 0);
+    slcd_set_blink_enabled(true);
+    slcd_enable();
+}
+
+void watch_start_indicator_blink_if_possible(watch_indicator_t indicator, uint32_t duration) {
+#ifdef USE_CUSTOM_LCD
+    uint8_t mask = 0;
+    switch (indicator) {
+    case WATCH_INDICATOR_COLON:
+        mask = 0b0001;
+        break;
+    case WATCH_INDICATOR_LAP:
+        mask = 0b0010;
+        break;
+    case WATCH_INDICATOR_BATTERY:
+        mask = 0b0100;
+        break;
+    case WATCH_INDICATOR_SLEEP:
+        mask = 0b1000;
+        break;
+    default:
+        return;
+    }
+    watch_set_indicator(indicator);
+
+    if (duration <= _slcd_fc_min_ms_bypass) {
+        slcd_configure_frame_counter(0, (duration / (1000 / _slcd_framerate)) - 1, false);
+    } else {
+        slcd_configure_frame_counter(0, ((duration / (1000 / _slcd_framerate)) / 8 - 1), true);
+    }
+    slcd_set_frame_counter_enabled(0, true);
+
+
+    slcd_disable();
     slcd_set_blink_enabled(false);
-    slcd_configure_blink(false, 0x07, 0x07, 0);
+    slcd_configure_blink(false, mask, 0, 0);
     slcd_set_blink_enabled(true);
+    slcd_enable();
+#else
+    (void) indicator;
+    (void) duration;
+#endif
 }
 
 void watch_stop_blink(void) {
index d004e06a53099174db87ff2162e7aa1f3f618014..c3a23ba061b598c027a1d45cf44d22c339b191ed 100644 (file)
@@ -57,6 +57,9 @@ typedef enum {
     // These next indicators are only available on the new custom LCD:
     WATCH_INDICATOR_BATTERY,    ///< The battery indicator. Will fall back to the LAP icon on the original F-91W LCD.
     WATCH_INDICATOR_SLEEP,      ///< The sleep indicator. No fallback here; use the tick animation to indicate sleep.
+
+    // You can generally address the colon using dedicated functions, but it's also available here if needed.
+    WATCH_INDICATOR_COLON,      ///< The colon between hours and minutes.
 } watch_indicator_t;
 
 /// An enum listing the locations on the display where text can be placed.
@@ -197,15 +200,26 @@ void watch_clear_all_indicators(void);
   * @param character The character you wish to blink.
   * @param duration The duration of the on/off cycle in milliseconds, from 50 to ~4250 ms.
   * @note Segment B of position 7 cannot blink autonomously, so not all characters will work well.
-  *       Supported characters for blinking:
+  *       Supported characters for blinking on classic LCD :
   *        * Punctuation: underscore, apostrophe, comma, hyphen, equals sign, tilde (top segment only)
   *        * Numbers: 5, 6, ampersand (lowercase 7)
   *        * Letters: b, C, c, E, F, h, i, L, l, n, o, S, t
+  *       Supported characters for blinking on custom LCD :
+  *        * Only the segments making up the capital letter 'C' (ADEF)
   */
 void watch_start_character_blink(char character, uint32_t duration);
 
+/** @brief Blinks an indicator on the custom LCD.
+  * @details You can blink the LAP, ARROWS, SLEEP and COLON indicators on the custom LCD.
+  *          Alas you cannot autonomously blink any indicators on the original F-91W LCD.
+  * @param indicator The indicator you wish to blink.
+  * @param duration The duration of the on/off cycle in milliseconds, from 50 to ~4250 ms.
+  */
+void watch_start_indicator_blink_if_possible(watch_indicator_t indicator, uint32_t duration);
+
 /** @brief Stops and clears all blinking segments.
   * @details This will stop all blinking in position 7, and clear all segments in that digit.
+  *          On the Pro LCD, this will also stop the blinking of all indicators.
   */
 void watch_stop_blink(void);
 
index f8a72fdab4c9b9c38ede95f89b883023ef8f5124..b3e0f0ff553117ec8e3d0582de660df88daba227 100644 (file)
@@ -79,6 +79,10 @@ void watch_start_character_blink(char character, uint32_t duration) {
     blink_interval_id = emscripten_set_interval(watch_invoke_blink_callback, (double)duration, NULL);
 }
 
+void watch_start_indicator_blink_if_possible(watch_indicator_t indicator, uint32_t duration) {
+    /// TODO: For #SecondMovement, implement this on simulator
+}
+
 void watch_stop_blink(void) {
     emscripten_clear_timeout(blink_interval_id);
     blink_interval_id = -1;