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

View File

@@ -2531,7 +2531,6 @@ void ShowFreq(int mode) {
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE);
rdsreset = true;
RDSstatus = false;
licold = 254;
ECCold = 253;
afmethodBold = false;

View File

@@ -158,6 +158,11 @@ bool TEF6686::getIdentification(uint16_t &device, uint16_t &hw_version, uint16_t
return sw_version;
}
void TEF6686::setCoax(uint8_t mode) {
devTEF_Radio_Set_GPIO(mode);
}
void TEF6686::power(bool mode) {
devTEF_APPL_Set_OperationMode(mode);
if (mode == 0) devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 1, 10000);

View File

@@ -670,6 +670,7 @@ class TEF6686 {
void setSoftmuteAM(uint8_t mode);
void setMono(bool mono);
bool getStereoStatus();
void setCoax(uint8_t mode);
void init(byte TEF);
void clearRDS(bool fullsearchrds);
void power(bool mode);

View File

@@ -297,4 +297,12 @@ bool devTEF_Radio_Set_I2S_Input(bool mode) {
} else {
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);
}

View File

@@ -56,6 +56,7 @@ typedef enum {
typedef enum {
Cmd_Set_OperationMode = 1,
Cmd_Set_GPIO = 3,
Cmd_Get_Operation_Status = 128,
Cmd_Get_Identification = 130
} 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_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
bool devTEF_Radio_Set_I2S_Input(bool mode);
bool devTEF_Radio_Set_GPIO(uint8_t mode);
#endif

View File

@@ -189,30 +189,29 @@ void Communication() {
void XDRGTKRoutine() {
if (XDRGTKUSB) {
if (Serial.available())
{
buff[buff_pos] = Serial.read();
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1)
{
buff_pos++;
while (Serial.available() > 0) {
char c = Serial.read();
if (buff_pos < 16 && c != '\n') {
buff[buff_pos++] = c;
} else {
buff[buff_pos] = 0;
buff[buff_pos] = '\0';
buff_pos = 0;
XDRGTKdata = true;
break;
}
}
}
if (XDRGTKTCP) {
if (RemoteClient.available() > 0) {
buff[buff_pos] = RemoteClient.read();
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1)
{
buff_pos++;
if (XDRGTKTCP && RemoteClient.available() > 0) {
while (RemoteClient.available() > 0) {
char c = RemoteClient.read();
if (buff_pos < 16 && c != '\n') {
buff[buff_pos++] = c;
} else {
buff[buff_pos] = 0;
buff[buff_pos] = '\0';
buff_pos = 0;
XDRGTKdata = true;
break;
}
}
}
@@ -393,7 +392,6 @@ void XDRGTKRoutine() {
radio.SetFreq(frequency);
}
if (band == BAND_FM) DataPrint("T" + String((frequency + ConverterSet * 100) * 10) + "\n"); else DataPrint("T" + String(frequency_AM) + "\n");
ShowFreq(0);
radio.clearRDS(fullsearchrds);
RDSstatus = false;
@@ -528,11 +526,11 @@ void XDRGTKRoutine() {
ANT = atol(buff + 1);
switch (ANT) {
case 0:
// Antenna A
if (BAND_FM || BAND_OIRT) radio.setCoax(2); else radio.setCoax(0);
break;
case 1:
// Antenna B
if (BAND_FM || BAND_OIRT) radio.setCoax(3); else radio.setCoax(1);
break;
case 2:

View File

@@ -448,7 +448,7 @@ void readRds() {
void ShowErrors() {
uint8_t calc = 4;
if (RDSstatus) {
if (RDSstatus && !rdsreset) {
if (!radio.rds.rdsAerror) calc--;
if (!radio.rds.rdsBerror) calc--;
if (!radio.rds.rdsCerror) calc--;
@@ -457,6 +457,8 @@ void ShowErrors() {
SAvg3 = (((SAvg3 * 9) + 5) / 10) + calc;
calc = SAvg3 / 10;
}
rdsreset = false;
if (calc != rdsqualityold || BWreset) {
switch (calc) {