You've already forked TEF6686_ESP32
Added DAB AF
This commit is contained in:
@@ -1197,6 +1197,11 @@ void TEF6686::readRDS(byte showrdserrors)
|
||||
rds.hasRDSplus = true; // Set flag
|
||||
rtplusblock = ((rds.rdsB & 0x1F) >> 1) * 2; // Get RT+ Block
|
||||
}
|
||||
|
||||
if (rds.rdsD == 0x0093) { // Check for DAB+ AF application
|
||||
rds.hasDABAF = true; // Set flag
|
||||
DABAFblock = ((rds.rdsB & 0x1F) >> 1) * 2; // Get RT+ Block
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -1307,6 +1312,27 @@ void TEF6686::readRDS(byte showrdserrors)
|
||||
rds.RTContent2 = extractUTF8Substring(rds.RTContent2, 0, 44, false); // Make sure RT does not exceed 32 characters
|
||||
}
|
||||
if (!rdsBerrorThreshold && rdsblock == 16 && (bitRead(rds.rdsB, 15))) rds.hasTMC = true; // TMC flag
|
||||
|
||||
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && DABAFblock == rdsblock && rds.hasDABAF) {
|
||||
rds.dabaffreq = (rds.rdsC * 16);
|
||||
|
||||
for (size_t i = 0; i < sizeof(DABfrequencyTable) / sizeof(DABfrequencyTable[0]); ++i) {
|
||||
if (DABfrequencyTable[i].frequency == rds.dabaffreq) strcpy(rds.dabafchannel, DABfrequencyTable[i].label);
|
||||
}
|
||||
|
||||
rds.dabafeid[0] = (rds.rdsD >> 12) & 0xF;
|
||||
rds.dabafeid[1] = (rds.rdsD >> 8) & 0xF;
|
||||
rds.dabafeid[2] = (rds.rdsD >> 4) & 0xF;
|
||||
rds.dabafeid[3] = rds.rdsD & 0xF;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (rds.dabafeid[i] < 10) {
|
||||
rds.dabafeid[i] += '0'; // Add ASCII offset for decimal digits
|
||||
} else {
|
||||
rds.dabafeid[i] += 'A' - 10; // Add ASCII offset for hexadecimal letters A-F
|
||||
}
|
||||
}
|
||||
rds.dabafeid[4] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1426,10 +1452,15 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
||||
for (i = 0; i < 6; i++) rds.picode[i] = 0x20;
|
||||
rds.picode[6] = 0;
|
||||
|
||||
for (i = 0; i < 5; i++) rds.dabafeid[i] = 0x20;
|
||||
rds.dabafeid[5] = 0;
|
||||
|
||||
for (i = 0; i < 4; i++) rds.dabafchannel[i] = 0x20;
|
||||
rds.dabafchannel[4] = 0;
|
||||
|
||||
for (i = 0; i < 8; i++) rds.stationID[i] = 0x20;
|
||||
rds.stationID[8] = 0;
|
||||
|
||||
|
||||
for (i = 0; i < 2; i++) rds.stationState[i] = 0x20;
|
||||
rds.stationState[2] = 0;
|
||||
|
||||
@@ -1474,6 +1505,7 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
||||
rds.pinMin = 0;
|
||||
rds.pinDay = 0;
|
||||
rds.stationTypeCode = 32;
|
||||
rds.dabaffreq = 0;
|
||||
rds.hasPIN = false;
|
||||
rds.hasECC = false;
|
||||
rds.hasLIC = false;
|
||||
@@ -1487,6 +1519,7 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
||||
rds.hasTMC = false;
|
||||
rds.hasAID = false;
|
||||
rds.hasRDSplus = false;
|
||||
rds.hasDABAF = false;
|
||||
rt_process = false;
|
||||
ps_process = false;
|
||||
rds.rdsreset = true;
|
||||
|
||||
@@ -524,6 +524,30 @@ static const char* const oda_app_names[] {
|
||||
"RFT+ (work title)"
|
||||
};
|
||||
|
||||
struct DABFrequencyLabel {
|
||||
uint32_t frequency;
|
||||
const char* label;
|
||||
};
|
||||
|
||||
const DABFrequencyLabel DABfrequencyTable[] = {
|
||||
{ 174928, "5A"}, { 176640, "5B"}, { 178352, "5C"}, { 180064, "5D"},
|
||||
{ 181936, "6A"}, { 183648, "6B"}, { 185360, "6C"}, { 187072, "6D"},
|
||||
{ 188928, "7A"}, { 190640, "7B"}, { 192352, "7C"}, { 194064, "7D"},
|
||||
{ 195936, "8A"}, { 197648, "8B"}, { 199360, "8C"}, { 201072, "8D"},
|
||||
{ 202928, "9A"}, { 204640, "9B"}, { 206352, "9C"}, { 208064, "9D"},
|
||||
{ 209936, "10A"}, { 211648, "10B"}, { 213360, "10C"}, { 215072, "10D"},
|
||||
{ 216928, "11A"}, { 218640, "11B"}, { 220352, "11C"}, { 222064, "11D"},
|
||||
{ 223936, "12A"}, { 225648, "12B"}, { 227360, "12C"}, { 229072, "12D"},
|
||||
{ 230784, "13A"}, { 232496, "13B"}, { 234208, "13C"}, { 235776, "13D"},
|
||||
{ 237488, "13E"}, { 239200, "13F"}, {1452960, "LA"}, {1454672, "LB"},
|
||||
{1456384, "LC"}, {1458096, "LD"}, {1459808, "LE"}, {1461520, "LF"},
|
||||
{1463232, "LG"}, {1464944, "LH"}, {1466656, "LI"}, {1468368, "LJ"},
|
||||
{1470080, "LK"}, {1471792, "LL"}, {1473504, "LM"}, {1475216, "LN"},
|
||||
{1476928, "LO"}, {1478640, "LP"}, {1480352, "LQ"}, {1482064, "LR"},
|
||||
{1483776, "LS"}, {1485488, "LT"}, {1487200, "LU"}, {1488912, "LV"},
|
||||
{1490624, "LW"}
|
||||
};
|
||||
|
||||
typedef struct _rds_ {
|
||||
byte region;
|
||||
byte stationTypeCode;
|
||||
@@ -543,8 +567,11 @@ typedef struct _rds_ {
|
||||
char picode[7];
|
||||
char stationID[9];
|
||||
char stationState[3];
|
||||
char dabafeid[5];
|
||||
char dabafchannel[4];
|
||||
uint16_t hour, minute, day, month, year, rdsA, rdsB, rdsC, rdsD, rdsErr, rdsStat, correctPI, rdsplusTag1, rdsplusTag2;
|
||||
uint16_t aid[10];
|
||||
uint32_t dabaffreq;
|
||||
byte aid_counter;
|
||||
int8_t offset;
|
||||
unsigned int ECC;
|
||||
@@ -564,6 +591,7 @@ typedef struct _rds_ {
|
||||
bool hasPIN;
|
||||
bool hasECC;
|
||||
bool hasLIC;
|
||||
bool hasDABAF;
|
||||
bool hasRT;
|
||||
bool hasTP;
|
||||
bool hasTA;
|
||||
@@ -666,7 +694,6 @@ class TEF6686 {
|
||||
uint8_t eon_counter;
|
||||
uint8_t logbook_counter;
|
||||
uint8_t rdsblock;
|
||||
uint8_t rtplusblock;
|
||||
bool mute;
|
||||
bool afmethodB;
|
||||
byte af_updatecounter;
|
||||
@@ -718,5 +745,7 @@ class TEF6686 {
|
||||
uint8_t af_counterbcheck;
|
||||
bool afmethodBtrigger;
|
||||
uint16_t correctPIold;
|
||||
uint8_t rtplusblock;
|
||||
uint8_t DABAFblock;
|
||||
};
|
||||
#endif
|
||||
@@ -356,7 +356,10 @@ void BuildAFScreen() {
|
||||
for (byte i = 0; i < 20; i++) {
|
||||
std::memset(eonpicodeold[i], '\0', sizeof(eonpicodeold[i]));
|
||||
}
|
||||
|
||||
if (radio.rds.hasDABAF && radio.rds.dabaffreq != 0) tftPrint(1, "DAB: " + String(radio.rds.dabafchannel) + " (" + String(radio.rds.dabafeid) + ")", 166, 32, SecondaryColor, SecondaryColorSmooth, 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BuildMenu() {
|
||||
|
||||
Reference in New Issue
Block a user