Clean ups, and more features

This commit is contained in:
2026-02-18 16:28:52 +01:00
parent 9e6cf2bd72
commit d1294914ce
22 changed files with 228 additions and 1138 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ void NTPupdate() {
time_t currentTime = getNtpTime();
if (currentTime) {
set_time(currentTime);
set_time(currentTime, Timezone);
rtcset = true;
NTPupdated = true;
radio.rds.ctupdate = false;
+1 -1
View File
@@ -1270,7 +1270,7 @@ void TEF6686::readRDS(byte showrdserrors) {
rds.offset = timeoffset;
rtcset = true;
if (!NTPupdated) set_time(rdstime + timeoffset);
if (!NTPupdated) set_time(rdstime, timeoffset);
} else rds.hasCT = false;
lastrdstime = rdstime;
lasttimeoffset = timeoffset;
+16 -2
View File
@@ -967,7 +967,7 @@ void total_pc_control() {
if(len < 3 + datalen + 1) break; // Validate buffer size
Wire.beginTransmission(addr);
Wire.write(data + 3, len - 3);
Wire.write(data + 3, datalen);
auto out = Wire.endTransmission(false);
uint8_t recvlen = Wire.requestFrom(addr, data[3+datalen]);
@@ -987,7 +987,7 @@ void total_pc_control() {
case 4: { // Version
Serial.write(2);
Serial.write(4);
Serial.write(1);
Serial.write(2);
} break;
case 5: { // Reboot
Serial.write(1);
@@ -1006,6 +1006,20 @@ void total_pc_control() {
Serial.flush();
Serial.updateBaudRate(clock);
} break;
case 7: { // Write to EEPROM
if(len < 4) break;
EEPROM.writeBytes((data[1] << 8) | data[2], data + 3, len - 3);
EEPROM.commit();
Serial.write(1);
Serial.write(7);
} break;
case 8: { // Read from EEPROM
if(len < 4) break;
auto address = (data[1] << 8) | data[2];
Serial.write(data[3] + 1);
Serial.write(8);
for(uint16_t i = 0; i < data[3]; i++) Serial.write(EEPROM.read(address + i));
} break;
case 0xff: { // Another wake command
Serial.write(1);
Serial.write(0xff);
-1
View File
@@ -846,7 +846,6 @@ void endMenu() {
menuitem = 0;
saveData();
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
Serial.end();
if (wifi) remoteip = IPAddress(WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
Serial.flush();
+1 -1
View File
@@ -217,7 +217,7 @@ int8_t MPold = 0;
int8_t USold = 0;
int8_t LevelOffset;
int8_t LowLevelSet;
int8_t NTPoffset;
int8_t Timezone;
int8_t CN;
int8_t CNold;
RTC_DATA_ATTR int8_t VolSet;
+9 -9
View File
@@ -1393,7 +1393,7 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.setTextDatum(TR_DATUM);
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FullLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset, DEC), 298, 2);
FullLineSprite.drawString((Timezone > -1 ? "+" : "") + String(Timezone), 298, 2);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
FullLineSprite.drawString("GMT", 258, 2);
break;
@@ -2491,7 +2491,7 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.setTextDatum(TL_DATUM);
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
PSSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset, DEC), 77, 15);
PSSprite.drawString((Timezone > -1 ? "+" : "") + String(Timezone), 77, 15);
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
PSSprite.setTextDatum(TR_DATUM);
PSSprite.drawString("GMT", 73, 15);
@@ -4171,11 +4171,11 @@ void MenuUpDown(bool dir) {
case ITEM7:
if (dir) {
NTPoffset++;
if (NTPoffset > 12) NTPoffset = -12;
Timezone++;
if (Timezone > 12) Timezone = -12;
} else {
NTPoffset--;
if (NTPoffset < -12) NTPoffset = 12;
Timezone--;
if (Timezone < -12) Timezone = 12;
}
OneBigLineSprite.setTextDatum(TR_DATUM);
@@ -4183,7 +4183,7 @@ void MenuUpDown(bool dir) {
OneBigLineSprite.drawString("GMT", 135, 0);
OneBigLineSprite.setTextDatum(TL_DATUM);
OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
OneBigLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset), 155, 0);
OneBigLineSprite.drawString((Timezone > -1 ? "+" : "") + String(Timezone), 155, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
@@ -5225,7 +5225,7 @@ void DoMenu() {
wc.addParameter(&XDRGTK_key_input);
setWiFiConnectParam = true;
}
wc.startConfigurationPortal(AP_WAIT);
wc.startConfigurationPortal();
XDRGTK_key = XDRGTK_key_input.getValue();
EEPROM.writeString(EE_STRING_XDRGTK_KEY, XDRGTK_key);
EEPROM.commit();
@@ -5269,7 +5269,7 @@ void DoMenu() {
OneBigLineSprite.drawString("GMT", 135, 0);
OneBigLineSprite.setTextDatum(TL_DATUM);
OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
OneBigLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset), 155, 0);
OneBigLineSprite.drawString((Timezone > -1 ? "+" : "") + String(Timezone), 155, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
+2 -2
View File
@@ -255,14 +255,14 @@ String getCurrentDateTime(bool inUTC) {
int utcOffsetHours = 0;
if (!inUTC) {
currentEpoch += (NTPupdated ? NTPoffset * 3600 : radio.rds.offset); // Apply GMT offset if NTPupdated, else RDS offset
currentEpoch += (NTPupdated ? Timezone * 3600 : radio.rds.offset); // Apply GMT offset if NTPupdated, else RDS offset
if (NTPupdated && autoDST) {
struct tm tempTimeInfo;
localtime_r(&currentEpoch, &tempTimeInfo);
if (isDST(mktime(&tempTimeInfo))) currentEpoch += 3600;
}
} else utcOffsetHours = (NTPupdated ? NTPoffset : radio.rds.offset / 3600);
} else utcOffsetHours = (NTPupdated ? Timezone : radio.rds.offset / 3600);
localtime_r(&currentEpoch, &timeInfo);
+3 -3
View File
@@ -118,7 +118,7 @@ void saveData() {
EEPROM.writeByte(EE_BYTE_MEMPIONLY, mempionly);
EEPROM.writeByte(EE_BYTE_MEMDOUBLEPI, memdoublepi);
EEPROM.writeByte(EE_BYTE_WAITONLYONSIGNAL, scanholdonsignal);
EEPROM.writeByte(EE_BYTE_NTPOFFSET, NTPoffset);
EEPROM.writeByte(EE_BYTE_TIMEZONE, Timezone);
EEPROM.writeByte(EE_BYTE_AUTOLOG, autolog);
EEPROM.writeByte(EE_BYTE_AUTODST, autoDST);
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, clockampm);
@@ -231,7 +231,7 @@ void loadData() {
TouchCalData[3] = EEPROM.readUInt(EE_UINT16_CALTOUCH4);
TouchCalData[4] = EEPROM.readUInt(EE_UINT16_CALTOUCH5);
invertdisplay = EEPROM.readByte(EE_BYTE_INVERTDISPLAY);
NTPoffset = EEPROM.readByte(EE_BYTE_NTPOFFSET);
Timezone = EEPROM.readByte(EE_BYTE_TIMEZONE);
autolog = EEPROM.readByte(EE_BYTE_AUTOLOG);
autoDST = EEPROM.readByte(EE_BYTE_AUTODST);
clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM);
@@ -338,7 +338,7 @@ void DefaultSettings() {
EEPROM.writeUInt(EE_UINT16_CALTOUCH3, 300);
EEPROM.writeUInt(EE_UINT16_CALTOUCH4, 3450);
EEPROM.writeUInt(EE_UINT16_CALTOUCH5, 3);
EEPROM.writeByte(EE_BYTE_NTPOFFSET, 1);
EEPROM.writeByte(EE_BYTE_TIMEZONE, 0);
EEPROM.writeByte(EE_BYTE_AUTOLOG, 1);
EEPROM.writeByte(EE_BYTE_AUTODST, 1);
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0);
+1 -1
View File
@@ -490,8 +490,8 @@ void showCT() {
char dateStr[9];
time_t t = rtc.getEpoch();
t += Timezone * 3600; // Convert offset from hours to seconds
if (NTPupdated) {
t += NTPoffset * 3600; // Convert offset from hours to seconds
if (autoDST && isDST(t)) t += 3600;
}
+9 -1
View File
@@ -1,4 +1,6 @@
#include "rtc.hpp"
#include "globals.h"
#include "nonvolatile.h"
// the hardware rtc driver was made with the support of Wh1teRabbitHU's implementation
@@ -120,8 +122,14 @@ bool init_rtc() {
return false;
}
void set_time(time_t time) {
void set_time(time_t time, int8_t offset) {
rtc.setTime(time);
if(Timezone != offset) {
EEPROM.writeByte(EE_BYTE_TIMEZONE, offset);
EEPROM.commit();
Timezone = offset;
}
if(!rx_rtc_avail) return;
struct tm* timeinfo = gmtime(&time);
writeToModule(0x1F, 64);