Added RT buffering

This commit is contained in:
Sjef Verhoeven PE5PVB
2023-08-04 19:58:40 +02:00
parent 90335b9d0e
commit 1e78088dc0
5 changed files with 56 additions and 31 deletions
+8 -4
View File
@@ -71,6 +71,7 @@ bool menu;
bool menuopen; bool menuopen;
bool nobattery; bool nobattery;
bool power = true; bool power = true;
bool rdsreset;
bool RDSSPYTCP; bool RDSSPYTCP;
bool RDSSPYUSB; bool RDSSPYUSB;
bool RDSstatus; bool RDSstatus;
@@ -2217,22 +2218,22 @@ void ShowAdvancedRDS() {
const uint8_t* font = FONT16; const uint8_t* font = FONT16;
if (language == LANGUAGE_CHS) font = FONT16_CHS; if (language == LANGUAGE_CHS) font = FONT16_CHS;
if (radio.rds.rdsAerror != errorAold) { if (radio.rds.rdsAerror != errorAold || rdsreset) {
if (radio.rds.rdsAerror) tft.fillCircle(86, 41, 5, SignificantColor); else tft.fillCircle(86, 41, 5, InsignificantColor); if (radio.rds.rdsAerror) tft.fillCircle(86, 41, 5, SignificantColor); else tft.fillCircle(86, 41, 5, InsignificantColor);
errorAold = radio.rds.rdsAerror; errorAold = radio.rds.rdsAerror;
} }
if (radio.rds.rdsBerror != errorBold) { if (radio.rds.rdsBerror != errorBold || rdsreset) {
if (radio.rds.rdsBerror) tft.fillCircle(124, 41, 5, SignificantColor); else tft.fillCircle(124, 41, 5, InsignificantColor); if (radio.rds.rdsBerror) tft.fillCircle(124, 41, 5, SignificantColor); else tft.fillCircle(124, 41, 5, InsignificantColor);
errorBold = radio.rds.rdsBerror; errorBold = radio.rds.rdsBerror;
} }
if (radio.rds.rdsCerror != errorCold) { if (radio.rds.rdsCerror != errorCold || rdsreset) {
if (radio.rds.rdsCerror) tft.fillCircle(162, 41, 5, SignificantColor); else tft.fillCircle(162, 41, 5, InsignificantColor); if (radio.rds.rdsCerror) tft.fillCircle(162, 41, 5, SignificantColor); else tft.fillCircle(162, 41, 5, InsignificantColor);
errorCold = radio.rds.rdsCerror; errorCold = radio.rds.rdsCerror;
} }
if (radio.rds.rdsDerror != errorDold) { if (radio.rds.rdsDerror != errorDold || rdsreset) {
if (radio.rds.rdsDerror) tft.fillCircle(200, 41, 5, SignificantColor); else tft.fillCircle(200, 41, 5, InsignificantColor); if (radio.rds.rdsDerror) tft.fillCircle(200, 41, 5, SignificantColor); else tft.fillCircle(200, 41, 5, InsignificantColor);
errorDold = radio.rds.rdsDerror; errorDold = radio.rds.rdsDerror;
} }
@@ -2466,6 +2467,8 @@ void ShowAdvancedRDS() {
if (radio.rds.hasTMC == true) tftPrint(-1, "TMC", 89, 51, PrimaryColor, PrimaryColorSmooth, FONT16); else tftPrint(-1, "TMC", 89, 51, GreyoutColor, BackgroundColor, FONT16); if (radio.rds.hasTMC == true) tftPrint(-1, "TMC", 89, 51, PrimaryColor, PrimaryColorSmooth, FONT16); else tftPrint(-1, "TMC", 89, 51, GreyoutColor, BackgroundColor, FONT16);
hastmcold = radio.rds.hasTMC; hastmcold = radio.rds.hasTMC;
} }
rdsreset = false;
} }
void doAF() { void doAF() {
@@ -2892,6 +2895,7 @@ void ShowFreq(int mode) {
eonstringold = ""; eonstringold = "";
afstringold = ""; afstringold = "";
rds_clockold = ""; rds_clockold = "";
rdsreset = true;
sprite.fillSprite(BackgroundColor); sprite.fillSprite(BackgroundColor);
sprite2.fillSprite(BackgroundColor); sprite2.fillSprite(BackgroundColor);
if (advancedRDS) sprite2.pushSprite(35, 220); else if (!afscreen) sprite.pushSprite(38, 220); if (advancedRDS) sprite2.pushSprite(35, 220); else if (!afscreen) sprite.pushSprite(38, 220);
+37 -22
View File
@@ -621,7 +621,18 @@ void TEF6686::readRDS(bool showrdserrors)
rds.hasRT = true; rds.hasRT = true;
rds.rtAB = (bitRead(rds.rdsB, 4)); // Get AB flag rds.rtAB = (bitRead(rds.rdsB, 4)); // Get AB flag
if (initab) {
rtABold = rds.rtAB;
initab = false;
}
if (rds.rtAB != rtABold) { // Erase old RT, because of AB change if (rds.rtAB != rtABold) { // Erase old RT, because of AB change
initrt = false;
wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII
RDScharConverter(rt_buffer, RTtext, sizeof(RTtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, 64, true); // Make sure RT does not exceed 64 characters
for (byte i = 0; i < 64; i++) { for (byte i = 0; i < 64; i++) {
rt_buffer[i] = 0x20; rt_buffer[i] = 0x20;
} }
@@ -635,10 +646,12 @@ void TEF6686::readRDS(bool showrdserrors)
rt_buffer[offset + 2] = rds.rdsD >> 8; // Thirth character of segment rt_buffer[offset + 2] = rds.rdsD >> 8; // Thirth character of segment
rt_buffer[offset + 3] = rds.rdsD & 0xff; // Fourth character of segment rt_buffer[offset + 3] = rds.rdsD & 0xff; // Fourth character of segment
wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII if (initrt) {
RDScharConverter(rt_buffer, RTtext, sizeof(RTtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII
rds.stationText = convertToUTF8(RTtext); // Convert RDS characterset to ASCII RDScharConverter(rt_buffer, RTtext, sizeof(RTtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, 64, true); // Make sure RT does not exceed 64 characters rds.stationText = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, 64, true); // Make sure RT does not exceed 64 characters
}
for (int i = 0; i < 64; i++) rt_buffer2[i] = rt_buffer[i]; for (int i = 0; i < 64; i++) rt_buffer2[i] = rt_buffer[i];
} }
@@ -648,14 +661,14 @@ void TEF6686::readRDS(bool showrdserrors)
if (showrdserrors || rds.correct) { if (showrdserrors || rds.correct) {
// RT decoder (32 characters) // RT decoder (32 characters)
rds.hasRT = true; rds.hasRT = true;
rds.rtAB = (bitRead(rds.rdsB, 4)); // Get AB flag rds.rtAB32 = (bitRead(rds.rdsB, 4)); // Get AB flag
if (rds.rtAB != rtABold) { // Erase old RT, because of AB change if (rds.rtAB32 != rtAB32old) { // Erase old RT, because of AB change
for (byte i = 0; i < 33; i++) { for (byte i = 0; i < 33; i++) {
rt_buffer32[i] = 0x20; rt_buffer32[i] = 0x20;
} }
rt_buffer32[32] = '\0'; rt_buffer32[32] = '\0';
rtABold = rds.rtAB; rtAB32old = rds.rtAB32;
} }
offset = (rds.rdsB & 0xf) * 2; // Get RT character segment offset = (rds.rdsB & 0xf) * 2; // Get RT character segment
@@ -743,17 +756,17 @@ void TEF6686::readRDS(bool showrdserrors)
togglebit = bitRead(lowByte(rds.rdsB), 4); togglebit = bitRead(lowByte(rds.rdsB), 4);
runningbit = bitRead(lowByte(rds.rdsB), 3); runningbit = bitRead(lowByte(rds.rdsB), 3);
switch (rds.rdsplusTag1) { switch (rds.rdsplusTag1) {
case 1 ... 53: rds.rdsplusTag1 += 111; break; case 1 ... 53: rds.rdsplusTag1 += 111; break;
case 59 ... 63: rds.rdsplusTag1 += 105; break; case 59 ... 63: rds.rdsplusTag1 += 105; break;
default: rds.rdsplusTag1 = 169; break; default: rds.rdsplusTag1 = 169; break;
} }
switch (rds.rdsplusTag2) { switch (rds.rdsplusTag2) {
case 1 ... 53: rds.rdsplusTag2 += 111; break; case 1 ... 53: rds.rdsplusTag2 += 111; break;
case 59 ... 63: rds.rdsplusTag2 += 105; break; case 59 ... 63: rds.rdsplusTag2 += 105; break;
default: rds.rdsplusTag2 = 169; break; default: rds.rdsplusTag2 = 169; break;
} }
if (togglebit) { if (togglebit) {
for (int i = 0; i < 45; i++) { for (int i = 0; i < 45; i++) {
@@ -949,10 +962,12 @@ void TEF6686::clearRDS (bool fullsearchrds)
eon_counter = 0; eon_counter = 0;
afreset = true; afreset = true;
rds.MS = 0; rds.MS = 0;
rds.rdsAerror = false; rds.rdsAerror = true;
rds.rdsBerror = false; rds.rdsBerror = true;
rds.rdsCerror = false; rds.rdsCerror = true;
rds.rdsDerror = false; rds.rdsDerror = true;
initrt = true;
initab = true;
} }
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) { void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
+9 -5
View File
@@ -18,7 +18,7 @@ enum RADIO_BAND {
}; };
// Toggle: LW -> MW -> SW // Toggle: LW -> MW -> SW
enum RADIO_AM_BAND_SELECTION { enum RADIO_AM_BAND_SELECTION {
AM_BAND_ALL = 0, AM_BAND_LW_MW, AM_BAND_LW_SW, AM_BAND_MW_SW, AM_BAND_ALL = 0, AM_BAND_LW_MW, AM_BAND_LW_SW, AM_BAND_MW_SW,
AM_BAND_LW, AM_BAND_MW, AM_BAND_SW, AM_BAND_LW, AM_BAND_MW, AM_BAND_SW,
AM_BAND_CNT AM_BAND_CNT
@@ -159,6 +159,7 @@ typedef struct _rds_ {
bool hasAF; bool hasAF;
bool hasCT; bool hasCT;
bool rtAB; bool rtAB;
bool rtAB32;
bool hasRDSplus; bool hasRDSplus;
bool correct; bool correct;
bool filter; bool filter;
@@ -200,7 +201,7 @@ class TEF6686 {
eon_ eon[20]; eon_ eon[20];
rds_ rds; rds_ rds;
logbook_ logbook[22]; logbook_ logbook[22];
uint16_t CheckSignal(uint16_t frequency); uint16_t CheckSignal(uint16_t frequency);
uint16_t TestAF(); uint16_t TestAF();
void TestAFEON(); void TestAFEON();
void readRDS(bool showrdserrors); void readRDS(bool showrdserrors);
@@ -266,13 +267,14 @@ class TEF6686 {
char rt_buffer32[33]; char rt_buffer32[33];
bool useRTPlus = true; bool useRTPlus = true;
bool ABold; bool ABold;
bool afreset; bool afreset;
char stationTextBuffer[65]; char stationTextBuffer[65];
uint16_t rdsBprevious; uint16_t rdsBprevious;
uint16_t rdsCprevious; uint16_t rdsCprevious;
uint16_t rdsDprevious; uint16_t rdsDprevious;
uint16_t piold; uint16_t piold;
bool rtABold; bool rtABold;
bool rtAB32old;
wchar_t PStext[9] = L""; wchar_t PStext[9] = L"";
wchar_t EONPStext[20][9]; wchar_t EONPStext[20][9];
wchar_t PTYNtext[9] = L""; wchar_t PTYNtext[9] = L"";
@@ -280,8 +282,10 @@ class TEF6686 {
char RDSplus1[45]; char RDSplus1[45];
char RDSplus2[45]; char RDSplus2[45];
uint16_t currentfreq; uint16_t currentfreq;
bool togglebit; bool togglebit;
bool runningbit; bool runningbit;
bool initrt;
bool initab;
}; };
#endif #endif
+1
View File
@@ -224,6 +224,7 @@ void BuildMenu() {
} }
void BuildAdvancedRDS() { void BuildAdvancedRDS() {
rdsreset = true;
afscreen = false; afscreen = false;
afpage = false; afpage = false;
afpagenr = 0; afpagenr = 0;
+1
View File
@@ -29,6 +29,7 @@ extern bool haseonold;
extern bool hastmcold; extern bool hastmcold;
extern bool LowLevelInit; extern bool LowLevelInit;
extern bool menuopen; extern bool menuopen;
extern bool rdsreset;
extern bool RDSstatus; extern bool RDSstatus;
extern bool RDSstatusold; extern bool RDSstatusold;
extern bool rdsstereoold; extern bool rdsstereoold;