Removed RT, added ECC to log
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ const uint8_t FONT16_CHS[] PROGMEM = {
|
|||||||
0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x0E,
|
0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x0E,
|
||||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x01,
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x01,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05,
|
||||||
0x00, 0x00, 0x00, 0x05,/Users/kevin/Documents/GitHub/TEF6686_ESP32/src/FONT28_CHS.h 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08,
|
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08,
|
||||||
0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
|
0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
|
||||||
0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0E,
|
0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0E,
|
||||||
|
|||||||
+26
-33
@@ -205,7 +205,7 @@ bool handleCreateNewLogbook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the header to the new CSV file
|
// Write the header to the new CSV file
|
||||||
String header = "Date,Time,Frequency,PI,Signal,Stereo,TA,TP,PTY,PS,RadioText\n";
|
String header = "Date,Time,Frequency,PI,Signal,Stereo,TA,TP,PTY,ECC,PS\n";
|
||||||
file.print(header); // Ensure that the header is written properly
|
file.print(header); // Ensure that the header is written properly
|
||||||
|
|
||||||
// Make sure the data is written before closing the file
|
// Make sure the data is written before closing the file
|
||||||
@@ -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 || logcounter > 1000) {
|
if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 150) {
|
||||||
return 2; // Return 2 if insufficient free space is available
|
return 2; // Return 2 if insufficient free space is available
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,58 +243,51 @@ byte addRowToCSV() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the frequency in a formatted string (e.g., "XX.XX MHz")
|
// Prepare the frequency in a formatted string (e.g., "XX.XX MHz")
|
||||||
int freqInt;
|
int freqInt = (band == BAND_OIRT) ? (int)frequency_OIRT : (int)frequency;
|
||||||
if (band == BAND_OIRT) freqInt = (int)frequency_OIRT; else freqInt = (int)frequency; // Cast the frequency value to an integer
|
int adjustedFreq = freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0);
|
||||||
int convertedFreq = (freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0)) / 100; // Apply necessary conversion
|
String frequencyFormatted = String(adjustedFreq / 100) + "." +
|
||||||
String frequencyFormatted = String(convertedFreq) + "." +
|
((adjustedFreq % 100 < 10) ? "0" : "") +
|
||||||
((freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0)) % 100 < 10 ? "0" : "") +
|
String(adjustedFreq % 100) + " MHz";
|
||||||
String((freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0)) % 100) + " MHz";
|
|
||||||
|
|
||||||
// Calculate signal strength based on the selected unit
|
// Calculate signal strength based on the selected unit
|
||||||
int SStatusprint = 0;
|
int SStatusPrint = 0;
|
||||||
if (unit == 0) SStatusprint = SStatus; // dBμV
|
if (unit == 0) SStatusPrint = SStatus; // dBμV
|
||||||
if (unit == 1) SStatusprint = ((SStatus * 100) + 10875) / 100; // dBf
|
else if (unit == 1) SStatusPrint = ((SStatus * 100) + 10875) / 100; // dBf
|
||||||
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
|
||||||
|
|
||||||
// Format the signal strength with appropriate decimal places and unit
|
// Format the signal strength with appropriate decimal places and unit
|
||||||
String signal = String(SStatusprint / 10) + "." + String(abs(SStatusprint % 10));
|
String signal = String(SStatusPrint / 10) + "." + String(abs(SStatusPrint % 10));
|
||||||
if (unit == 0) signal += " dBμV";
|
if (unit == 0) signal += " dBμV";
|
||||||
else if (unit == 1) signal += " dBf";
|
else if (unit == 1) signal += " dBf";
|
||||||
else if (unit == 2) signal += " dBm";
|
else if (unit == 2) signal += " dBm";
|
||||||
|
|
||||||
// Prepare the radio text with station information, including enhanced options if available
|
|
||||||
String radioText = String(radio.rds.stationText + " " + radio.rds.stationText32);
|
|
||||||
if (radio.rds.hasEnhancedRT) {
|
|
||||||
radioText += " eRT: " + String(radio.rds.enhancedRTtext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace commas in the station name and radio text to avoid CSV conflicts
|
// Replace commas in the station name and radio text to avoid CSV conflicts
|
||||||
String stationName = radio.rds.stationName;
|
String stationName = radio.rds.stationName;
|
||||||
String radioTextModified = radioText;
|
|
||||||
stationName.replace(",", " "); // Replace commas in station name
|
stationName.replace(",", " "); // Replace commas in station name
|
||||||
radioTextModified.replace(",", " "); // Replace commas in radio text
|
|
||||||
|
|
||||||
// Handle PTY, TA, TP and Stereo flag
|
// Handle ECC, PTY, TA, TP, and Stereo flag
|
||||||
String TA;
|
String TA = radio.rds.hasTA ? "•" : " ";
|
||||||
String TP;
|
String TP = radio.rds.hasTP ? "•" : " ";
|
||||||
String Stereo;
|
String Stereo = radio.getStereoStatus() ? "•" : " ";
|
||||||
String pty;
|
String pty = String(radio.rds.stationTypeCode);
|
||||||
if (radio.rds.hasTA) TA = "•"; else TA = "";
|
String ECC = "--";
|
||||||
if (radio.rds.hasTP) TP = "•"; else TP = "";
|
if (radio.rds.hasECC) {
|
||||||
if (radio.getStereoStatus()) Stereo = "•"; else Stereo = "";
|
char eccBuffer[3]; // Buffer to hold 2-digit hex value + null terminator
|
||||||
pty = String(radio.rds.stationTypeCode);
|
snprintf(eccBuffer, sizeof(eccBuffer), "%02X", radio.rds.ECC); // Format ECC as uppercase 2-digit hex
|
||||||
|
ECC = String(eccBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
// Construct the CSV row data
|
// Construct the CSV row data
|
||||||
String row = currentDateTime + "," +
|
String row = currentDateTime + "," +
|
||||||
frequencyFormatted + "," +
|
frequencyFormatted + "," +
|
||||||
radio.rds.picode + "," +
|
String(radio.rds.picode) + "," +
|
||||||
signal + "," +
|
signal + "," +
|
||||||
Stereo + "," +
|
Stereo + "," +
|
||||||
TA + "," +
|
TA + "," +
|
||||||
TP + "," +
|
TP + "," +
|
||||||
pty + "," +
|
pty + "," +
|
||||||
stationName + "," +
|
ECC + "," +
|
||||||
radioTextModified + "\n";
|
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