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);
+22 -7
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
if (initrt) {
wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII 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 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 = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, 64, true); // Make sure RT does not exceed 64 characters 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
@@ -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) {
+4
View File
@@ -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;
@@ -273,6 +274,7 @@ class TEF6686 {
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"";
@@ -282,6 +284,8 @@ class TEF6686 {
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;