diff --git a/src/TEF6686.cpp b/src/TEF6686.cpp index 3596ce2..166c244 100644 --- a/src/TEF6686.cpp +++ b/src/TEF6686.cpp @@ -528,9 +528,12 @@ void TEF6686::readRDS(byte showrdserrors) //AF decoder if (rdsblock == 0) { // Only when in GROUP 0A - if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq && !afmethodB) { // Check for AF method B + if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq) { // Check for AF method B afmethodB = true; + afmethodBprobe = true; af_updatecounter++; + } else if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == !currentfreq) { + afmethodBprobe = false; } if (((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) > 224) && ((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 250)) afinit = true; @@ -543,38 +546,48 @@ void TEF6686::readRDS(byte showrdserrors) if ((rds.rdsC & 0xFF) > 0 && (rds.rdsC & 0xFF) < 205) buffer1 = (rds.rdsC & 0xFF) * 10 + 8750; else buffer1 = 0; if (buffer0 != 0 || buffer1 != 0) rds.hasAF = true; - if (buffer1 == currentfreq && buffer0 > buffer1) { - for (int x = 0; x < af_counter; x++) { - if (af[x].frequency == buffer0 && !af[x].regional) { - af[x].regional = true; - af_updatecounter++; - break; + if (afmethodBprobe) { + if (buffer1 == currentfreq && buffer0 > buffer1) { + for (int x = 0; x < af_counter; x++) { + if (af[x].frequency == buffer0 && !af[x].regional) { + if (!af[x].regional) { + af[x].regional = true; + af_updatecounter++; + } + break; + } + } + } else if (buffer1 == currentfreq && buffer0 < buffer1) { + for (int x = 0; x < af_counter; x++) { + if (af[x].frequency == buffer0 && !af[x].mixed) { + if (!af[x].mixed) { + af[x].mixed = true; + af_updatecounter++; + } + break; + } } } - } else if (buffer1 == currentfreq && buffer0 < buffer1) { - for (int x = 0; x < af_counter; x++) { - if (af[x].frequency == buffer0 && !af[x].mixed) { - af[x].mixed = true; - af_updatecounter++; - break; - } - } - } - if (buffer0 == currentfreq && buffer0 > buffer1) { - for (int x = 0; x < af_counter; x++) { - if (af[x].frequency == buffer1 && !af[x].regional) { - af[x].regional = true; - af_updatecounter++; - break; + if (buffer0 == currentfreq && buffer0 > buffer1) { + for (int x = 0; x < af_counter; x++) { + if (af[x].frequency == buffer1 && !af[x].regional) { + if (!af[x].regional) { + af[x].regional = true; + af_updatecounter++; + } + break; + } } - } - } else if (buffer0 == currentfreq && buffer0 < buffer1) { - for (int x = 0; x < af_counter; x++) { - if (af[x].frequency == buffer0 && !af[x].mixed) { - af[x].mixed = true; - af_updatecounter++; - break; + } else if (buffer0 == currentfreq && buffer0 < buffer1) { + for (int x = 0; x < af_counter; x++) { + if (af[x].frequency == buffer0 && !af[x].mixed) { + if (!af[x].mixed) { + af[x].mixed = true; + af_updatecounter++; + } + break; + } } } } @@ -1077,6 +1090,7 @@ void TEF6686::clearRDS (bool fullsearchrds) packet2 = false; packet3 = false; rds.aid_counter = 0; + afmethodBprobe = false; } void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) { diff --git a/src/TEF6686.h b/src/TEF6686.h index 8dd336b..22e12aa 100644 --- a/src/TEF6686.h +++ b/src/TEF6686.h @@ -85,81 +85,81 @@ static const char* const PTY_USA[] { }; static const uint16_t oda_app_ids[] { - 0x0000, 0x0093, 0x0BCB, 0x0C24, 0x0CC1, 0x0D45, 0x0D8B, 0x0E2C, 0x0E31, 0x0F87, - 0x125F, 0x1BDA, 0x1C5E, 0x1C68, 0x1CB1, 0x1D47, 0x1DC2, 0x1DC5, 0x1E8F, 0x4400, - 0x4AA1, 0x4AB7, 0x4BA2, 0x4BD7, 0x4BD8, 0x4C59, 0x4D87, 0x4D95, 0x4D9A, 0x50DD, - 0x5757, 0x6363, 0x6365, 0x6552, 0x6A7A, 0x7373, 0xA112, 0xA911, 0xABCF, 0xC350, - 0xC3A1, 0xC3B0, 0xC3C3, 0xC4D4, 0xC549, 0xC563, 0xC6A7, 0xC737, 0xCB73, 0xCB97, - 0xCC21, 0xCD46, 0xCD47, 0xCD9E, 0xCE6B, 0xE123, 0xE1C1, 0xE319, 0xE411, 0xE440, - 0xE4A6, 0xE5D7, 0xE911, 0xFF7F, 0xFF80 + 0x0000, 0x0093, 0x0BCB, 0x0C24, 0x0CC1, 0x0D45, 0x0D8B, 0x0E2C, 0x0E31, 0x0F87, + 0x125F, 0x1BDA, 0x1C5E, 0x1C68, 0x1CB1, 0x1D47, 0x1DC2, 0x1DC5, 0x1E8F, 0x4400, + 0x4AA1, 0x4AB7, 0x4BA2, 0x4BD7, 0x4BD8, 0x4C59, 0x4D87, 0x4D95, 0x4D9A, 0x50DD, + 0x5757, 0x6363, 0x6365, 0x6552, 0x6A7A, 0x7373, 0xA112, 0xA911, 0xABCF, 0xC350, + 0xC3A1, 0xC3B0, 0xC3C3, 0xC4D4, 0xC549, 0xC563, 0xC6A7, 0xC737, 0xCB73, 0xCB97, + 0xCC21, 0xCD46, 0xCD47, 0xCD9E, 0xCE6B, 0xE123, 0xE1C1, 0xE319, 0xE411, 0xE440, + 0xE4A6, 0xE5D7, 0xE911, 0xFF7F, 0xFF80 }; static const char* const oda_app_names[] { - "None", - "Cross referencing DAB within RDS", - "Leisure & Practical Info for Drivers", - "ELECTRABEL-DSM 7", - "Wireless Playground broadcast control signal", - "RDS-TMC: ALERT-C / EN ISO 14819-1", - "ELECTRABEL-DSM 18", - "ELECTRABEL-DSM 3", - "ELECTRABEL-DSM 13", - "ELECTRABEL-DSM 2", - "I-FM-RDS for fixed and mobile devices", - "ELECTRABEL-DSM 1", - "ELECTRABEL-DSM 20", - "ITIS In-vehicle data base", - "ELECTRABEL-DSM 10", - "ELECTRABEL-DSM 4", - "CITIBUS 4", - "Encrypted TTI using ALERT-Plus", - "ELECTRABEL-DSM 17", - "RDS-Light", - "RASANT", - "ELECTRABEL-DSM 9", - "ELECTRABEL-DSM 5", - "RadioText+ (RT+)", - "RadioText Plus / RT+for eRT", - "CITIBUS 2", - "Radio Commerce System (RCS)", - "ELECTRABEL-DSM 16", - "ELECTRABEL-DSM 11", - "To warn people in case of disasters or emergency", - "Personal weather station", - "Hybradio RDS-Net(for testing use, only)", - "RDS2 – 9 bit AF lists ODA", - "Enhanced RadioText (eRT)", - "Warning receiver", - "Enhanced early warning system", - "NL _ Alert system", - "Data FM Selective Multipoint Messaging", - "RF Power Monitoring", - "NRSC Song Title and Artist", - "Personal Radio Service", - "iTunes Tagging", - "NAVTEQ Traffic Plus", - "eEAS", - "Smart Grid Broadcast Channel", - "ID Logic", - "Veil Enabled Interactive Device", - "Utility Message Channel (UMC)", - "CITIBUS 1", - "ELECTRABEL-DSM 14", - "CITIBUS 3", - "RDS-TMC: ALERT-C", - "RDS-TMC: ALERT-C", - "ELECTRABEL-DSM 8", - "Encrypted TTI using ALERT-Plus", - "APS Gateway", - "Action code", - "ELECTRABEL-DSM 12", - "Beacon downlink", - "ELECTRABEL-DSM 15", - "ELECTRABEL-DSM 19", - "ELECTRABEL-DSM 6", - "EAS open protocol", - "RFT: Station logo", - "RFT+ (work title)" + "None", + "Cross referencing DAB within RDS", + "Leisure & Practical Info for Drivers", + "ELECTRABEL-DSM 7", + "Wireless Playground broadcast control signal", + "RDS-TMC: ALERT-C / EN ISO 14819-1", + "ELECTRABEL-DSM 18", + "ELECTRABEL-DSM 3", + "ELECTRABEL-DSM 13", + "ELECTRABEL-DSM 2", + "I-FM-RDS for fixed and mobile devices", + "ELECTRABEL-DSM 1", + "ELECTRABEL-DSM 20", + "ITIS In-vehicle data base", + "ELECTRABEL-DSM 10", + "ELECTRABEL-DSM 4", + "CITIBUS 4", + "Encrypted TTI using ALERT-Plus", + "ELECTRABEL-DSM 17", + "RDS-Light", + "RASANT", + "ELECTRABEL-DSM 9", + "ELECTRABEL-DSM 5", + "RadioText+ (RT+)", + "RadioText Plus / RT+for eRT", + "CITIBUS 2", + "Radio Commerce System (RCS)", + "ELECTRABEL-DSM 16", + "ELECTRABEL-DSM 11", + "To warn people in case of disasters or emergency", + "Personal weather station", + "Hybradio RDS-Net(for testing use, only)", + "RDS2 – 9 bit AF lists ODA", + "Enhanced RadioText (eRT)", + "Warning receiver", + "Enhanced early warning system", + "NL _ Alert system", + "Data FM Selective Multipoint Messaging", + "RF Power Monitoring", + "NRSC Song Title and Artist", + "Personal Radio Service", + "iTunes Tagging", + "NAVTEQ Traffic Plus", + "eEAS", + "Smart Grid Broadcast Channel", + "ID Logic", + "Veil Enabled Interactive Device", + "Utility Message Channel (UMC)", + "CITIBUS 1", + "ELECTRABEL-DSM 14", + "CITIBUS 3", + "RDS-TMC: ALERT-C", + "RDS-TMC: ALERT-C", + "ELECTRABEL-DSM 8", + "Encrypted TTI using ALERT-Plus", + "APS Gateway", + "Action code", + "ELECTRABEL-DSM 12", + "Beacon downlink", + "ELECTRABEL-DSM 15", + "ELECTRABEL-DSM 19", + "ELECTRABEL-DSM 6", + "EAS open protocol", + "RFT: Station logo", + "RFT+ (work title)" }; typedef struct _rds_ { @@ -342,5 +342,6 @@ class TEF6686 { bool packet1; bool packet2; bool packet3; + bool afmethodBprobe; }; #endif \ No newline at end of file diff --git a/src/gui.cpp b/src/gui.cpp index 6c2906c..c621a74 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -648,7 +648,7 @@ void BuildAdvancedRDS() { tftPrint(-1, "TP", 2, 51, GreyoutColor, BackgroundColor, 16); tftPrint(-1, "TA", 21, 51, GreyoutColor, BackgroundColor, 16); tftPrint(-1, "AF", 42, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(-1, "-R", 60, 51, GreyoutColor, BackgroundColor, 16); + tftPrint(-1, "-B", 60, 51, GreyoutColor, BackgroundColor, 16); tftPrint(-1, "CT", 78, 51, GreyoutColor, BackgroundColor, 16); tftPrint(-1, "TMC", 95, 51, GreyoutColor, BackgroundColor, 16); tftPrint(-1, "RT+", 130, 51, GreyoutColor, BackgroundColor, 16); diff --git a/src/rds.cpp b/src/rds.cpp index 850969d..5b35408 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -56,7 +56,7 @@ void ShowAdvancedRDS() { if (!screenmute) tftPrint(-1, "N/A", 242, 208, BackgroundColor, BackgroundColor, 16); if (!screenmute) tftPrint(-1, LIColdString, 242, 208, BackgroundColor, BackgroundColor, 16); - if (radio.rds.LIC > 0 && radio.rds.LIC < 171) { + if (radio.rds.LIC > 0 && radio.rds.LIC < 128) { if (!screenmute) { if (radio.rds.hasLIC) tftPrint(-1, myLanguages[radio.rds.LIC], 242, 208, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(-1, "N/A", 242, 208, PrimaryColor, PrimaryColorSmooth, 16); } @@ -209,7 +209,7 @@ void ShowAdvancedRDS() { if (afmethodBold != radio.afmethodB || rdsreset) { if (!screenmute) { - if (radio.afmethodB) tftPrint(-1, "-R", 60, 51, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(-1, "-R", 60, 51, GreyoutColor, BackgroundColor, 16); + if (radio.afmethodB) tftPrint(-1, "-B", 60, 51, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(-1, "-B", 60, 51, GreyoutColor, BackgroundColor, 16); } afmethodBold = radio.afmethodB; } @@ -829,12 +829,15 @@ void ShowAFEON() { tft.fillRect(2, 48, 166, 150, BackgroundColor); for (byte i = 0; i < radio.af_counter; i++) { byte x = i - (afpagenr == 2 ? 30 : 0); - if (radio.af[i].checked) { - if (!screenmute) tftPrint(1, ((radio.afmethodB && radio.af[i].regional && radio.af[i].mixed) ? "M " : (radio.afmethodB && radio.af[i].regional && !radio.af[i].mixed ? "R " : "")) + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), InsignificantColor, InsignificantColorSmooth, 16); - } else if (!radio.af[i].afvalid) { - if (!screenmute) tftPrint(1, ((radio.afmethodB && radio.af[i].regional && radio.af[i].mixed) ? "M " : (radio.afmethodB && radio.af[i].regional && !radio.af[i].mixed ? "R " : "")) + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), SignificantColor, SignificantColorSmooth, 16); - } else { - if (!screenmute) tftPrint(1, ((radio.afmethodB && radio.af[i].regional && radio.af[i].mixed) ? "M " : (radio.afmethodB && radio.af[i].regional && !radio.af[i].mixed ? "R " : "")) + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), PrimaryColor, PrimaryColorSmooth, 16); + if (!screenmute) { + tftPrint(-1, ((radio.afmethodB && !radio.af[i].regional && radio.af[i].mixed) ? "S " : (radio.afmethodB && radio.af[i].regional && radio.af[i].mixed) ? "M " : (radio.afmethodB && radio.af[i].regional && !radio.af[i].mixed) ? "R " : ""), 10 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), ActiveColor, ActiveColorSmooth, 16); + if (radio.af[i].checked) { + tftPrint(1, String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), InsignificantColor, InsignificantColorSmooth, 16); + } else if (!radio.af[i].afvalid) { + tftPrint(1, String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), SignificantColor, SignificantColorSmooth, 16); + } else { + tftPrint(1, String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 55 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), PrimaryColor, PrimaryColorSmooth, 16); + } } if (i == 29 + (afpagenr == 2 ? 30 : 0)) i = 254; }