Added limit over 130 entries for logbook viewer and 1000 entires in total

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-14 21:47:13 +01:00
parent a02e9f5ac0
commit a4eac50357
3 changed files with 90 additions and 55 deletions
+47 -31
View File
@@ -394,6 +394,7 @@ unsigned int frequencyold;
unsigned int HighEdgeOIRTSet; unsigned int HighEdgeOIRTSet;
unsigned int HighEdgeSet; unsigned int HighEdgeSet;
unsigned int LowEdgeOIRTSet; unsigned int LowEdgeOIRTSet;
unsigned int logcounter;
unsigned int LowEdgeSet; unsigned int LowEdgeSet;
unsigned int LWHighEdgeSet; unsigned int LWHighEdgeSet;
unsigned int LWLowEdgeSet; unsigned int LWLowEdgeSet;
@@ -588,6 +589,7 @@ void setup() {
autolog = EEPROM.readByte(EE_BYTE_AUTOLOG); autolog = EEPROM.readByte(EE_BYTE_AUTOLOG);
autoDST = EEPROM.readByte(EE_BYTE_AUTODST); autoDST = EEPROM.readByte(EE_BYTE_AUTODST);
clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM); clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM);
logcounter = EEPROM.readUInt(EE_UINT16_LOGCOUNTER);
if (spispeed == SPI_SPEED_DEFAULT) { if (spispeed == SPI_SPEED_DEFAULT) {
tft.setSPISpeed(SPI_FREQUENCY / 1000000); tft.setSPISpeed(SPI_FREQUENCY / 1000000);
@@ -4600,6 +4602,8 @@ void DefaultSettings() {
} }
EEPROM.commit(); 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) { 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++; columnIndex++;
} }
// Generate rows if (file.available()) hasData = true;
while (file.available()) {
String line = file.readStringUntil('\n');
if (line.length() > 0) {
hasData = true;
html += "<tr>";
String piCode = "", frequency = ""; if (logcounter < 130) {
startIndex = 0, columnIndex = 0; // Generate rows
while (file.available()) {
String line = file.readStringUntil('\n');
if (line.length() > 0) {
html += "<tr>";
while (startIndex < line.length()) { String piCode = "", frequency = "";
int endIndex = line.indexOf(',', startIndex); startIndex = 0, columnIndex = 0;
if (endIndex == -1) endIndex = line.length();
String cell = line.substring(startIndex, endIndex);
// Extract PI code and Frequency while (startIndex < line.length()) {
if (columnIndex == piCodeIndex) piCode = cell; int endIndex = line.indexOf(',', startIndex);
if (columnIndex == frequencyIndex) frequency = cell; if (endIndex == -1) endIndex = line.length();
String cell = line.substring(startIndex, endIndex);
html += "<td>" + cell + "</td>"; // Extract PI code and Frequency
startIndex = endIndex + 1; if (columnIndex == piCodeIndex) piCode = cell;
columnIndex++; if (columnIndex == frequencyIndex) frequency = cell;
html += "<td>" + cell + "</td>";
startIndex = endIndex + 1;
columnIndex++;
}
// Remove " MHz" from Frequency
frequency.replace(" MHz", "");
// Make row clickable
html += "<td><a href =\"https://maps.fmdx.org/#qth=&freq=" + frequency + "&findPi=" + piCode + "\"target=\"_blank\">🌐</a></td>";
html += "</tr>";
} }
// Remove " MHz" from Frequency
frequency.replace(" MHz", "");
// Make row clickable
html += "<td><a href =\"https://maps.fmdx.org/#qth=&freq=" + frequency + "&findPi=" + piCode + "\"target=\"_blank\">🌐</a></td>";
html += "</tr>";
} }
}
file.close(); file.close();
} else {
html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(myLanguage[language][300]) + "</td></tr>";
}
if (!hasData) { if (!hasData) {
html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(myLanguage[language][288]) + "</td></tr>"; html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(myLanguage[language][288]) + "</td></tr>";
@@ -5580,13 +5589,17 @@ bool handleCreateNewLogbook() {
file.flush(); // Ensure that everything is written to the file file.flush(); // Ensure that everything is written to the file
file.close(); // Close the file after writing 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 if the function runs without problems
return true; return true;
} }
byte addRowToCSV() { byte addRowToCSV() {
// Ensure there is at least 150 bytes of free space in SPIFFS before proceeding // 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 return 2; // Return 2 if insufficient free space is available
} }
@@ -5642,9 +5655,9 @@ byte addRowToCSV() {
String TP; String TP;
String Stereo; String Stereo;
String pty; String pty;
if (radio.rds.hasTA) TA = ""; else TA = "-"; if (radio.rds.hasTA) TA = ""; else TA = "";
if (radio.rds.hasTP) TP = ""; else TP = "-"; if (radio.rds.hasTP) TP = ""; else TP = "";
if (radio.getStereoStatus()) Stereo = ""; else Stereo = "-"; if (radio.getStereoStatus()) Stereo = ""; else Stereo = "";
pty = String(radio.rds.stationTypeCode); pty = String(radio.rds.stationTypeCode);
// Construct the CSV row data // Construct the CSV row data
@@ -5662,6 +5675,9 @@ byte addRowToCSV() {
// Write the row to the file and close it // Write the row to the file and close it
if (file.print(row)) { if (file.print(row)) {
file.close(); // Successfully wrote to the file file.close(); // Successfully wrote to the file
logcounter++;
EEPROM.writeUInt(EE_UINT16_LOGCOUNTER, logcounter);
EEPROM.commit();
return 0; // Return 0 to indicate success return 0; // Return 0 to indicate success
} else { } else {
file.close(); // Close the file if writing fails file.close(); // Close the file if writing fails
+5 -4
View File
@@ -225,9 +225,9 @@
#define EE_CHECKBYTE_VALUE 10 // 0 ~ 255,add new entry, change for new value #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! #define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#ifdef HAS_AIR_BAND #ifdef HAS_AIR_BAND
#define EE_TOTAL_CNT 2284 // Total occupied eeprom bytes #define EE_TOTAL_CNT 2288 // Total occupied eeprom bytes
#else #else
#define EE_TOTAL_CNT 2279 // Total occupied eeprom bytes #define EE_TOTAL_CNT 2283 // Total occupied eeprom bytes
#endif #endif
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte #define EE_PRESETS_BAND_START 0 // 99 * 1 byte
@@ -349,9 +349,10 @@
#define EE_BYTE_AUTOLOG 2276 #define EE_BYTE_AUTOLOG 2276
#define EE_BYTE_AUTODST 2277 #define EE_BYTE_AUTODST 2277
#define EE_BYTE_CLOCKAMPM 2278 #define EE_BYTE_CLOCKAMPM 2278
#define EE_UINT16_LOGCOUNTER 2279
#ifdef HAS_AIR_BAND #ifdef HAS_AIR_BAND
#define EE_BYTE_AIRSTEPSIZE 2279 #define EE_BYTE_AIRSTEPSIZE 2283
#define EE_UINT16_FREQUENCY_AIR 2280 #define EE_UINT16_FREQUENCY_AIR 2284
#endif #endif
// End of EEPROM index defines // End of EEPROM index defines
+37 -19
View File
@@ -5,7 +5,7 @@
// [number of languages][number of texts] // [number of languages][number of texts]
static const char* const myLanguage[18][300] PROGMEM = { static const char* const myLanguage[18][301] PROGMEM = {
{ "English", // English { "English", // English
"Rotary direction changed", // 1 "Rotary direction changed", // 1
"Please release button", // 2 "Please release button", // 2
@@ -305,7 +305,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Nederlands", // Dutch
@@ -607,7 +608,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Automatisch loggen", // 296 "Automatisch loggen", // 296
"Logboek vol!", // 297 "Logboek vol!", // 297
"Klok methode", // 298 "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 { "Polski", // Polish
@@ -909,7 +911,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologowanie stacji", // 296 "Autologowanie stacji", // 296
"Wykaz pełny!", // 297 "Wykaz pełny!", // 297
"Tryb zegara", // 298 "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 { "Hrvatski", // Croatian
@@ -1211,7 +1214,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Ελληνικά", // Greek
@@ -1513,7 +1517,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Αυτόματη καταγραφή", // 296 "Αυτόματη καταγραφή", // 296
"Βιβλίο γεμάτο!", // 297 "Βιβλίο γεμάτο!", // 297
"Λειτουργία ρολογιού", // 298 "Λειτουργία ρολογιού", // 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 { "Română", // Romanian
@@ -1815,7 +1820,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Deutsch", // German
@@ -2117,7 +2123,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Český", // Czech
@@ -2419,7 +2426,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Magyar", // Hungarian
@@ -2721,7 +2729,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Français", // French
@@ -3023,7 +3032,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Journal automatique", // 296 "Journal automatique", // 296
"Journal de bord plein!", // 297 "Journal de bord plein!", // 297
"Mode horloge", // 298 "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 { "Български", // Bulgarian
@@ -3325,7 +3335,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Русский", // Russian
@@ -3627,7 +3638,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Українська", // Ukranian
@@ -3929,7 +3941,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Italiano", // Italian
@@ -4231,7 +4244,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Simplified Chinese", // Simplified Chinese
@@ -4533,7 +4547,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Logbook full!", // 297 "Logbook full!", // 297
"Clock mode", // 298 "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 { "Norsk", // Norwegian
@@ -4835,7 +4850,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Autologger", // 296 "Autologger", // 296
"Loggbok full!", // 297 "Loggbok full!", // 297
"Klokkemodus", // 298 "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 { "Español", // Spanish
@@ -5137,7 +5153,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Registrador automático", // 296 "Registrador automático", // 296
"¡Libro lleno!", // 297 "¡Libro lleno!", // 297
"Modo reloj", // 298 "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 { "Português", // Portuguese
@@ -5439,7 +5456,8 @@ static const char* const myLanguage[18][300] PROGMEM = {
"Registrador automático", // 296 "Registrador automático", // 296
"Livro cheio!", // 297 "Livro cheio!", // 297
"Modo de relógio", // 298 "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