Added coaxswitch via GPIO0 (XDRGTK)

Optimised XDRGTK parsing
Fix problem where PS/PTY/PI sometimes turned blue on correct RDS when switching from Adv. RDS to normal screen
This commit is contained in:
Sjef Verhoeven PE5PVB
2024-02-12 23:17:46 +01:00
parent 388231a4b4
commit 2a3e8d7197
7 changed files with 34 additions and 20 deletions
-1
View File
@@ -2531,7 +2531,6 @@ void ShowFreq(int mode) {
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE); attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE);
rdsreset = true; rdsreset = true;
RDSstatus = false;
licold = 254; licold = 254;
ECCold = 253; ECCold = 253;
afmethodBold = false; afmethodBold = false;
+5
View File
@@ -158,6 +158,11 @@ bool TEF6686::getIdentification(uint16_t &device, uint16_t &hw_version, uint16_t
return sw_version; return sw_version;
} }
void TEF6686::setCoax(uint8_t mode) {
devTEF_Radio_Set_GPIO(mode);
}
void TEF6686::power(bool mode) { void TEF6686::power(bool mode) {
devTEF_APPL_Set_OperationMode(mode); devTEF_APPL_Set_OperationMode(mode);
if (mode == 0) devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 1, 10000); if (mode == 0) devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 1, 10000);
+1
View File
@@ -670,6 +670,7 @@ class TEF6686 {
void setSoftmuteAM(uint8_t mode); void setSoftmuteAM(uint8_t mode);
void setMono(bool mono); void setMono(bool mono);
bool getStereoStatus(); bool getStereoStatus();
void setCoax(uint8_t mode);
void init(byte TEF); void init(byte TEF);
void clearRDS(bool fullsearchrds); void clearRDS(bool fullsearchrds);
void power(bool mode); void power(bool mode);
+8
View File
@@ -298,3 +298,11 @@ bool devTEF_Radio_Set_I2S_Input(bool mode) {
return devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Input, 5, 0); return devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Input, 5, 0);
} }
} }
bool devTEF_Radio_Set_GPIO(uint8_t mode) {
if (mode == 0) return devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 33, 2);
if (mode == 1) return devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 33, 3);
if (mode == 2) return devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 32, 2);
if (mode == 3) return devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 32, 3);
}
+2 -1
View File
@@ -56,6 +56,7 @@ typedef enum {
typedef enum { typedef enum {
Cmd_Set_OperationMode = 1, Cmd_Set_OperationMode = 1,
Cmd_Set_GPIO = 3,
Cmd_Get_Operation_Status = 128, Cmd_Get_Operation_Status = 128,
Cmd_Get_Identification = 130 Cmd_Get_Identification = 130
} TEF_APPL_COMMAND; } TEF_APPL_COMMAND;
@@ -108,5 +109,5 @@ bool devTEF_Radio_Set_StHiBlend_Mph(uint8_t mode, uint16_t start, uint16_t slope
bool devTEF_Radio_Set_NoisBlanker(uint8_t mode, uint16_t start); bool devTEF_Radio_Set_NoisBlanker(uint8_t mode, uint16_t start);
bool devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq); bool devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
bool devTEF_Radio_Set_I2S_Input(bool mode); bool devTEF_Radio_Set_I2S_Input(bool mode);
bool devTEF_Radio_Set_GPIO(uint8_t mode);
#endif #endif
+15 -17
View File
@@ -189,30 +189,29 @@ void Communication() {
void XDRGTKRoutine() { void XDRGTKRoutine() {
if (XDRGTKUSB) { if (XDRGTKUSB) {
if (Serial.available()) while (Serial.available() > 0) {
{ char c = Serial.read();
buff[buff_pos] = Serial.read(); if (buff_pos < 16 && c != '\n') {
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1) buff[buff_pos++] = c;
{
buff_pos++;
} else { } else {
buff[buff_pos] = 0; buff[buff_pos] = '\0';
buff_pos = 0; buff_pos = 0;
XDRGTKdata = true; XDRGTKdata = true;
break;
} }
} }
} }
if (XDRGTKTCP) { if (XDRGTKTCP && RemoteClient.available() > 0) {
if (RemoteClient.available() > 0) { while (RemoteClient.available() > 0) {
buff[buff_pos] = RemoteClient.read(); char c = RemoteClient.read();
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1) if (buff_pos < 16 && c != '\n') {
{ buff[buff_pos++] = c;
buff_pos++;
} else { } else {
buff[buff_pos] = 0; buff[buff_pos] = '\0';
buff_pos = 0; buff_pos = 0;
XDRGTKdata = true; XDRGTKdata = true;
break;
} }
} }
} }
@@ -393,7 +392,6 @@ void XDRGTKRoutine() {
radio.SetFreq(frequency); radio.SetFreq(frequency);
} }
if (band == BAND_FM) DataPrint("T" + String((frequency + ConverterSet * 100) * 10) + "\n"); else DataPrint("T" + String(frequency_AM) + "\n"); if (band == BAND_FM) DataPrint("T" + String((frequency + ConverterSet * 100) * 10) + "\n"); else DataPrint("T" + String(frequency_AM) + "\n");
ShowFreq(0); ShowFreq(0);
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
RDSstatus = false; RDSstatus = false;
@@ -528,11 +526,11 @@ void XDRGTKRoutine() {
ANT = atol(buff + 1); ANT = atol(buff + 1);
switch (ANT) { switch (ANT) {
case 0: case 0:
// Antenna A if (BAND_FM || BAND_OIRT) radio.setCoax(2); else radio.setCoax(0);
break; break;
case 1: case 1:
// Antenna B if (BAND_FM || BAND_OIRT) radio.setCoax(3); else radio.setCoax(1);
break; break;
case 2: case 2:
+3 -1
View File
@@ -448,7 +448,7 @@ void readRds() {
void ShowErrors() { void ShowErrors() {
uint8_t calc = 4; uint8_t calc = 4;
if (RDSstatus) { if (RDSstatus && !rdsreset) {
if (!radio.rds.rdsAerror) calc--; if (!radio.rds.rdsAerror) calc--;
if (!radio.rds.rdsBerror) calc--; if (!radio.rds.rdsBerror) calc--;
if (!radio.rds.rdsCerror) calc--; if (!radio.rds.rdsCerror) calc--;
@@ -458,6 +458,8 @@ void ShowErrors() {
calc = SAvg3 / 10; calc = SAvg3 / 10;
} }
rdsreset = false;
if (calc != rdsqualityold || BWreset) { if (calc != rdsqualityold || BWreset) {
switch (calc) { switch (calc) {
case 0: case 0: