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

View File

@@ -71,6 +71,7 @@ bool menu;
bool menuopen;
bool nobattery;
bool power = true;
bool rdsreset;
bool RDSSPYTCP;
bool RDSSPYUSB;
bool RDSstatus;
@@ -2217,22 +2218,22 @@ void ShowAdvancedRDS() {
const uint8_t* font = FONT16;
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);
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);
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);
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);
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);
hastmcold = radio.rds.hasTMC;
}
rdsreset = false;
}
void doAF() {
@@ -2892,6 +2895,7 @@ void ShowFreq(int mode) {
eonstringold = "";
afstringold = "";
rds_clockold = "";
rdsreset = true;
sprite.fillSprite(BackgroundColor);
sprite2.fillSprite(BackgroundColor);
if (advancedRDS) sprite2.pushSprite(35, 220); else if (!afscreen) sprite.pushSprite(38, 220);

View File

@@ -621,7 +621,18 @@ void TEF6686::readRDS(bool showrdserrors)
rds.hasRT = true;
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
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++) {
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 + 3] = rds.rdsD & 0xff; // Fourth character of segment
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
if (initrt) {
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 (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) {
// RT decoder (32 characters)
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++) {
rt_buffer32[i] = 0x20;
}
rt_buffer32[32] = '\0';
rtABold = rds.rtAB;
rtAB32old = rds.rtAB32;
}
offset = (rds.rdsB & 0xf) * 2; // Get RT character segment
@@ -743,17 +756,17 @@ void TEF6686::readRDS(bool showrdserrors)
togglebit = bitRead(lowByte(rds.rdsB), 4);
runningbit = bitRead(lowByte(rds.rdsB), 3);
switch (rds.rdsplusTag1) {
case 1 ... 53: rds.rdsplusTag1 += 111; break;
case 59 ... 63: rds.rdsplusTag1 += 105; break;
default: rds.rdsplusTag1 = 169; break;
}
switch (rds.rdsplusTag2) {
case 1 ... 53: rds.rdsplusTag2 += 111; break;
case 59 ... 63: rds.rdsplusTag2 += 105; break;
default: rds.rdsplusTag2 = 169; break;
}
switch (rds.rdsplusTag1) {
case 1 ... 53: rds.rdsplusTag1 += 111; break;
case 59 ... 63: rds.rdsplusTag1 += 105; break;
default: rds.rdsplusTag1 = 169; break;
}
switch (rds.rdsplusTag2) {
case 1 ... 53: rds.rdsplusTag2 += 111; break;
case 59 ... 63: rds.rdsplusTag2 += 105; break;
default: rds.rdsplusTag2 = 169; break;
}
if (togglebit) {
for (int i = 0; i < 45; i++) {
@@ -949,10 +962,12 @@ void TEF6686::clearRDS (bool fullsearchrds)
eon_counter = 0;
afreset = true;
rds.MS = 0;
rds.rdsAerror = false;
rds.rdsBerror = false;
rds.rdsCerror = false;
rds.rdsDerror = false;
rds.rdsAerror = true;
rds.rdsBerror = true;
rds.rdsCerror = true;
rds.rdsDerror = true;
initrt = true;
initab = true;
}
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {

View File

@@ -18,7 +18,7 @@ enum RADIO_BAND {
};
// 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_LW, AM_BAND_MW, AM_BAND_SW,
AM_BAND_CNT
@@ -159,6 +159,7 @@ typedef struct _rds_ {
bool hasAF;
bool hasCT;
bool rtAB;
bool rtAB32;
bool hasRDSplus;
bool correct;
bool filter;
@@ -200,7 +201,7 @@ class TEF6686 {
eon_ eon[20];
rds_ rds;
logbook_ logbook[22];
uint16_t CheckSignal(uint16_t frequency);
uint16_t CheckSignal(uint16_t frequency);
uint16_t TestAF();
void TestAFEON();
void readRDS(bool showrdserrors);
@@ -266,13 +267,14 @@ class TEF6686 {
char rt_buffer32[33];
bool useRTPlus = true;
bool ABold;
bool afreset;
bool afreset;
char stationTextBuffer[65];
uint16_t rdsBprevious;
uint16_t rdsCprevious;
uint16_t rdsDprevious;
uint16_t piold;
bool rtABold;
bool rtAB32old;
wchar_t PStext[9] = L"";
wchar_t EONPStext[20][9];
wchar_t PTYNtext[9] = L"";
@@ -280,8 +282,10 @@ class TEF6686 {
char RDSplus1[45];
char RDSplus2[45];
uint16_t currentfreq;
bool togglebit;
bool runningbit;
bool togglebit;
bool runningbit;
bool initrt;
bool initab;
};
#endif

View File

@@ -224,6 +224,7 @@ void BuildMenu() {
}
void BuildAdvancedRDS() {
rdsreset = true;
afscreen = false;
afpage = false;
afpagenr = 0;

View File

@@ -29,6 +29,7 @@ extern bool haseonold;
extern bool hastmcold;
extern bool LowLevelInit;
extern bool menuopen;
extern bool rdsreset;
extern bool RDSstatus;
extern bool RDSstatusold;
extern bool rdsstereoold;