diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index c2b4e7c..eab5f31 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -394,6 +394,7 @@ unsigned int frequencyold; unsigned int HighEdgeOIRTSet; unsigned int HighEdgeSet; unsigned int LowEdgeOIRTSet; +unsigned int logcounter; unsigned int LowEdgeSet; unsigned int LWHighEdgeSet; unsigned int LWLowEdgeSet; @@ -588,6 +589,7 @@ void setup() { autolog = EEPROM.readByte(EE_BYTE_AUTOLOG); autoDST = EEPROM.readByte(EE_BYTE_AUTODST); clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM); + logcounter = EEPROM.readUInt(EE_UINT16_LOGCOUNTER); if (spispeed == SPI_SPEED_DEFAULT) { tft.setSPISpeed(SPI_FREQUENCY / 1000000); @@ -4600,6 +4602,8 @@ void DefaultSettings() { } EEPROM.commit(); + + handleCreateNewLogbook(); } 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) { @@ -5486,40 +5490,45 @@ void handleRoot() { columnIndex++; } - // Generate rows - while (file.available()) { - String line = file.readStringUntil('\n'); - if (line.length() > 0) { - hasData = true; - html += ""; + if (file.available()) hasData = true; - String piCode = "", frequency = ""; - startIndex = 0, columnIndex = 0; + if (logcounter < 130) { + // Generate rows + while (file.available()) { + String line = file.readStringUntil('\n'); + if (line.length() > 0) { + html += ""; - while (startIndex < line.length()) { - int endIndex = line.indexOf(',', startIndex); - if (endIndex == -1) endIndex = line.length(); - String cell = line.substring(startIndex, endIndex); + String piCode = "", frequency = ""; + startIndex = 0, columnIndex = 0; - // Extract PI code and Frequency - if (columnIndex == piCodeIndex) piCode = cell; - if (columnIndex == frequencyIndex) frequency = cell; + while (startIndex < line.length()) { + int endIndex = line.indexOf(',', startIndex); + if (endIndex == -1) endIndex = line.length(); + String cell = line.substring(startIndex, endIndex); - html += "" + cell + ""; - startIndex = endIndex + 1; - columnIndex++; + // Extract PI code and Frequency + if (columnIndex == piCodeIndex) piCode = cell; + if (columnIndex == frequencyIndex) frequency = cell; + + html += "" + cell + ""; + startIndex = endIndex + 1; + columnIndex++; + } + + // Remove " MHz" from Frequency + frequency.replace(" MHz", ""); + + // Make row clickable + html += "🌐"; + html += ""; } - - // Remove " MHz" from Frequency - frequency.replace(" MHz", ""); - - // Make row clickable - html += "🌐"; - html += ""; } - } - file.close(); + file.close(); + } else { + html += "" + String(myLanguage[language][300]) + ""; + } if (!hasData) { html += "" + String(myLanguage[language][288]) + ""; @@ -5580,13 +5589,17 @@ bool handleCreateNewLogbook() { file.flush(); // Ensure that everything is written to the file file.close(); // Close the file after writing + + logcounter = 0; // Reset logcounter + EEPROM.writeUInt(EE_UINT16_LOGCOUNTER, logcounter); + EEPROM.commit(); // Return true if the function runs without problems return true; } byte addRowToCSV() { // Ensure there is at least 150 bytes of free space in SPIFFS before proceeding - if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 150) { + if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 150 || logcounter > 1000) { return 2; // Return 2 if insufficient free space is available } @@ -5642,9 +5655,9 @@ byte addRowToCSV() { String TP; String Stereo; String pty; - if (radio.rds.hasTA) TA = "•"; else TA = "-"; - if (radio.rds.hasTP) TP = "•"; else TP = "-"; - if (radio.getStereoStatus()) Stereo = "•"; else Stereo = "-"; + if (radio.rds.hasTA) TA = "•"; else TA = ""; + if (radio.rds.hasTP) TP = "•"; else TP = ""; + if (radio.getStereoStatus()) Stereo = "•"; else Stereo = ""; pty = String(radio.rds.stationTypeCode); // Construct the CSV row data @@ -5662,6 +5675,9 @@ byte addRowToCSV() { // Write the row to the file and close it if (file.print(row)) { file.close(); // Successfully wrote to the file + logcounter++; + EEPROM.writeUInt(EE_UINT16_LOGCOUNTER, logcounter); + EEPROM.commit(); return 0; // Return 0 to indicate success } else { file.close(); // Close the file if writing fails diff --git a/src/constants.h b/src/constants.h index fd75aca..13a5b36 100644 --- a/src/constants.h +++ b/src/constants.h @@ -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 2284 // Total occupied eeprom bytes +#define EE_TOTAL_CNT 2288 // Total occupied eeprom bytes #else -#define EE_TOTAL_CNT 2279 // Total occupied eeprom bytes +#define EE_TOTAL_CNT 2283 // Total occupied eeprom bytes #endif #define EE_PRESETS_BAND_START 0 // 99 * 1 byte @@ -349,9 +349,10 @@ #define EE_BYTE_AUTOLOG 2276 #define EE_BYTE_AUTODST 2277 #define EE_BYTE_CLOCKAMPM 2278 +#define EE_UINT16_LOGCOUNTER 2279 #ifdef HAS_AIR_BAND -#define EE_BYTE_AIRSTEPSIZE 2279 -#define EE_UINT16_FREQUENCY_AIR 2280 +#define EE_BYTE_AIRSTEPSIZE 2283 +#define EE_UINT16_FREQUENCY_AIR 2284 #endif // End of EEPROM index defines diff --git a/src/language.h b/src/language.h index a97e785..35230c4 100644 --- a/src/language.h +++ b/src/language.h @@ -5,7 +5,7 @@ // [number of languages][number of texts] -static const char* const myLanguage[18][300] PROGMEM = { +static const char* const myLanguage[18][301] PROGMEM = { { "English", // English "Rotary direction changed", // 1 "Please release button", // 2 @@ -305,7 +305,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Nederlands", // Dutch @@ -607,7 +608,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Automatisch loggen", // 296 "Logboek vol!", // 297 "Klok methode", // 298 - "Auto zomertijd\nop NTP tijd" // 299 + "Auto zomertijd\nop NTP tijd", // 299 + "Het logboek bevat meer dan 130 items, die de viewer niet kan verwerken. Download alstublieft het CSV-bestand om het te bekijken." // 300 }, { "Polski", // Polish @@ -909,7 +911,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologowanie stacji", // 296 "Wykaz pełny!", // 297 "Tryb zegara", // 298 - "Auto czas letni wg NTP" // 299 + "Auto czas letni wg NTP", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Hrvatski", // Croatian @@ -1211,7 +1214,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Ελληνικά", // Greek @@ -1513,7 +1517,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Αυτόματη καταγραφή", // 296 "Βιβλίο γεμάτο!", // 297 "Λειτουργία ρολογιού", // 298 - "Αυτόματο DST\nσε ώρα NTP" // 299 + "Αυτόματο DST\nσε ώρα NTP", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Română", // Romanian @@ -1815,7 +1820,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Deutsch", // German @@ -2117,7 +2123,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Český", // Czech @@ -2419,7 +2426,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Magyar", // Hungarian @@ -2721,7 +2729,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Français", // French @@ -3023,7 +3032,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Journal automatique", // 296 "Journal de bord plein!", // 297 "Mode horloge", // 298 - "DST automatique\nsur l'heure NTP" // 299 + "DST automatique\nsur l'heure NTP", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Български", // Bulgarian @@ -3325,7 +3335,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Русский", // Russian @@ -3627,7 +3638,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Українська", // Ukranian @@ -3929,7 +3941,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Italiano", // Italian @@ -4231,7 +4244,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Simplified Chinese", // Simplified Chinese @@ -4533,7 +4547,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Logbook full!", // 297 "Clock mode", // 298 - "Auto DST on NTP time" // 299 + "Auto DST on NTP time", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Norsk", // Norwegian @@ -4835,7 +4850,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Autologger", // 296 "Loggbok full!", // 297 "Klokkemodus", // 298 - "Auto sommertid på NTP-tid" // 299 + "Auto sommertid på NTP-tid", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Español", // Spanish @@ -5137,7 +5153,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Registrador automático", // 296 "¡Libro lleno!", // 297 "Modo reloj", // 298 - "DST automático\nen hora NTP" // 299 + "DST automático\nen hora NTP", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 }, { "Português", // Portuguese @@ -5439,7 +5456,8 @@ static const char* const myLanguage[18][300] PROGMEM = { "Registrador automático", // 296 "Livro cheio!", // 297 "Modo de relógio", // 298 - "DST automático\nno horário NTP" // 299 + "DST automático\nno horário NTP", // 299 + "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it." // 300 } }; -#endif +#endif \ No newline at end of file