Added RTC clock

Once when CT has been received, time is synced to internal RTC. When CT is not avaialble the RTC time will be shown in secondary color. This clock is also visible in AM mode.
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-10-25 17:22:59 +02:00
parent 32d866328a
commit 8d910ef63d
3 changed files with 35 additions and 6 deletions
+6 -1
View File
@@ -4,6 +4,7 @@
#include <EEPROM.h>
#include <Wire.h>
#include <math.h>
#include <ESP32Time.h> // https://github.com/fbiego/ESP32Time
#include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
#include <Hash.h> // 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();
+25 -5
View File
@@ -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;
}
}
+4
View File
@@ -6,6 +6,7 @@
#include <WiFiClient.h>
#include "TEF6686.h"
#include <WiFi.h>
#include <ESP32Time.h>
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;