Added auto DST on NTP

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-14 11:36:30 +01:00
parent e5fd5497e0
commit 9a3bf8a5f9
7 changed files with 162 additions and 27 deletions

View File

@@ -225,9 +225,9 @@
#define EE_CHECKBYTE_VALUE 10 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#ifdef HAS_AIR_BAND
#define EE_TOTAL_CNT 2282 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2283 // Total occupied eeprom bytes
#else
#define EE_TOTAL_CNT 2277 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2278 // Total occupied eeprom bytes
#endif
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
@@ -347,9 +347,10 @@
#define EE_BYTE_INVERTDISPLAY 2274
#define EE_BYTE_NTPOFFSET 2275
#define EE_BYTE_AUTOLOG 2276
#define EE_BYTE_AUTODST 2277
#ifdef HAS_AIR_BAND
#define EE_BYTE_AIRSTEPSIZE 2277
#define EE_UINT16_FREQUENCY_AIR 2278
#define EE_BYTE_AIRSTEPSIZE 2278
#define EE_UINT16_FREQUENCY_AIR 2279
#endif
// End of EEPROM index defines

View File

@@ -1407,6 +1407,16 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.drawString("kHz", 298, 2);
break;
case CONNECTIVITY:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
FullLineSprite.drawString(removeNewline(myLanguage[language][299]), 6, 2);
FullLineSprite.setTextDatum(TR_DATUM);
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FullLineSprite.drawString((autoDST ? myLanguage[language][42] : myLanguage[language][30]), 298, 2);
break;
case DXMODE:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
@@ -2486,6 +2496,15 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.drawString("kHz", 77, 15);
break;
case CONNECTIVITY:
PSSprite.setTextDatum(TC_DATUM);
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
PSSprite.drawString(shortLine(removeNewline(myLanguage[language][299])), 75, 1);
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
PSSprite.drawString((autoDST ? myLanguage[language][42] : myLanguage[language][30]), 75, 15);
break;
case DXMODE:
PSSprite.setTextDatum(TC_DATUM);
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
@@ -3800,6 +3819,13 @@ void MenuUp() {
OneBigLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset), 155, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM8:
autoDST = !autoDST;
OneBigLineSprite.drawString((autoDST ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;
@@ -4771,6 +4797,13 @@ void MenuDown() {
OneBigLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset), 155, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM8:
autoDST = !autoDST;
OneBigLineSprite.drawString((autoDST ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;
@@ -5800,6 +5833,13 @@ void DoMenu() {
OneBigLineSprite.drawString((NTPoffset > -1 ? "+" : "") + String(NTPoffset), 155, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM8:
Infoboxprint(myLanguage[language][299]);
OneBigLineSprite.drawString((autoDST ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;

View File

@@ -16,6 +16,7 @@ extern bool afmethodBold;
extern bool afpage;
extern bool afscreen;
extern bool artheadold;
extern bool autoDST;
extern bool autolog;
extern bool autosquelch;
extern bool BWreset;

View File

@@ -5,7 +5,7 @@
// [number of languages][number of texts]
static const char* const myLanguage[18][298] PROGMEM = {
static const char* const myLanguage[18][300] PROGMEM = {
{ "English", // English
"Rotary direction changed", // 1
"Please release button", // 2
@@ -303,7 +303,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Nederlands", // Dutch
@@ -601,9 +603,11 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Logboek legen", // 292
"Logboek geleegd", // 293
"Legen mislukt", // 294
"NTP tijdverschil instellen", // 295
"NTP tijdverschil\ninstellen", // 295
"Automatisch loggen", // 296
"Logboek vol!" // 297
"Logboek vol!", // 297
"Klok methode", // 298
"Auto zomertijd\nop NTP tijd" // 299
},
{ "Polski", // Polish
@@ -903,7 +907,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Błąd wyczyszczenia", // 294
"Ustaw odchyl. czasu NTP", // 295
"Autologowanie stacji", // 296
"Wykaz pełny!" // 297
"Wykaz pełny!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Hrvatski", // Croatian
@@ -1203,7 +1209,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Ελληνικά", // Greek
@@ -1503,7 +1511,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Η εκκαθάριση απέτυχε", // 294
"Ολίσθηση ώρας NTP", // 295
"Αυτόματη καταγραφή", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Română", // Romanian
@@ -1803,7 +1813,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Deutsch", // German
@@ -2103,7 +2115,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Löschen fehlgeschlagen", // 294
"NTP-Zeitversatz einstellen", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Český", // Czech
@@ -2403,7 +2417,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Magyar", // Hungarian
@@ -2703,7 +2719,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Français", // French
@@ -3003,7 +3021,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Échec de l'effacement", // 294
"Décalage horaire NTP", // 295
"Journal automatique", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Български", // Bulgarian
@@ -3303,7 +3323,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Русский", // Russian
@@ -3603,7 +3625,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Українська", // Ukranian
@@ -3903,7 +3927,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Italiano", // Italian
@@ -4203,7 +4229,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Cancellazione non riuscita", // 294
"Imposta offset orario NTP", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Simplified Chinese", // Simplified Chinese
@@ -4503,7 +4531,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Clear failed", // 294
"Set NTP time offset", // 295
"Autologger", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Norsk", // Norwegian
@@ -4803,7 +4833,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Slett mislyktes", // 294
"Angi NTP-tidsforskyvning", // 295
"Autologger", // 296
"Loggbok full!" // 297
"Loggbok full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Español", // Spanish
@@ -5103,7 +5135,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Error al borrar", // 294
"Desfase de tiempo NTP", // 295
"Registrador automático", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
},
{ "Português", // Portuguese
@@ -5403,7 +5437,9 @@ static const char* const myLanguage[18][298] PROGMEM = {
"Falha ao limpar", // 294
"Deslocamento de\ntempo NTP", // 295
"Registrador automático", // 296
"Logbook full!" // 297
"Logbook full!", // 297
"Clock mode", // 298
"Auto DST on NTP time" // 299
}
};
#endif
#endif

View File

@@ -801,6 +801,11 @@ void showCT() {
// Apply the GMT offset only if NTPupdated is true
if (NTPupdated) {
t += NTPoffset * 3600; // Convert offset from hours to seconds
// Apply DST adjustment if autoDST is enabled
if (autoDST && isDST(t)) {
t += 3600; // Add 1 hour for DST
}
}
// Format the time based on region

View File

@@ -13,6 +13,7 @@ extern bool afmethodBold;
extern bool afpage;
extern bool afscreen;
extern bool aftest;
extern bool autoDST;
extern bool artheadold;
extern bool BWreset;
extern bool compressedold;
@@ -154,4 +155,5 @@ extern void ShowRDSLogo(bool RDSstatus);
extern void DataPrint(String string);
extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize);
extern void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize);
extern bool isDST(time_t t);
#endif