]> git.earman.xyz Git - sensor-watch.git/commitdiff
add option for text across the top on custom LCD
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 18:54:59 +0000 (14:54 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 19:24:43 +0000 (15:24 -0400)
watch-library/shared/watch/watch_common_display.c
watch-library/shared/watch/watch_slcd.h

index c6d175894f1c8c0cccf4ae3005a7fec30f057226..4b2d03fdc508a726a99dec8992a3d1b8654aa526 100644 (file)
@@ -54,6 +54,7 @@ static const uint32_t IndicatorSegments[] = {
 void watch_display_character(uint8_t character, uint8_t position) {
 #ifdef USE_CUSTOM_LCD
     if (character == 'R') character = 'r'; // We can't display uppercase R on this display.
+    else if (character == 'T' && position > 1 && position < 8) character = 't'; // lowercase t is the only option for these positions
 #else
     // special cases for positions 4 and 6
     if (position == 4 || position == 6) {
@@ -155,6 +156,7 @@ void watch_display_string(const char *string, uint8_t position) {
 
 void watch_display_text(watch_position_t location, const char *string) {
     switch (location) {
+        case WATCH_POSITION_TOP:
         case WATCH_POSITION_TOP_LEFT:
             watch_display_character(string[0], 0);
             if (string[1]) {
@@ -198,7 +200,6 @@ void watch_display_text(watch_position_t location, const char *string) {
             }
             break;
         case WATCH_POSITION_FULL:
-        default:
             // This is deprecated, but we use it for the legacy behavior.
             #pragma GCC diagnostic push
             #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -212,6 +213,14 @@ void watch_display_text_with_fallback(watch_position_t location, const char *str
     (void)fallback;
 
     switch (location) {
+        case WATCH_POSITION_TOP:
+            for (size_t i = 0; i < strlen(string); i++) {
+                if (i < 2) watch_display_character(string[i], i);
+                else if (i == 2) watch_display_character(string[i], 10);
+                else if (i < 5) watch_display_character(string[i], i - 1);
+                else break;
+            }
+            break;
         case WATCH_POSITION_TOP_LEFT:
             watch_display_character(string[0], 0);
             if (string[1]) {
@@ -248,7 +257,6 @@ void watch_display_text_with_fallback(watch_position_t location, const char *str
             watch_display_text(location, string);
             break;
         case WATCH_POSITION_FULL:
-        default:
             // This is deprecated, but we use it for the legacy behavior.
             #pragma GCC diagnostic push
             #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
index eba6df5a7337c086bd709a3ca230dc97adcc7349..7c73652629ac0e4810134191b5be335c25ea7116 100644 (file)
@@ -62,6 +62,7 @@ typedef enum {
 /// An enum listing the locations on the display where text can be placed.
 typedef enum {
     WATCH_POSITION_FULL = 0,    ///< Display 10 characters to the full screen, in the standard F-91W layout.
+    WATCH_POSITION_TOP,         ///< Display 2 (classic) or 5 (custom) characters at the top of the screen. On custom LCD, overwrites top right positon.
     WATCH_POSITION_TOP_LEFT,    ///< Display 2 or 3 characters in the top left of the screen.
     WATCH_POSITION_TOP_RIGHT,   ///< Display 2 digits in the top right of the screen.
     WATCH_POSITION_BOTTOM,      ///< Display 6 characters at the bottom of the screen, the main line.