Fix for AFREG and AF detector

This commit is contained in:
Sjef Verhoeven PE5PVB
2023-11-02 20:53:46 +01:00
parent 6afb6b9b2d
commit bb747bdbbd
2 changed files with 6 additions and 7 deletions

View File

@@ -432,6 +432,7 @@ void setup() {
AMLevelOffset = EEPROM.readInt(EE_INT16_AMLEVELOFFSET); AMLevelOffset = EEPROM.readInt(EE_INT16_AMLEVELOFFSET);
unit = EEPROM.readByte(EE_BYTE_UNIT); unit = EEPROM.readByte(EE_BYTE_UNIT);
af = EEPROM.readByte(EE_BYTE_AF); af = EEPROM.readByte(EE_BYTE_AF);
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
StereoToggle = EEPROM.readByte(EE_BYTE_STEREO); StereoToggle = EEPROM.readByte(EE_BYTE_STEREO);
batteryoptions = EEPROM.readByte(EE_BYTE_BATTERY_OPTIONS); batteryoptions = EEPROM.readByte(EE_BYTE_BATTERY_OPTIONS);
amcodect = EEPROM.readByte(EE_BYTE_AM_CO_DECT); amcodect = EEPROM.readByte(EE_BYTE_AM_CO_DECT);
@@ -745,7 +746,6 @@ void loop() {
if (freqold != frequency) { if (freqold != frequency) {
ShowFreq(0); ShowFreq(0);
if (radio.afmethodB) { if (radio.afmethodB) {
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
afmethodBold = true; afmethodBold = true;
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
} }
@@ -762,7 +762,6 @@ void loop() {
if (freqold != frequency) { if (freqold != frequency) {
ShowFreq(0); ShowFreq(0);
if (radio.afmethodB) { if (radio.afmethodB) {
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
afmethodBold = true; afmethodBold = true;
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
} }
@@ -778,7 +777,6 @@ void loop() {
if (freqold != frequency) { if (freqold != frequency) {
ShowFreq(0); ShowFreq(0);
if (radio.afmethodB) { if (radio.afmethodB) {
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
afmethodBold = true; afmethodBold = true;
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
} }
@@ -1884,6 +1882,7 @@ void ModeButtonPress() {
EEPROM.writeByte(EE_BYTE_MWREGION, mwstepsize); EEPROM.writeByte(EE_BYTE_MWREGION, mwstepsize);
EEPROM.writeByte(EE_BYTE_SPISPEED, spispeed); EEPROM.writeByte(EE_BYTE_SPISPEED, spispeed);
EEPROM.commit(); EEPROM.commit();
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
Serial.end(); Serial.end();
if (wifi) remoteip = IPAddress (WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient); if (wifi) remoteip = IPAddress (WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
if (USBmode) Serial.begin(19200); else Serial.begin(115200); if (USBmode) Serial.begin(19200); else Serial.begin(115200);

View File

@@ -32,8 +32,9 @@ void TEF6686::TestAFEON() {
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 4, af[x].frequency); devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 4, af[x].frequency);
delay(200); delay(200);
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr); devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
if (rds.rdsStat & (1 << 9)) { if (rds.rdsStat & (1 << 9)) {
if (((afmethodB && rds.afreg && ((rds.rdsA >> 8) & 0x0F) == (rds.correctPI & 0x0F)) || (!afmethodB && rds.rdsA == rds.correctPI)) && (((rds.rdsErr >> 14) & 0x03) == 0)) { if ((afmethodB && rds.afreg ? (((rds.rdsA >> 8) & 0xF) > 2 && ((rds.correctPI >> 8) & 0xF) > 2 && ((rds.rdsA >> 12) & 0xF) == ((rds.correctPI >> 12) & 0xF) && (rds.rdsA & 0xFF) == (rds.correctPI & 0xFF)) || rds.rdsA == rds.correctPI : rds.rdsA == rds.correctPI)) {
af[x].checked = true; af[x].checked = true;
af[x].afvalid = true; af[x].afvalid = true;
} else { } else {
@@ -98,7 +99,7 @@ uint16_t TEF6686::TestAF() {
delay(200); delay(200);
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr); devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
if (rds.rdsStat & (1 << 9)) { if (rds.rdsStat & (1 << 9)) {
if (((afmethodB && rds.afreg && ((rds.rdsA >> 8) & 0x0F) == (rds.correctPI & 0x0F)) || (!afmethodB && rds.rdsA == rds.correctPI)) && (((rds.rdsErr >> 14) & 0x03) == 0)) { if ((afmethodB && rds.afreg ? (((rds.rdsA >> 8) & 0xF) > 2 && ((rds.correctPI >> 8) & 0xF) > 2 && ((rds.rdsA >> 12) & 0xF) == ((rds.correctPI >> 12) & 0xF) && (rds.rdsA & 0xFF) == (rds.correctPI & 0xFF)) || rds.rdsA == rds.correctPI : rds.rdsA == rds.correctPI)) {
currentfreq = af[highestIndex].frequency; currentfreq = af[highestIndex].frequency;
for (byte y = 0; y < 50; y++) { for (byte y = 0; y < 50; y++) {
af[y].frequency = 0; af[y].frequency = 0;
@@ -1420,8 +1421,7 @@ void TEF6686::readRDS(byte showrdserrors)
} }
} }
void TEF6686::clearRDS (bool fullsearchrds) void TEF6686::clearRDS (bool fullsearchrds) {
{
devTEF_Radio_Set_RDS(fullsearchrds); devTEF_Radio_Set_RDS(fullsearchrds);
rds.stationName = ""; rds.stationName = "";
rds.stationText = ""; rds.stationText = "";