You've already forked TEF6686_ESP32
Improved EON PS decoding
This commit is contained in:
@@ -1436,13 +1436,16 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
|
|
||||||
case RDS_GROUP_14A: {
|
case RDS_GROUP_14A: {
|
||||||
// EON
|
// EON
|
||||||
if (!rdsDerrorThreshold) {
|
if (!rdsAerrorThreshold && !rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) {
|
||||||
rds.hasEON = true; // Group is there, so we have EON
|
rds.hasEON = true; // Group is there, so we have EON
|
||||||
|
|
||||||
bool isValuePresent = false;
|
bool isValuePresent = false;
|
||||||
for (int i = 0; i < 20; i++) {
|
int eonIndex = -1;
|
||||||
|
int i = 0;
|
||||||
|
for (; i < 20; i++) {
|
||||||
if (eon[i].pi == rds.rdsD || rds.rdsA == rds.rdsD) { // Check if EON is already in array
|
if (eon[i].pi == rds.rdsD || rds.rdsA == rds.rdsD) { // Check if EON is already in array
|
||||||
isValuePresent = true;
|
isValuePresent = true;
|
||||||
|
eonIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1452,60 +1455,61 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
eon[eon_counter].picode[1] = (rds.rdsD >> 8) & 0xF;
|
eon[eon_counter].picode[1] = (rds.rdsD >> 8) & 0xF;
|
||||||
eon[eon_counter].picode[2] = (rds.rdsD >> 4) & 0xF;
|
eon[eon_counter].picode[2] = (rds.rdsD >> 4) & 0xF;
|
||||||
eon[eon_counter].picode[3] = rds.rdsD & 0xF;
|
eon[eon_counter].picode[3] = rds.rdsD & 0xF;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
if (eon[eon_counter].picode[i] < 10) {
|
if (eon[eon_counter].picode[j] < 10) {
|
||||||
eon[eon_counter].picode[i] += '0'; // Add ASCII offset for decimal digits
|
eon[eon_counter].picode[j] += '0'; // Add ASCII offset for decimal digits
|
||||||
} else {
|
} else {
|
||||||
eon[eon_counter].picode[i] += 'A' - 10; // Add ASCII offset for hexadecimal letters A-F
|
eon[eon_counter].picode[j] += 'A' - 10; // Add ASCII offset for hexadecimal letters A-F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eon[eon_counter].pi = rds.rdsD; // Store PI on next array
|
eon[eon_counter].pi = rds.rdsD; // Store PI on next array
|
||||||
if (eon_counter < 20) eon_counter++;
|
if (eon_counter < 20) eon_counter++;
|
||||||
|
eonIndex = eon_counter - 1;
|
||||||
|
} else {
|
||||||
|
eonIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = rds.rdsB & 0x0F; // Read offset
|
offset = rds.rdsB & 0x0F; // Read offset
|
||||||
|
|
||||||
byte position;
|
if (offset < 4 && eon[eonIndex].pi == rds.rdsD) {
|
||||||
for (position = 0; position < 20; position++) {
|
for (int j = 0; j < 9; j++) EONPStext[eonIndex][j] = '\0'; // Clear buffer
|
||||||
if (eon[position].pi == rds.rdsD) { // Find position in array
|
eon_buffer[eonIndex][(offset * 2) + 0] = rds.rdsC >> 8; // First character of segment
|
||||||
break;
|
eon_buffer[eonIndex][(offset * 2) + 1] = rds.rdsC & 0xFF; // Second character of segment
|
||||||
}
|
eon_buffer[eonIndex][(offset * 2) + 2] = '\0'; // Endmarker of segment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset == 0) eon[eonIndex].packet0 = true;
|
||||||
|
if (offset == 1) eon[eonIndex].packet1 = true;
|
||||||
|
if (offset == 2) eon[eonIndex].packet2 = true;
|
||||||
|
if (offset == 3) eon[eonIndex].packet3 = true;
|
||||||
|
|
||||||
if (offset < 4 && eon[position].pi == rds.rdsD) {
|
if (eon[eonIndex].packet0 && eon[eonIndex].packet1 && eon[eonIndex].packet2 && eon[eonIndex].packet3 && eon[eonIndex].pi == rds.rdsD) { // Last chars are received
|
||||||
for (int j = 0; j < 9; j++) EONPStext[position][j] = '\0'; // Clear buffer
|
RDScharConverter(eon_buffer[eonIndex], EONPStext[eonIndex], sizeof(EONPStext[eonIndex]) / sizeof(wchar_t), false); // Convert 8 bit ASCII to 16 bit ASCII
|
||||||
eon_buffer[position][(offset * 2) + 0] = rds.rdsC >> 8; // First character of segment
|
String utf8String = convertToUTF8(EONPStext[eonIndex]); // Convert RDS characterset to ASCII
|
||||||
eon_buffer[position][(offset * 2) + 1] = rds.rdsC & 0xFF; // Second character of segment
|
eon[eonIndex].ps = extractUTF8Substring(utf8String, 0, 8, false); // Make sure PS does not exceed 8 characters
|
||||||
eon_buffer[position][(offset * 2) + 2] = '\0'; // Endmarker of segment
|
eon[eonIndex].packet0 = false;
|
||||||
|
eon[eonIndex].packet1 = false;
|
||||||
|
eon[eonIndex].packet2 = false;
|
||||||
|
eon[eonIndex].packet3 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > 3 && eon[position].pi == rds.rdsD) { // Last chars are received
|
if (offset == 13 && eon[eonIndex].pi == rds.rdsD) {
|
||||||
RDScharConverter(eon_buffer[position], EONPStext[position], sizeof(EONPStext[position]) / sizeof(wchar_t), false); // Convert 8 bit ASCII to 16 bit ASCII
|
eon[eonIndex].taset = true;
|
||||||
String utf8String = convertToUTF8(EONPStext[position]); // Convert RDS characterset to ASCII
|
eon[eonIndex].ta = bitRead(rds.rdsC, 0);
|
||||||
eon[position].ps = extractUTF8Substring(utf8String, 0, 8, false); // Make sure PS does not exceed 8 characters
|
eon[eonIndex].pty = (rds.rdsC >> 11) & 0xF;
|
||||||
for (int j = 0; j < 9; j++) eon_buffer[position][j] = '\0'; // Clear buffer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset == 13 && eon[position].pi == rds.rdsD) {
|
if (bitRead(rds.rdsB, 4) && eon[eonIndex].pi == rds.rdsD) eon[eonIndex].tp = true;
|
||||||
eon[position].taset = true;
|
|
||||||
eon[position].ta = bitRead(rds.rdsC, 0);
|
|
||||||
eon[position].pty = (rds.rdsC >> 11) & 0xF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitRead(rds.rdsB, 4) && eon[position].pi == rds.rdsD) eon[position].tp = true;
|
if (offset > 4 && offset < 9 && eon[eonIndex].pi == rds.rdsD) { // Check if mapped frequency belongs to current frequency
|
||||||
|
|
||||||
if (offset > 4 && offset < 9 && eon[position].pi == rds.rdsD) { // Check if mapped frequency belongs to current frequency
|
|
||||||
if (((rds.rdsC >> 8) * 10 + 8750) == currentfreq && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
if (((rds.rdsC >> 8) * 10 + 8750) == currentfreq && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
||||||
if (eon[position].mappedfreq == 0) {
|
if (eon[eonIndex].mappedfreq == 0) {
|
||||||
eon[position].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array
|
eon[eonIndex].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array
|
||||||
} else {
|
} else if (eon[eonIndex].mappedfreq2 == 0 && eon[eonIndex].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
||||||
if (eon[position].mappedfreq2 == 0 && eon[position].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
eon[eonIndex].mappedfreq2 = ((rds.rdsC & 0xFF) * 10 + 8750);
|
||||||
eon[position].mappedfreq2 = ((rds.rdsC & 0xFF) * 10 + 8750);
|
} else if (eon[eonIndex].mappedfreq3 == 0 && eon[eonIndex].mappedfreq2 != ((rds.rdsC & 0xFF) * 10 + 8750) && eon[eonIndex].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
||||||
} else if (eon[position].mappedfreq2 != ((rds.rdsC & 0xFF) * 10 + 8750) && eon[position].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
|
eon[eonIndex].mappedfreq3 = ((rds.rdsC & 0xFF) * 10 + 8750);
|
||||||
if (eon[position].mappedfreq3 == 0) eon[position].mappedfreq3 = ((rds.rdsC & 0xFF) * 10 + 8750);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1575,7 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
RDScharConverter(pslong_buffer, PSLongtext, sizeof(PSLongtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII
|
RDScharConverter(pslong_buffer, PSLongtext, sizeof(PSLongtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII
|
||||||
String utf8String = convertToUTF8(PSLongtext); // Convert RDS characterset to ASCII
|
String utf8String = convertToUTF8(PSLongtext); // Convert RDS characterset to ASCII
|
||||||
rds.stationNameLong = extractUTF8Substring(utf8String, 0, endmarkerLPS, true); // Make sure PS Long does not exceed 32 characters
|
rds.stationNameLong = extractUTF8Substring(utf8String, 0, endmarkerLPS, true); // Make sure PS Long does not exceed 32 characters
|
||||||
rds.stationNameLong = trimTrailingSpaces(rds.stationNameLong);
|
rds.stationNameLong = trimTrailingSpaces(rds.stationNameLong);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -644,6 +644,7 @@ typedef struct _eon_ {
|
|||||||
bool tp;
|
bool tp;
|
||||||
bool taset;
|
bool taset;
|
||||||
uint8_t pty;
|
uint8_t pty;
|
||||||
|
bool packet0, packet1, packet2, packet3;
|
||||||
} eon_;
|
} eon_;
|
||||||
|
|
||||||
typedef struct _logbook_ {
|
typedef struct _logbook_ {
|
||||||
|
|||||||
20
src/rds.cpp
20
src/rds.cpp
@@ -60,11 +60,11 @@ void ShowAdvancedRDS() {
|
|||||||
|
|
||||||
if (licold != radio.rds.LIC || rdsreset) {
|
if (licold != radio.rds.LIC || rdsreset) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.hasLIC) LICString = (radio.rds.LICtext.length() == 0 ? myLanguage[language][73] : radio.rds.LICtext); else LICString = "N/A";
|
if (radio.rds.hasLIC) LICString = (radio.rds.LICtext.length() == 0 ? myLanguage[language][73] : radio.rds.LICtext); else LICString = "N/A";
|
||||||
if (LICString != LIColdString) {
|
if (LICString != LIColdString) {
|
||||||
tftPrint(-1, "N/A", 242, 208, BackgroundColor, BackgroundColor, 16);
|
tftPrint(-1, "N/A", 242, 208, BackgroundColor, BackgroundColor, 16);
|
||||||
tftPrint(-1, LIColdString, 242, 208, BackgroundColor, BackgroundColor, 16);
|
tftPrint(-1, LIColdString, 242, 208, BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
tftPrint(-1, LICString, 242, 208, RDSColor, RDSColorSmooth, 16);
|
tftPrint(-1, LICString, 242, 208, RDSColor, RDSColorSmooth, 16);
|
||||||
LIColdString = LICString;
|
LIColdString = LICString;
|
||||||
licold = radio.rds.LIC;
|
licold = radio.rds.LIC;
|
||||||
@@ -290,11 +290,11 @@ void showECC() {
|
|||||||
if (ECCold != radio.rds.ECC) {
|
if (ECCold != radio.rds.ECC) {
|
||||||
if (advancedRDS) {
|
if (advancedRDS) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? myLanguage[language][73] : radio.rds.ECCtext); else ECCString = "N/A";
|
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? myLanguage[language][73] : radio.rds.ECCtext); else ECCString = "N/A";
|
||||||
if (ECCString != ECColdString) {
|
if (ECCString != ECColdString) {
|
||||||
tftPrint(-1, "N/A", 242, 193, BackgroundColor, BackgroundColor, 16);
|
tftPrint(-1, "N/A", 242, 193, BackgroundColor, BackgroundColor, 16);
|
||||||
tftPrint(-1, ECColdString, 242, 193, BackgroundColor, BackgroundColor, 16);
|
tftPrint(-1, ECColdString, 242, 193, BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
tftPrint(-1, ECCString, 242, 193, RDSColor, RDSColorSmooth, 16);
|
tftPrint(-1, ECCString, 242, 193, RDSColor, RDSColorSmooth, 16);
|
||||||
}
|
}
|
||||||
ECColdString = ECCString;
|
ECColdString = ECCString;
|
||||||
|
|||||||
Reference in New Issue
Block a user