You've already forked TEF6686_ESP32
Undo CSV changes
This commit is contained in:
@@ -3235,13 +3235,13 @@ void ShowFreq(int mode) {
|
||||
case 3:
|
||||
FrequencySprite.fillSprite(BackgroundColor);
|
||||
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;
|
||||
|
||||
case 4:
|
||||
FrequencySprite.fillSprite(BackgroundColor);
|
||||
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;
|
||||
|
||||
case 5:
|
||||
|
||||
@@ -222,7 +222,7 @@ bool handleCreateNewLogbook() {
|
||||
|
||||
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 > 1500) {
|
||||
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
|
||||
}
|
||||
|
||||
// Fetch the current date and time
|
||||
char currentDateTime[32] = "-,-";
|
||||
String dateTimeString = getCurrentDateTime();
|
||||
if (!dateTimeString.isEmpty()) {
|
||||
strncpy(currentDateTime, dateTimeString.c_str(), sizeof(currentDateTime) - 1);
|
||||
// Fetch the current date and time as a string
|
||||
String currentDateTime = getCurrentDateTime();
|
||||
|
||||
// Use a placeholder ("-,-") if the date and time could not be retrieved
|
||||
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 adjustedFreq = freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0);
|
||||
char frequencyFormatted[16];
|
||||
snprintf(frequencyFormatted, sizeof(frequencyFormatted), "%d.%02d MHz",
|
||||
adjustedFreq / 100, adjustedFreq % 100);
|
||||
String frequencyFormatted = String(adjustedFreq / 100) + "." +
|
||||
((adjustedFreq % 100 < 10) ? "0" : "") +
|
||||
String(adjustedFreq % 100) + " MHz";
|
||||
|
||||
// Calculate signal strength based on the selected unit
|
||||
int SStatusPrint = 0;
|
||||
@@ -254,45 +255,39 @@ byte addRowToCSV() {
|
||||
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
|
||||
|
||||
char signal[16];
|
||||
snprintf(signal, sizeof(signal), "%d.%d %s",
|
||||
SStatusPrint / 10, abs(SStatusPrint % 10),
|
||||
(unit == 0) ? "dBμV" : (unit == 1) ? "dBf" : "dBm");
|
||||
// Format the signal strength with appropriate decimal places and unit
|
||||
String signal = String(SStatusPrint / 10) + "." + String(abs(SStatusPrint % 10));
|
||||
if (unit == 0) signal += " dBμV";
|
||||
else if (unit == 1) signal += " dBf";
|
||||
else if (unit == 2) signal += " dBm";
|
||||
|
||||
// Replace commas in the station name to avoid CSV conflicts
|
||||
char stationName[64] = "";
|
||||
strncpy(stationName, radio.rds.stationName.c_str(), sizeof(stationName) - 1);
|
||||
for (size_t i = 0; i < strlen(stationName); i++) {
|
||||
if (stationName[i] == ',') {
|
||||
stationName[i] = ' ';
|
||||
}
|
||||
}
|
||||
// Replace commas in the station name and radio text to avoid CSV conflicts
|
||||
String stationName = radio.rds.stationName;
|
||||
stationName.replace(",", " "); // Replace commas in station name
|
||||
|
||||
// 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) {
|
||||
snprintf(ECC, sizeof(ECC), "%02X", radio.rds.ECC); // Format ECC as uppercase 2-digit hex
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
// Construct the CSV row data
|
||||
char row[256];
|
||||
snprintf(row, sizeof(row), "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
|
||||
currentDateTime, frequencyFormatted, piCode,
|
||||
signal, Stereo, TA, TP, pty, ECC,
|
||||
stationName[0] != '\0' ? stationName : "");
|
||||
String row = currentDateTime + "," +
|
||||
frequencyFormatted + "," +
|
||||
String(radio.rds.picode) + "," +
|
||||
signal + "," +
|
||||
Stereo + "," +
|
||||
TA + "," +
|
||||
TP + "," +
|
||||
pty + "," +
|
||||
ECC + "," +
|
||||
stationName + "\n";
|
||||
|
||||
// Write the row to the file and close it
|
||||
if (file.print(row)) {
|
||||
|
||||
Reference in New Issue
Block a user