diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 7d4dd9f..9ddab71 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -4,6 +4,7 @@ #include #include #include +#include // https://github.com/fbiego/ESP32Time #include // https://github.com/Bodmer/TFT_eSPI #include // https://github.com/bbx10/Hash_tng #include "src/WiFiConnect.h" @@ -64,6 +65,7 @@ bool edgebeep; bool externaltune; bool fullsearchrds; bool hasafold; +bool hasCTold; bool haseonold; bool hasrtplusold; bool hastmcold; @@ -80,6 +82,7 @@ bool RDSstatus; bool RDSstatusold; bool rdsstereoold; bool resetFontOnNextCall; +bool rtcset; bool screenmute; bool screensavertriggered = false; bool seek; @@ -338,6 +341,8 @@ unsigned long tuningtimer; unsigned long udptimer; TEF6686 radio; +ESP32Time rtc(0); + TFT_eSprite RadiotextSprite = TFT_eSprite(&tft); TFT_eSprite FrequencySprite = TFT_eSprite(&tft); TFT_eSprite AdvRadiotextSprite = TFT_eSprite(&tft); @@ -948,6 +953,7 @@ void loop() { } void GetData() { + showCT(); if (band < BAND_GAP) ShowStereoStatus(); if (band < BAND_GAP && !menu) { if (advancedRDS && !afscreen && !screenmute) ShowAdvancedRDS(); @@ -956,7 +962,6 @@ void GetData() { showPTY(); showECC(); showRadioText(); - showCT(); if (millis() >= tuningtimer + 200) doAF(); } showPI(); diff --git a/src/rds.cpp b/src/rds.cpp index 82af4a3..4e321ef 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -282,7 +282,6 @@ void readRds() { if (!RDSstatus) { if (radio.rds.correctPI != 0) { if (region == REGION_EU) { - if (advancedRDS) tftPrint(0, PIold, 275, 75, SecondaryColor, SecondaryColorSmooth, 28); else tftPrint(0, PIold, 275, 187, SecondaryColor, SecondaryColorSmooth, 28); } @@ -299,6 +298,13 @@ void readRds() { tft.fillCircle(162, 41, 5, SignificantColor); tft.fillCircle(200, 41, 5, SignificantColor); } + if (radio.rds.hasCT) { + if (advancedRDS) { + tftPrint(1, rds_clock, 205, 109, SecondaryColor, SecondaryColorSmooth, 16); + } else { + tftPrint(1, rds_clock, 205, 163, SecondaryColor, SecondaryColorSmooth, 16); + } + } dropout = true; } } else { @@ -322,6 +328,13 @@ void readRds() { tft.fillCircle(203, 223, 2, GreyoutColor); tft.fillCircle(203, 234, 2, GreyoutColor); } + if (radio.rds.hasCT) { + if (advancedRDS) { + tftReplace(1, rds_clockold, rds_clock, 205, 109, PrimaryColor, PrimaryColorSmooth, 16); + } else { + tftReplace(1, rds_clockold, rds_clock, 205, 163, PrimaryColor, PrimaryColorSmooth, 16); + } + } dropout = false; } } @@ -457,15 +470,22 @@ void showPS() { void showCT() { if (!screenmute) { - rds_clock = ((radio.rds.hour < 10 ? "0" : "") + String(radio.rds.hour) + ":" + (radio.rds.minute < 10 ? "0" : "") + String(radio.rds.minute)); - if (rds_clock != rds_clockold) { - if (radio.rds.hasCT) { + if (radio.rds.hasCT) rds_clock = ((radio.rds.hour < 10 ? "0" : "") + String(radio.rds.hour) + ":" + (radio.rds.minute < 10 ? "0" : "") + String(radio.rds.minute)); else rds_clock = ((rtc.getHour(true) < 10 ? "0" : "") + String(rtc.getHour(true)) + ":" + (rtc.getMinute() < 10 ? "0" : "") + String(rtc.getMinute())); + if (rds_clock != rds_clockold || hasCTold != radio.rds.hasCT) { + if (radio.rds.hasCT && RDSstatus) { + rtcset = true; + rtc.setTime(0, radio.rds.minute, radio.rds.hour, radio.rds.day, radio.rds.month, radio.rds.year); if (advancedRDS) tftReplace(1, rds_clockold, rds_clock, 205, 109, PrimaryColor, PrimaryColorSmooth, 16); else tftReplace(1, rds_clockold, rds_clock, 205, 163, PrimaryColor, PrimaryColorSmooth, 16); } else { - if (advancedRDS) tftPrint(1, rds_clock, 205, 109, BackgroundColor, BackgroundColor, 16); else tftPrint(1, rds_clock, 205, 163, BackgroundColor, BackgroundColor, 16); + if (rtcset) { + if (advancedRDS) tftReplace(1, rds_clockold, rds_clock, 205, 109, SecondaryColor, SecondaryColorSmooth, 16); else tftReplace(1, rds_clockold, rds_clock, 205, 163, SecondaryColor, SecondaryColorSmooth, 16); + } else { + if (advancedRDS) tftPrint(1, rds_clock, 205, 109, BackgroundColor, BackgroundColor, 16); else tftPrint(1, rds_clock, 205, 163, BackgroundColor, BackgroundColor, 16); + } } } rds_clockold = rds_clock; + hasCTold = radio.rds.hasCT; } } diff --git a/src/rds.h b/src/rds.h index 4cbd3b2..2c4ac77 100644 --- a/src/rds.h +++ b/src/rds.h @@ -6,6 +6,7 @@ #include #include "TEF6686.h" #include +#include extern bool advancedRDS; extern bool afmethodBold; @@ -19,6 +20,7 @@ extern bool dropout; extern bool dynamicPTYold; extern bool fullsearchrds; extern bool hasafold; +extern bool hasCTold; extern bool haseonold; extern bool hasrtplusold; extern bool hastmcold; @@ -27,6 +29,7 @@ extern bool RDSSPYTCP; extern bool RDSSPYUSB; extern bool RDSstatus; extern bool rdsstereoold; +extern bool rtcset; extern bool screenmute; extern bool setupmode; extern byte showrdserrors; @@ -101,6 +104,7 @@ extern unsigned long rtplustickerhold; extern unsigned long rtticker; extern unsigned long rttickerhold; +extern ESP32Time rtc; extern TFT_eSPI tft; extern TEF6686 radio; extern WiFiClient RemoteClient;