RDS code cleanup

This commit is contained in:
Sjef Verhoeven PE5PVB
2023-10-17 22:36:05 +02:00
parent 7166fd3ce2
commit 4fe5a936eb
3 changed files with 67 additions and 75 deletions
+16 -24
View File
@@ -528,8 +528,8 @@ void TEF6686::readRDS(byte showrdserrors)
//AF decoder
if (rdsblock == 0 && rds.rdsC != rdsCold) { // Only when in GROUP 0A
if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq) { // Check for AF method B
afmethodB = true;
if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq) {
afmethodB = true; // Check for AF method B
afmethodBprobe = true;
af_updatecounter++;
af_counterb = (rds.rdsC >> 8) - 224;
@@ -560,20 +560,16 @@ void TEF6686::readRDS(byte showrdserrors)
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;
if (af[x].frequency == buffer0 && !af[x].same) {
af[x].same = true;
af_updatecounter++;
}
break;
}
}
@@ -582,32 +578,28 @@ void TEF6686::readRDS(byte showrdserrors)
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 == buffer1 && !af[x].mixed) {
if (!af[x].mixed) {
af[x].mixed = true;
if (af[x].frequency == buffer1 && !af[x].same) {
af[x].same = true;
af_updatecounter++;
}
break;
}
}
}
}
if (buffer0 != currentfreq && buffer1 != currentfreq && afmethodB && afmethodBprobe) { // Remove faulty Reg. flags
afmethodBprobe = false;
if (buffer0 != currentfreq && buffer1 != currentfreq && afmethodB && afmethodBprobe) {
afmethodBprobe = false; // Remove faulty Reg. flags
for (int x = 0; x < af_counter; x++) {
if (af[x].frequency == buffer0 || af[x].frequency == buffer1) {
if (af[x].mixed) {
af[x].mixed = false;
if (af[x].same) {
af[x].same = false;
af_updatecounter++;
}
if (af[x].regional) {
@@ -657,17 +649,17 @@ void TEF6686::readRDS(byte showrdserrors)
bool temp3 = af[j].afvalid;
bool temp4 = af[j].checked;
bool temp5 = af[j].regional;
bool temp6 = af[j].mixed;
bool temp6 = af[j].same;
af[j].frequency = af[j + 1].frequency;
af[j].afvalid = af[j + 1].afvalid;
af[j].checked = af[j + 1].checked;
af[j].regional = af[j + 1].regional;
af[j].mixed = af[j + 1].mixed;
af[j].same = af[j + 1].same;
af[j + 1].frequency = temp;
af[j + 1].afvalid = temp3;
af[j + 1].checked = temp4;
af[j + 1].regional = temp5;
af[j + 1].mixed = temp6;
af[j + 1].same = temp6;
}
}
}
@@ -874,8 +866,8 @@ void TEF6686::readRDS(byte showrdserrors)
case RDS_GROUP_12A:
case RDS_GROUP_13A: {
// RT+ decoding
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && rtplusblock == rdsblock && rds.hasRDSplus) { // Are we in the right RT+ block and is all ok to go?
rds.rdsplusTag1 = ((rds.rdsB & 0x07) << 3) + (rds.rdsC >> 13);
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && rtplusblock == rdsblock && rds.hasRDSplus) {
rds.rdsplusTag1 = ((rds.rdsB & 0x07) << 3) + (rds.rdsC >> 13); // Are we in the right RT+ block and is all ok to go?
rds.rdsplusTag2 = ((rds.rdsC & 0x01) << 5) + (rds.rdsD >> 11);
uint16_t start_marker_1 = (rds.rdsC >> 7) & 0x3F;
uint16_t length_marker_1 = (rds.rdsC >> 1) & 0x3F;
@@ -1042,7 +1034,7 @@ void TEF6686::clearRDS (bool fullsearchrds)
af[i].afvalid = true;
af[i].checked = false;
af[i].regional = false;
af[i].mixed = false;
af[i].same = false;
}
for (i = 0; i < 20; i++) {
+1 -1
View File
@@ -583,7 +583,7 @@ typedef struct _af_ {
bool afvalid;
bool checked;
bool regional;
bool mixed;
bool same;
} af_;
typedef struct _eon_ {
+1 -1
View File
@@ -830,7 +830,7 @@ void ShowAFEON() {
for (byte i = 0; i < radio.af_counter; i++) {
byte x = i - (afpagenr == 2 ? 30 : 0);
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);
tftPrint(-1, (radio.afmethodB && !radio.af[i].regional && radio.af[i].same) ? "S " : (radio.afmethodB && radio.af[i].regional && radio.af[i].same) ? "M " : (radio.afmethodB && radio.af[i].regional && !radio.af[i].same) ? "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) {