Undo CSV changes
This commit is contained in:
+2
-2
@@ -3235,13 +3235,13 @@ void ShowFreq(int mode) {
|
|||||||
case 3:
|
case 3:
|
||||||
FrequencySprite.fillSprite(BackgroundColor);
|
FrequencySprite.fillSprite(BackgroundColor);
|
||||||
FrequencySprite.pushSprite(46, 46);
|
FrequencySprite.pushSprite(46, 46);
|
||||||
tftPrint(0, myLanguage[language][291], 146, 58, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(0, myLanguage[language][291], 146, 58, SignificantColor, SignificantColorSmooth, 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
FrequencySprite.fillSprite(BackgroundColor);
|
FrequencySprite.fillSprite(BackgroundColor);
|
||||||
FrequencySprite.pushSprite(46, 46);
|
FrequencySprite.pushSprite(46, 46);
|
||||||
tftPrint(0, myLanguage[language][297], 146, 58, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(0, myLanguage[language][297], 146, 58, SignificantColor, SignificantColorSmooth, 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
|
|||||||
+37
-42
@@ -222,7 +222,7 @@ bool handleCreateNewLogbook() {
|
|||||||
|
|
||||||
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 > 1500) {
|
||||||
return 2; // Return 2 if insufficient free space is available
|
return 2; // Return 2 if insufficient free space is available
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,19 +234,20 @@ byte addRowToCSV() {
|
|||||||
return 1; // Return 1 if the file cannot be opened
|
return 1; // Return 1 if the file cannot be opened
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the current date and time
|
// Fetch the current date and time as a string
|
||||||
char currentDateTime[32] = "-,-";
|
String currentDateTime = getCurrentDateTime();
|
||||||
String dateTimeString = getCurrentDateTime();
|
|
||||||
if (!dateTimeString.isEmpty()) {
|
// Use a placeholder ("-,-") if the date and time could not be retrieved
|
||||||
strncpy(currentDateTime, dateTimeString.c_str(), sizeof(currentDateTime) - 1);
|
if (currentDateTime == "") {
|
||||||
|
currentDateTime = "-,-";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the frequency in a formatted string
|
// Prepare the frequency in a formatted string (e.g., "XX.XX MHz")
|
||||||
int freqInt = (band == BAND_OIRT) ? (int)frequency_OIRT : (int)frequency;
|
int freqInt = (band == BAND_OIRT) ? (int)frequency_OIRT : (int)frequency;
|
||||||
int adjustedFreq = freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0);
|
int adjustedFreq = freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0);
|
||||||
char frequencyFormatted[16];
|
String frequencyFormatted = String(adjustedFreq / 100) + "." +
|
||||||
snprintf(frequencyFormatted, sizeof(frequencyFormatted), "%d.%02d MHz",
|
((adjustedFreq % 100 < 10) ? "0" : "") +
|
||||||
adjustedFreq / 100, adjustedFreq % 100);
|
String(adjustedFreq % 100) + " MHz";
|
||||||
|
|
||||||
// Calculate signal strength based on the selected unit
|
// Calculate signal strength based on the selected unit
|
||||||
int SStatusPrint = 0;
|
int SStatusPrint = 0;
|
||||||
@@ -254,45 +255,39 @@ byte addRowToCSV() {
|
|||||||
else if (unit == 1) SStatusPrint = ((SStatus * 100) + 10875) / 100; // dBf
|
else if (unit == 1) SStatusPrint = ((SStatus * 100) + 10875) / 100; // dBf
|
||||||
else if (unit == 2) SStatusPrint = round((float(SStatus) / 10.0 - 10.0 * log10(75) - 90.0) * 10.0); // dBm
|
else if (unit == 2) SStatusPrint = round((float(SStatus) / 10.0 - 10.0 * log10(75) - 90.0) * 10.0); // dBm
|
||||||
|
|
||||||
char signal[16];
|
// Format the signal strength with appropriate decimal places and unit
|
||||||
snprintf(signal, sizeof(signal), "%d.%d %s",
|
String signal = String(SStatusPrint / 10) + "." + String(abs(SStatusPrint % 10));
|
||||||
SStatusPrint / 10, abs(SStatusPrint % 10),
|
if (unit == 0) signal += " dBμV";
|
||||||
(unit == 0) ? "dBμV" : (unit == 1) ? "dBf" : "dBm");
|
else if (unit == 1) signal += " dBf";
|
||||||
|
else if (unit == 2) signal += " dBm";
|
||||||
|
|
||||||
// Replace commas in the station name to avoid CSV conflicts
|
// Replace commas in the station name and radio text to avoid CSV conflicts
|
||||||
char stationName[64] = "";
|
String stationName = radio.rds.stationName;
|
||||||
strncpy(stationName, radio.rds.stationName.c_str(), sizeof(stationName) - 1);
|
stationName.replace(",", " "); // Replace commas in station name
|
||||||
for (size_t i = 0; i < strlen(stationName); i++) {
|
|
||||||
if (stationName[i] == ',') {
|
|
||||||
stationName[i] = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle ECC, PTY, TA, TP, and Stereo flag
|
// Handle ECC, PTY, TA, TP, and Stereo flag
|
||||||
char ECC[4] = "--";
|
String TA = radio.rds.hasTA ? "•" : " ";
|
||||||
|
String TP = radio.rds.hasTP ? "•" : " ";
|
||||||
|
String Stereo = radio.getStereoStatus() ? "•" : " ";
|
||||||
|
String pty = String(radio.rds.stationTypeCode);
|
||||||
|
String ECC = "--";
|
||||||
if (radio.rds.hasECC) {
|
if (radio.rds.hasECC) {
|
||||||
snprintf(ECC, sizeof(ECC), "%02X", radio.rds.ECC); // Format ECC as uppercase 2-digit hex
|
char eccBuffer[3]; // Buffer to hold 2-digit hex value + null terminator
|
||||||
}
|
snprintf(eccBuffer, sizeof(eccBuffer), "%02X", radio.rds.ECC); // Format ECC as uppercase 2-digit hex
|
||||||
|
ECC = String(eccBuffer);
|
||||||
const char *TA = radio.rds.hasTA ? "•" : " ";
|
|
||||||
const char *TP = radio.rds.hasTP ? "•" : " ";
|
|
||||||
const char *Stereo = radio.getStereoStatus() ? "•" : " ";
|
|
||||||
char pty[4];
|
|
||||||
snprintf(pty, sizeof(pty), "%d", radio.rds.stationTypeCode);
|
|
||||||
|
|
||||||
// Extract the first 4 characters of `picode`
|
|
||||||
char piCode[5] = "0000"; // Initialize with a default value
|
|
||||||
if (strlen(radio.rds.picode) >= 4) {
|
|
||||||
strncpy(piCode, radio.rds.picode, 4); // Copy the first 4 characters
|
|
||||||
piCode[4] = '\0'; // Ensure null termination
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the CSV row data
|
// Construct the CSV row data
|
||||||
char row[256];
|
String row = currentDateTime + "," +
|
||||||
snprintf(row, sizeof(row), "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
|
frequencyFormatted + "," +
|
||||||
currentDateTime, frequencyFormatted, piCode,
|
String(radio.rds.picode) + "," +
|
||||||
signal, Stereo, TA, TP, pty, ECC,
|
signal + "," +
|
||||||
stationName[0] != '\0' ? stationName : "");
|
Stereo + "," +
|
||||||
|
TA + "," +
|
||||||
|
TP + "," +
|
||||||
|
pty + "," +
|
||||||
|
ECC + "," +
|
||||||
|
stationName + "\n";
|
||||||
|
|
||||||
// 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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user