Selaa lähdekoodia

tweak standby time date display

Thomas Buck 5 kuukautta sitten
vanhempi
commit
23393735b6
1 muutettua tiedostoa jossa 15 lisäystä ja 3 poistoa
  1. 15
    3
      src/ui.cpp

+ 15
- 3
src/ui.cpp Näytä tiedosto

@@ -65,9 +65,10 @@
65 65
 #define STANDBY_BRIGHTNESS 10
66 66
 
67 67
 #define NTP_SERVER "pool.ntp.org"
68
-#define STANDBY_REDRAW_MS (1000 * 10)
68
+#define STANDBY_REDRAW_MS 500
69 69
 
70
-// TODO make configurable
70
+// TODO auto-detect?!
71
+#warning hard-coded timezone and daylight savings offset
71 72
 #define gmtOffset_sec (60 * 60)
72 73
 #define daylightOffset_sec (60 * 60)
73 74
 
@@ -231,7 +232,10 @@ static void draw_info(void) {
231 232
 }
232 233
 
233 234
 static void draw_standby(void) {
234
-    tft.fillScreen(TFT_BLACK);
235
+    // only clear whole screen when first entering standby page
236
+    if ((curr_brightness > STANDBY_BRIGHTNESS)) {
237
+        tft.fillScreen(TFT_BLACK);
238
+    }
235 239
 
236 240
     tft.setTextDatum(TC_DATUM); // top center
237 241
     tft.drawString(ESP_PLATFORM_NAME " " NAME_OF_FEATURE " V" ESP_ENV_VERSION, LCD_WIDTH / 2, 0, 2);
@@ -239,7 +243,10 @@ static void draw_standby(void) {
239 243
 
240 244
     struct tm timeinfo;
241 245
     String date, time;
246
+    String weekday[7] = { "So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa." };
242 247
     if(getLocalTime(&timeinfo)) {
248
+        date += weekday[timeinfo.tm_wday % 7];
249
+        date += " ";
243 250
         if (timeinfo.tm_mday < 10) {
244 251
             date += "0";
245 252
         }
@@ -261,6 +268,11 @@ static void draw_standby(void) {
261 268
             time += "0";
262 269
         }
263 270
         time += String(timeinfo.tm_min);
271
+        time += ":";
272
+        if (timeinfo.tm_sec < 10) {
273
+            time += "0";
274
+        }
275
+        time += String(timeinfo.tm_sec);
264 276
     }
265 277
 
266 278
     tft.setTextDatum(MC_DATUM); // middle center

Loading…
Peruuta
Tallenna