Added logging to GUI

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-08 11:23:21 +01:00
parent 8e0d8ec07e
commit 5e55bff237
7 changed files with 213 additions and 39 deletions
+74 -17
View File
@@ -184,7 +184,7 @@ byte amgain;
byte freqoldcount;
byte HighCutLevel;
byte HighCutOffset;
byte items[10] = {10, static_cast<byte>(dynamicspi ? 10 : 9), 7, 10, 10, 10, 9, 6, 9, 9};
byte items[10] = {10, static_cast<byte>(dynamicspi ? 10 : 9), 7, 10, 10, 10, 9, 6, 10, 9};
byte iMSEQ;
byte iMSset;
byte language;
@@ -642,6 +642,7 @@ void setup() {
webserver.on("/", handleRoot);
webserver.on("/downloadCSV", HTTP_GET, handleDownloadCSV);
webserver.on("/logo.png", handleLogo);
doTheme();
@@ -2732,7 +2733,12 @@ void ButtonPress() {
}
}
} else {
toggleiMSEQ();
if (band < BAND_GAP) {
if (addRowToCSV()) ShowFreq(2); else ShowFreq(3);
delay(200);
while (digitalRead(ROTARY_BUTTON) == LOW) delay(50);
ShowFreq(0);
}
}
}
if (screensaverset) {
@@ -3150,17 +3156,32 @@ void ShowFreq(int mode) {
}
FrequencySprite.setTextDatum(TR_DATUM);
switch (mode) {
case 0:
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.setTextColor(FreqColor, FreqColorSmooth, false);
FrequencySprite.drawString(String(freq / 100) + "." + (freq % 100 < 10 ? "0" : "") + String(freq % 100) + " ", 218, -6);
FrequencySprite.pushSprite(46, 46);
freqold = freq;
break;
if (mode == 0) {
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.setTextColor(FreqColor, FreqColorSmooth, false);
FrequencySprite.drawString(String(freq / 100) + "." + (freq % 100 < 10 ? "0" : "") + String(freq % 100) + " ", 218, -6);
FrequencySprite.pushSprite(46, 46);
freqold = freq;
} else if (mode == 1) {
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.pushSprite(46, 46);
tftPrint(0, myLanguage[language][34], 146, 58, ActiveColor, ActiveColorSmooth, 28);
case 1:
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.pushSprite(46, 46);
tftPrint(0, myLanguage[language][34], 146, 58, ActiveColor, ActiveColorSmooth, 28);
break;
case 2:
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.pushSprite(46, 46);
tftPrint(0, myLanguage[language][290], 146, 58, ActiveColor, ActiveColorSmooth, 28);
break;
case 3:
FrequencySprite.fillSprite(BackgroundColor);
FrequencySprite.pushSprite(46, 46);
tftPrint(0, myLanguage[language][291], 146, 58, ActiveColor, ActiveColorSmooth, 28);
break;
}
FrequencySprite.unloadFont();
}
@@ -5328,23 +5349,23 @@ void handleRoot() {
// Add CSS styling for a modern, dark-themed look
html += "<style>";
html += "body {background-color: #1a1a1a; color: white; font-family: 'Arial', sans-serif; margin: 0; padding: 0;}";
html += "h1 {text-align: center; color: #ffffff; margin-top: 20px; font-size: 32px;}"; // Change the color to white
html += "h1 {text-align: center; color: #ffffff; margin-top: 20px; font-size: 32px;}";
html += "img {display: block; margin: 0 auto; max-width: 100%; height: auto; padding-top: 20px;}";
html += "table {width: 90%; margin: 0 auto; border-collapse: collapse; border-radius: 8px; overflow: hidden;}";
html += "th {background-color: #333; color: white; padding: 12px; text-align: left; font-size: 18px;}"; // Keep header text color white
html += "th {background-color: #333; color: white; padding: 12px; text-align: left; font-size: 18px;}";
html += "td {background-color: #2a2a2a; color: white; padding: 10px; text-align: left; font-size: 16px;}";
html += "tr:nth-child(even) {background-color: #252525;}";
html += "tr:hover {background-color: #444; cursor: pointer;}";
html += "button {background-color: #ffcc00; color: black; border: none; padding: 12px 20px; font-size: 18px; cursor: pointer; border-radius: 5px; display: block; margin: 20px auto;}";
html += "button:hover {background-color: #ff9900;}";
html += "@media (max-width: 768px) { table {width: 100%;} th, td {font-size: 14px; padding: 8px;} }";
html += ".go-to-bottom {position: fixed; bottom: 30px; right: 30px; background-color: #ffcc00; color: black; border: none; padding: 12px 20px; font-size: 18px; cursor: pointer; border-radius: 5px; z-index: 100;}"; // Position the button at the bottom-right corner
html += ".go-to-bottom {position: fixed; bottom: 30px; right: 30px; background-color: #ffcc00; color: black; border: none; padding: 12px 20px; font-size: 18px; cursor: pointer; border-radius: 5px; z-index: 100;}";
html += "</style>";
html += "</head><body>";
// Add the logo image at the top of the page
html += "<img src=\"https://fmdx.org/img/logo.png\" alt=\"FMdx Logo\">";
// Add the logo image at the top of the page, served from SPIFFS
html += "<img src=\"/logo.png\" alt=\"FMdx Logo\">";
// Add a header with a dynamic title from the language array (replace with actual language logic)
html += "<h1>" + String(myLanguage[language][286]) + "</h1>";
@@ -5585,3 +5606,39 @@ String getCurrentDateTime() {
return String(buf) + "," + timeEuropean;
}
}
void handleLogo() {
fs::File file = SPIFFS.open("/logo.png", "r");
if (!file) {
webserver.send(404, "text/plain", "Logo not found");
return;
}
webserver.streamFile(file, "image/png");
file.close();
}
void printLogbookCSV() {
// Attempt to open the CSV file stored in SPIFFS
fs::File file = SPIFFS.open("/logbook.csv", "r");
// Check if the file was successfully opened
if (!file) {
Serial.println("Failed to open logbook!");
return;
}
// Print a message indicating the start of the file content
Serial.println("===== Start of logbook.csv =====");
// Read and print the contents of the file line by line
while (file.available()) {
String line = file.readStringUntil('\n'); // Read one line at a time
Serial.println(line); // Print the line to the Serial Monitor
}
// Close the file after reading
file.close();
// Print a message indicating the end of the file content
Serial.println("===== End of logbook.csv =====");
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

+2
View File
@@ -307,6 +307,8 @@ void Communication() {
}
}
}
} else if (data_str.startsWith("l") || data_str.startsWith("L")) {
printLogbookCSV();
}
}
+1 -1
View File
@@ -148,5 +148,5 @@ extern void showAutoSquelch(bool mode);
extern void ShowStepSize();
extern void startFMDXScan();
extern void cancelDXScan();
extern void printLogbookCSV();
#endif
+26 -2
View File
@@ -1555,6 +1555,12 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FullLineSprite.drawString(String(fmscansens), 298, 2);
break;
case DXMODE:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
FullLineSprite.drawString(removeNewline(myLanguage[language][292]), 6, 2);
break;
}
break;
}
@@ -2608,6 +2614,12 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
PSSprite.drawString(String(fmscansens), 75, 15);
break;
case DXMODE:
PSSprite.setTextDatum(TC_DATUM);
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
PSSprite.drawString(shortLine(removeNewline(myLanguage[language][292])), 75, 8);
break;
}
break;
}
@@ -4854,14 +4866,14 @@ void MenuDown() {
}
void showMenuOpenTouchButtons() {
if (hardwaremodel == PORTABLE_TOUCH_ILI9341 && !((menupage == CONNECTIVITY && menuoption == ITEM3) || (menupage == AUTOMEM && (menuoption == ITEM1 || menuoption == ITEM9)) || (menupage == MAINSETTINGS && menuoption == ITEM1))) {
if (hardwaremodel == PORTABLE_TOUCH_ILI9341 && !((menupage == CONNECTIVITY && menuoption == ITEM3) || (menupage == AUTOMEM && (menuoption == ITEM1 || menuoption == ITEM9)) || (menupage == MAINSETTINGS && menuoption == ITEM1) || (menupage == DXMODE && menuoption == ITEM10))) {
tft.fillRoundRect(18, 154, 60, 40, 6, FrameColor);
tft.drawRoundRect(18, 154, 60, 40, 6, ActiveColor);
tft.fillRoundRect(240, 154, 60, 40, 6, FrameColor);
tft.drawRoundRect(240, 154, 60, 40, 6, ActiveColor);
tft.fillTriangle(52, 160, 52, 188, 38, 174, (CurrentTheme == 7 ? White : ActiveColor));
tft.fillTriangle(266, 160, 266, 188, 280, 174, (CurrentTheme == 7 ? White : ActiveColor));
if (menuoption == ITEM9) {
if (!submenu && menuoption == ITEM9) {
tft.fillRoundRect(240, 36, 60, 40, 6, FrameColor);
tft.drawRoundRect(240, 36, 60, 40, 6, ActiveColor);
tftPrint(0, "OK", 270, 44, (CurrentTheme == 7 ? White : ActiveColor), ActiveColorSmooth, 28);
@@ -5799,6 +5811,18 @@ void DoMenu() {
OneBigLineSprite.drawString((scanholdonsignal ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM10:
Infoboxprint(myLanguage[language][292]);
if (handleCreateNewLogbook()) OneBigLineSprite.drawString(myLanguage[language][293], 135, 0); else OneBigLineSprite.drawString(myLanguage[language][294], 135, 0);
OneBigLineSprite.pushSprite(24, 118);
if (hardwaremodel == PORTABLE_TOUCH_ILI9341) {
tft.fillRoundRect(130, 154, 60, 40, 6, FrameColor);
tft.drawRoundRect(130, 154, 60, 40, 6, ActiveColor);
tftPrint(0, "OK", 160, 162, (CurrentTheme == 7 ? White : ActiveColor), ActiveColorSmooth, 28);
}
break;
}
break;
+1
View File
@@ -246,4 +246,5 @@ extern void setAutoSpeedSPI();
extern void showAutoSquelch(bool mode);
extern uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi);
extern void ClearMemoryRange(uint8_t start, uint8_t stop);
extern bool handleCreateNewLogbook();
#endif
+109 -19
View File
@@ -5,7 +5,7 @@
// [number of languages][number of texts]
static const char* const myLanguage[18][290] PROGMEM = {
static const char* const myLanguage[18][295] PROGMEM = {
{ "English", // English
"Rotary direction changed", // 1
"Please release button", // 2
@@ -295,7 +295,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Nederlands", // Dutch
@@ -587,7 +592,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Jouw logboek", // 286
"Download logboek", // 287
"Logboek is leeg", // 288
"Ga naar einde" // 289
"Ga naar einde", // 289
"Logboek update", // 290
"Log mislukt!", // 291
"Logboek legen", // 292
"Logboek geleegd", // 293
"Legen mislukt" // 294
},
{ "Polski", // Polish
@@ -879,7 +889,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Hrvatski", // Croatian
@@ -1171,7 +1186,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Ελληνικά", // Greek
@@ -1463,7 +1483,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Română", // Romanian
@@ -1755,7 +1780,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Deutsch", // German
@@ -2047,7 +2077,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Český", // Czech
@@ -2339,7 +2374,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Magyar", // Hungarian
@@ -2631,7 +2671,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Français", // French
@@ -2923,7 +2968,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Български", // Bulgarian
@@ -3215,7 +3265,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Русский", // Russian
@@ -3507,7 +3562,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Українська", // Ukranian
@@ -3799,7 +3859,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Italiano", // Italian
@@ -4091,7 +4156,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Simplified Chinese", // Simplified Chinese
@@ -4383,7 +4453,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Norsk", // Norwegian
@@ -4675,7 +4750,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Español", // Spanish
@@ -4967,7 +5047,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
},
{ "Português", // Portuguese
@@ -5259,7 +5344,12 @@ static const char* const myLanguage[18][290] PROGMEM = {
"Your logbook", // 286
"Download logbook", // 287
"Logbook is empty", // 288
"Go to bottom" // 289
"Go to bottom", // 289
"Added to log", // 290
"Update failed!", // 291
"Clear logbook", // 292
"Logbook cleared", // 293
"Clear failed" // 294
}
};
#endif