From 7e3b9b72a7ed649bf70254753645e2834ac8c5bf Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Wed, 6 Sep 2023 16:31:31 +0200 Subject: [PATCH] Added check for AF method B --- src/TEF6686.cpp | 20 +++++++++++++++++--- src/TEF6686.h | 2 ++ src/rds.cpp | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/TEF6686.cpp b/src/TEF6686.cpp index 9dcf5e6..38242d4 100644 --- a/src/TEF6686.cpp +++ b/src/TEF6686.cpp @@ -529,6 +529,12 @@ void TEF6686::readRDS(byte showrdserrors) if (!rdsCerrorThreshold) { //AF decoder if (rdsblock == 0) { // Only when in GROUP 0A + + if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250) { + if (afmethodcounter > 2) afmethodB == true; + afmethodcounter = 0; + } + if (((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) > 224) && ((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 250)) afinit = true; if (afinit) { if ((rds.rdsB >> 11) == 0 && af_counter < 50) { @@ -549,7 +555,10 @@ void TEF6686::readRDS(byte showrdserrors) if (!isValuePresent) { af[af_counter].frequency = buffer0; - if (buffer1 == currentfreq && buffer0 > buffer1) af[af_counter].regional = true; + if (buffer1 == currentfreq && buffer0 > buffer1) { + af[af_counter].regional = true; + afmethodcounter++; + } if (af_counter < 50) af_counter++; } @@ -563,7 +572,10 @@ void TEF6686::readRDS(byte showrdserrors) if (!isValuePresent) { af[af_counter].frequency = buffer1; - if (buffer0 == currentfreq && buffer0 < buffer1) af[af_counter].regional = true; + if (buffer0 == currentfreq && buffer0 < buffer1) { + af[af_counter].regional = true; + afmethodcounter++; + } if (af_counter < 50) af_counter++; } @@ -602,7 +614,7 @@ void TEF6686::readRDS(byte showrdserrors) rds.hasECC = true; } - if (rds.rdsC >> 12 == 3) { // ECC code readout + if (rds.rdsC >> 12 == 3) { // LIC code readout rds.LIC = rds.rdsC & 0xff; rds.hasLIC = true; } @@ -980,6 +992,8 @@ void TEF6686::clearRDS (bool fullsearchrds) rds.rdsplusTag2 = 169; afinit = false; errorfreepi = false; + afmethodB = false; + afmethodcounter = 0; } void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) { diff --git a/src/TEF6686.h b/src/TEF6686.h index 6874406..40955df 100644 --- a/src/TEF6686.h +++ b/src/TEF6686.h @@ -256,6 +256,7 @@ class TEF6686 { uint8_t rdsblock; uint8_t rtplusblock; bool mute; + bool afmethodB; private: void RDScharConverter(const char* input, wchar_t* output, size_t size, bool under); @@ -297,6 +298,7 @@ class TEF6686 { bool rdsBerrorThreshold; bool rdsCerrorThreshold; bool rdsDerrorThreshold; + byte afmethodcounter; }; #endif \ No newline at end of file diff --git a/src/rds.cpp b/src/rds.cpp index 17427f5..e685b44 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -809,11 +809,11 @@ void ShowAFEON() { 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.af[i].regional ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), InsignificantColor, InsignificantColorSmooth, 16); + if (!screenmute) tftPrint(1, (radio.af[i].regional && radio.afmethodB ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (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.af[i].regional ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (x > 9 ? 54 : 0) + (x > 19 ? 54 : 0), 48 + (15 * x) - (x > 9 ? 150 : 0) - (x > 19 ? 150 : 0), SignificantColor, SignificantColorSmooth, 16); + if (!screenmute) tftPrint(1, (radio.af[i].regional && radio.afmethodB ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (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.af[i].regional ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (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.af[i].regional && radio.afmethodB ? "R " : "") + String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10), 50 + (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; }