From f466445a13f8c9ef0c3f006c900e7e5f254bd5a1 Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Tue, 14 May 2024 16:56:09 +0200 Subject: [PATCH] Added menu option to configure 5s band button press --- TEF6686_ESP32.ino | 17 ++++++- src/constants.h | 15 ++++-- src/gui.cpp | 80 ++++++++++++++++++++++++++------ src/gui.h | 1 + src/language.h | 116 +++++++++++++++++++++++++++++++++++++--------- 5 files changed, 185 insertions(+), 44 deletions(-) diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 61b84e9..10561f2 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -169,6 +169,7 @@ byte iMSEQ; byte iMSset; byte language; byte licold; +byte longbandpress; byte memorypos; byte memoryposold; byte memoryposstatus; @@ -507,6 +508,7 @@ void setup() { scancancel = EEPROM.readByte(EE_BYTE_SCANCANCEL); scanmute = EEPROM.readByte(EE_BYTE_SCANMUTE); autosquelch = EEPROM.readByte(EE_BYTE_AUTOSQUELCH); + longbandpress = EEPROM.readByte(EE_BYTE_LONGBANDPRESS); if (spispeed == SPI_SPEED_DEFAULT) { tft.setSPISpeed(SPI_FREQUENCY / 1000000); @@ -1641,8 +1643,17 @@ void BANDBUTTONPress() { WakeToSleep(true); } while (digitalRead(BANDBUTTON) == LOW && counter - counterold <= 2500) counter = millis(); - if (counter - counterold > 2499 && hardwaremodel == BASE_ILI9341) { - deepSleep(); + if (counter - counterold > 2499) { + switch (longbandpress) { + case STANDBY: + deepSleep(); + break; + + case SCREENOFF: + screensavertriggered = true; + MuteScreen(1); + break; + } } } } @@ -4113,6 +4124,7 @@ void DefaultSettings(byte userhardwaremodel) { EEPROM.writeByte(EE_BYTE_SCANCANCEL, 0); EEPROM.writeByte(EE_BYTE_SCANMUTE, 0); EEPROM.writeByte(EE_BYTE_AUTOSQUELCH, 0); + EEPROM.writeByte(EE_BYTE_LONGBANDPRESS, 0); for (int i = 0; i < EE_PRESETS_CNT; i++) { EEPROM.writeByte(i + EE_PRESETS_BAND_START, BAND_FM); @@ -4345,6 +4357,7 @@ void endMenu() { EEPROM.writeByte(EE_BYTE_SCANCANCEL, scancancel); EEPROM.writeByte(EE_BYTE_SCANMUTE, scanmute); EEPROM.writeByte(EE_BYTE_AUTOSQUELCH, autosquelch); + EEPROM.writeByte(EE_BYTE_LONGBANDPRESS, longbandpress); EEPROM.commit(); if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false; Serial.end(); diff --git a/src/constants.h b/src/constants.h index 69ea81b..03935f8 100644 --- a/src/constants.h +++ b/src/constants.h @@ -209,9 +209,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 2220 // Total occupied eeprom bytes +#define EE_TOTAL_CNT 2221 // Total occupied eeprom bytes #else -#define EE_TOTAL_CNT 2215 // Total occupied eeprom bytes +#define EE_TOTAL_CNT 2216 // Total occupied eeprom bytes #endif #define EE_PRESETS_BAND_START 0 // 99 * 1 byte @@ -310,10 +310,11 @@ #define EE_BYTE_SCANMEM 2211 #define EE_BYTE_SCANCANCEL 2212 #define EE_BYTE_SCANMUTE 2213 -#define EE_BYTE_AUTOSQUELCH 2214 +#define EE_BYTE_AUTOSQUELCH 2214 +#define EE_BYTE_LONGBANDPRESS 2215 #ifdef HAS_AIR_BAND -#define EE_BYTE_AIRSTEPSIZE 2115 -#define EE_UINT16_FREQUENCY_AIR 2216 +#define EE_BYTE_AIRSTEPSIZE 2116 +#define EE_UINT16_FREQUENCY_AIR 2217 #endif // End of EEPROM index defines @@ -332,6 +333,10 @@ typedef struct { char RDSPS[9]; } mem; +enum LONGBANDBUTTONPRESS { + STANDBY = 0, SCREENOFF +}; + enum SCAN_CANCEL { SCAN_CANCEL = OFF, CORRECTPI, SIGNAL }; diff --git a/src/gui.cpp b/src/gui.cpp index 92ea8e0..3f63f57 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -8,7 +8,7 @@ #include byte menuitem; -byte items[9] = {9, static_cast(dynamicspi ? 9 : 8), 7, 10, 9, 10, 9, 6, 7}; +byte items[9] = {9, static_cast(dynamicspi ? 10 : 9), 7, 10, 9, 10, 9, 6, 7}; extern mem presets[]; void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de/online/rgb565-color-picker/ @@ -1287,20 +1287,16 @@ void ShowOneLine(byte position, byte item, bool selected) { break; case MAINSETTINGS: - if (dynamicspi) { - FullLineSprite.setTextDatum(TL_DATUM); - FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); - FullLineSprite.drawString(removeNewline(myLanguage[language][81]), 6, 3); + FullLineSprite.setTextDatum(TL_DATUM); + FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); + FullLineSprite.drawString(removeNewline(myLanguage[language][224]), 6, 3); - FullLineSprite.setTextDatum(TR_DATUM); - FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); - FullLineSprite.drawString("MHz", 298, 3); - FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); - if (spispeed == 7) { - FullLineSprite.drawString(myLanguage[language][86], 258, 3); - } else { - FullLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(myLanguage[language][204]) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 258, 3); - } + FullLineSprite.setTextDatum(TR_DATUM); + FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); + switch (longbandpress) { + case STANDBY: FullLineSprite.drawString(myLanguage[language][225], 298, 3); break; + case SCREENOFF: FullLineSprite.drawString(myLanguage[language][226], 298, 3); break; + default: FullLineSprite.drawString(myLanguage[language][227], 298, 3); break; } break; @@ -1352,6 +1348,24 @@ void ShowOneLine(byte position, byte item, bool selected) { FullLineSprite.drawString(removeNewline(String(myLanguage[language][84]) + " " + String(VERSION)), 152, 3); break; + case MAINSETTINGS: + if (dynamicspi) { + FullLineSprite.setTextDatum(TL_DATUM); + FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); + FullLineSprite.drawString(removeNewline(myLanguage[language][81]), 6, 3); + + FullLineSprite.setTextDatum(TR_DATUM); + FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); + FullLineSprite.drawString("MHz", 298, 3); + FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); + if (spispeed == 7) { + FullLineSprite.drawString(myLanguage[language][86], 258, 3); + } else { + FullLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(myLanguage[language][204]) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 258, 3); + } + } + break; + case DISPLAYSETTINGS: FullLineSprite.setTextDatum(TL_DATUM); FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); @@ -1863,6 +1877,18 @@ void MenuUp() { break; case ITEM9: + longbandpress++; + if (longbandpress > 2) longbandpress = 0; + + switch (longbandpress) { + case STANDBY: OneBigLineSprite.drawString(myLanguage[language][225], 135, 0); break; + case SCREENOFF: OneBigLineSprite.drawString(myLanguage[language][226], 135, 0); break; + default: OneBigLineSprite.drawString(myLanguage[language][227], 135, 0); break; + } + OneBigLineSprite.pushSprite(24, 118); + break; + + case ITEM10: spispeed++; if (spispeed > SPI_SPEED_COUNT - 1) spispeed = 0; @@ -2694,6 +2720,19 @@ void MenuDown() { break; case ITEM9: + longbandpress--; + if (longbandpress > 2) longbandpress = 2; + + switch (longbandpress) { + case STANDBY: OneBigLineSprite.drawString(myLanguage[language][225], 135, 0); break; + case SCREENOFF: OneBigLineSprite.drawString(myLanguage[language][226], 135, 0); break; + default: OneBigLineSprite.drawString(myLanguage[language][227], 135, 0); break; + } + OneBigLineSprite.pushSprite(24, 118); + break; + + + case ITEM10: spispeed--; if (spispeed > SPI_SPEED_COUNT - 1) spispeed = SPI_SPEED_COUNT - 1; OneBigLineSprite.setTextDatum(TL_DATUM); @@ -3577,11 +3616,22 @@ void DoMenu() { case AM_BAND_NONE: OneBigLineSprite.drawString(myLanguage[language][83], 135, 0); break; } #endif - OneBigLineSprite.pushSprite(24, 118); break; case ITEM9: + Infoboxprint(myLanguage[language][224]); + + switch (longbandpress) { + case STANDBY: OneBigLineSprite.drawString(myLanguage[language][225], 135, 0); break; + case SCREENOFF: OneBigLineSprite.drawString(myLanguage[language][226], 135, 0); break; + default: OneBigLineSprite.drawString(myLanguage[language][227], 135, 0); break; + } + OneBigLineSprite.pushSprite(24, 118); + break; + + + case ITEM10: Infoboxprint(myLanguage[language][81]); OneBigLineSprite.setTextDatum(TL_DATUM); diff --git a/src/gui.h b/src/gui.h index efab857..3354097 100644 --- a/src/gui.h +++ b/src/gui.h @@ -98,6 +98,7 @@ extern byte HighCutLevel; extern byte HighCutOffset; extern byte language; extern byte licold; +extern byte longbandpress; extern byte memorypos; extern byte menupage; extern byte MSold; diff --git a/src/language.h b/src/language.h index 49bdb87..ae81fad 100644 --- a/src/language.h +++ b/src/language.h @@ -5,7 +5,7 @@ // [number of languages][number of texts] // *** means the text is the same as in English -static const char* const myLanguage[18][224] PROGMEM = { +static const char* const myLanguage[18][228] PROGMEM = { { "English", // English "Rotary direction changed", // 1 "Please release button", // 2 @@ -229,7 +229,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Nederlands", // Dutch @@ -455,7 +459,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correcte PI", // 220 "Signaal", // 221 "Geen geluid\ntijdens scannen", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton ingedrukt", // 224 + "Uitschakelen", // 225 + "Scherm uit", // 226 + "Geen functie" // 227 }, { "Polski", // Polish @@ -681,7 +689,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Poprawne PI", // 220 "Sygnał", // 221 "Wycisz dźwięk\npodczas skanowania", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Hrvatski", // Croatian @@ -907,7 +919,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Ελληνικά", // Greek @@ -1133,7 +1149,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Σωστό PI", // 220 "Σήμα", // 221 "Σίγαση ήχου\nκατά την ανίχνευση", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Română", // Romanian @@ -1359,7 +1379,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Deutsch", // German @@ -1585,7 +1609,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Korrekter PI-Code", // 220 "Signal", // 221 "Stumm beim Scannen", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Český", // Czech @@ -1811,7 +1839,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Slovenský", // Slovak @@ -2037,7 +2069,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Français", // French @@ -2263,7 +2299,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "PI Correct", // 220 "Signal", // 221 "Audio muet lors\nde la numérisation", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Български", // Bulgarian @@ -2489,7 +2529,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Русский", // Russian @@ -2715,7 +2759,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "При корректном PI", // 220 "При наличии сигнала", // 221 "Отключать аудио\nпри сканировании", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Українська", // Ukranian @@ -2941,7 +2989,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "Correct PI", // 220 "Signal", // 221 "Mute audio\nwhile scanning", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Italiano", // Italian @@ -3006,7 +3058,7 @@ static const char* const myLanguage[18][224] PROGMEM = { "Mostra banda SW in m.", // 59 "Filtro RDS", // 60 "Mostra errori PI", // 61 - "Utilizzare squelch", // 62 + "Utilizzare squelch", // 62 "Meter di modulazione", // 63 "Soppressione rumore AM", // 64 "Soppressione rumore FM", // 65 @@ -3027,7 +3079,7 @@ static const char* const myLanguage[18][224] PROGMEM = { "Min.", // 80 *** "Velocità SPI Dinamico", // 81 *** "Sensibilità scansione", // 82 - "ASSENTE", // 83 + "ASSENTE", // 83 "Versione Software", // 84 "Font frequenza", // 85 *** "Auto", // 86 @@ -3167,7 +3219,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "PI corretto", // 220 "Signale", // 221 "Audio silenziato\ndurante scansione", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Simplified Chinese", // Simplified Chinese @@ -3393,7 +3449,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "节目识别码正确", // 220 "信号超阈值", // 221 "扫描时静音", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Norsk", // Norwegian @@ -3619,7 +3679,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "korrekt PI", // 220 "Signal", // 221 "Demp lyden\nmens du skanner", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Español", // Spanish @@ -3845,7 +3909,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "PI correcto", // 220 "Señal", // 221 "Audio mudo\nmientras busca", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 }, { "Português", // Portuguese @@ -4071,7 +4139,11 @@ static const char* const myLanguage[18][224] PROGMEM = { "PI correto", // 220 "Sinal", // 221 "Mudo áudio\nenquanto procura", // 222 - "AIR" // 223 + "AIR", // 223 + "5 sec. bandbutton press", // 224 + "Power off", // 225 + "Mute screen", // 226 + "Disabled" // 227 } }; -#endif +#endif \ No newline at end of file