display.cpp: time/date display added if RTC present

This commit is contained in:
Klaus K Wilting 2019-01-27 21:02:08 +01:00
parent 7c68f7632a
commit ddc7abe90d

View File

@ -1,5 +1,27 @@
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
/*
Display-Mask (128 x 64 pixel):
| 111111
|0123456789012345
------------------
0|PAX:aabbccddee
1|PAX:aabbccddee
2|B:a.bcV Sats:ab
3|BLTH:abcde SF:ab
4|WIFI:abcde ch:ab
5|RLIM:abcd abcdKB
6|xxxxxxxxxxxxxxxx
6|20:27:00* 27.Feb
7|yyyyyyyyyyyyyyab
line 6: x = Text for LORA status OR time/date
line 7: y = Text for LMIC status; ab = payload queue
*/
// Basic Config // Basic Config
#include "globals.h" #include "globals.h"
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes #include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
@ -19,6 +41,10 @@ const char lora_datarate[] = {"1211100908078CNA1211109C8C7C"};
const char lora_datarate[] = {"121110090807FSNA"}; const char lora_datarate[] = {"121110090807FSNA"};
#endif #endif
// helper arry for converting month values to text
char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
uint8_t volatile DisplayState = 0; uint8_t volatile DisplayState = 0;
// helper function, prints a hex key on display // helper function, prints a hex key on display
@ -144,7 +170,7 @@ void refreshtheDisplay() {
#ifdef BLECOUNTER #ifdef BLECOUNTER
u8x8.setCursor(0, 3); u8x8.setCursor(0, 3);
if (cfg.blescan) if (cfg.blescan)
u8x8.printf("BLTH:%-4d", macs_ble); u8x8.printf("BLTH:%-5d", macs_ble);
else else
u8x8.printf("%s", "BLTH:off"); u8x8.printf("%s", "BLTH:off");
#endif #endif
@ -162,7 +188,7 @@ void refreshtheDisplay() {
// update wifi counter + channel display (line 4) // update wifi counter + channel display (line 4)
u8x8.setCursor(0, 4); u8x8.setCursor(0, 4);
u8x8.printf("WIFI:%-4d", macs_wifi); u8x8.printf("WIFI:%-5d", macs_wifi);
u8x8.setCursor(11, 4); u8x8.setCursor(11, 4);
u8x8.printf("ch:%02d", channel); u8x8.printf("ch:%02d", channel);
@ -173,9 +199,18 @@ void refreshtheDisplay() {
u8x8.printf("%4dKB", getFreeRAM() / 1024); u8x8.printf("%4dKB", getFreeRAM() / 1024);
#ifdef HAS_LORA #ifdef HAS_LORA
// update LoRa status display (line 6)
u8x8.setCursor(0, 6); u8x8.setCursor(0, 6);
#ifndef HAS_RTC
// update LoRa status display (line 6)
u8x8.printf("%-16s", display_line6); u8x8.printf("%-16s", display_line6);
#else
// update time/date display (line 6)
time_t t = now();
u8x8.printf("%02d:%02d:%02d%c %2d.%3s", hour(t), minute(t), second(t),
timeStatus() == timeSet ? '*' : '?', day(t),
printmonth[month(t)]);
#endif
// update LMiC event display (line 7) // update LMiC event display (line 7)
u8x8.setCursor(0, 7); u8x8.setCursor(0, 7);