Fixed a problem with Radiotext when only Method B was used

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-13 21:06:23 +01:00
parent d0f630a32d
commit 33ce573c35
2 changed files with 58 additions and 20 deletions

View File

@@ -605,12 +605,12 @@ void TEF6686::readRDS(byte showrdserrors) {
if (showrdserrors == 3 || (!rdsBerrorThreshold && (!rdsDerrorThreshold))) {
offset = rds.rdsB & 0x03; // Let's get the character offset for PS
switch (offset) {
case 0: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps12error = true; else rds.ps12error = false; break;
case 1: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps34error = true; else rds.ps34error = false; break;
case 2: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps56error = true; else rds.ps56error = false; break;
case 3: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps78error = true; else rds.ps78error = false; break;
}
switch (offset) {
case 0: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps12error = true; else rds.ps12error = false; break;
case 1: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps34error = true; else rds.ps34error = false; break;
case 2: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps56error = true; else rds.ps56error = false; break;
case 3: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps78error = true; else rds.ps78error = false; break;
}
ps_buffer2[(offset * 2) + 0] = ps_buffer[(offset * 2) + 0]; // Make a copy of the PS buffer
ps_buffer2[(offset * 2) + 1] = ps_buffer[(offset * 2) + 1];
@@ -1278,6 +1278,7 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
char rt_buffer_temp[129];
bool found = false;
strcpy(rt_buffer_temp, rt_buffer32);
@@ -1295,7 +1296,7 @@ void TEF6686::readRDS(byte showrdserrors) {
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText32 = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText32 = extractUTF8Substring(rds.stationText32, 0, endmarkerRT32, true);// Make sure RT does not exceed 32 characters
rds.stationText = trimTrailingSpaces(rds.stationText); // Trim empty spaces at the end
rds.stationText32 = trimTrailingSpaces(rds.stationText32); // Trim empty spaces at the end
}
} break;

View File

@@ -855,66 +855,99 @@ void showCT() {
}
void showRadioText() {
String RTString = String(radio.rds.stationText + " " + radio.rds.stationText32 + (radio.rds.hasEnhancedRT ? " eRT: " + String(radio.rds.enhancedRTtext) : "") + " ");
// Build the radio text string
String RTString = String(
radio.rds.stationText +
(radio.rds.stationText.length() > 0 ? " " : "") +
radio.rds.stationText32 +
(radio.rds.hasEnhancedRT ? " eRT: " + String(radio.rds.enhancedRTtext) : "") +
" "
);
// Check if RT has changed
if (radio.rds.hasRT && radio.rds.rtAB != rtABold) {
xPos = 0;
rttickerhold = millis();
rtABold = radio.rds.rtAB;
xPos = 0; // Reset ticker position
rttickerhold = millis(); // Hold the ticker momentarily
rtABold = radio.rds.rtAB; // Update old AB status
}
if (!screenmute) {
if (radio.rds.hasRT && radio.rds.stationText.length() > 0) {
// Display RDS information if RT is available
if (radio.rds.hasRT &&
(radio.rds.stationText.length() > 0 || radio.rds.stationText32.length() > 0)) {
// Determine whether to use advanced RDS mode
if (advancedRDS && RDSSprite.textWidth(radio.trimTrailingSpaces(RTString)) < 165) {
xPos = 0;
RDSSprite.fillSprite(BackgroundColor);
RDSSprite.setTextDatum(TL_DATUM);
RDSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
RDSSprite.setTextColor(
RDSstatus ? RDSColor : RDSDropoutColor,
RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth,
false
);
RDSSprite.drawString(RTString, xPos, 2);
RDSSprite.pushSprite(36, 220);
} else if (!advancedRDS && RDSSprite.textWidth(radio.trimTrailingSpaces(RTString)) < 270) {
xPos = 0;
FullLineSprite.fillSprite(BackgroundColor);
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
FullLineSprite.setTextColor(
RDSstatus ? RDSColor : RDSDropoutColor,
RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth,
false
);
FullLineSprite.drawString(RTString, xPos, 2);
FullLineSprite.fillRect(275, 0, 8, 19, BackgroundColor);
FullLineSprite.drawLine(283, 0, 283, 19, FrameColor);
if (radio.rds.hasRT) {
FullLineSprite.fillCircle(278, 3, 2, radio.rds.rtAB ? GreyoutColor : InsignificantColor);
FullLineSprite.fillCircle(278, 14, 2, radio.rds.rtAB ? InsignificantColor : GreyoutColor);
}
FullLineSprite.pushSprite(36, 220);
} else {
// Handle scrolling text
if (millis() - rtticker >= (advancedRDS ? 5 : 15)) {
if (xPos == 0 && millis() - rttickerhold < 1000) {
// Do nothing, just wait
// Wait for a moment before scrolling
} else {
xPos--;
rttickerhold = millis(); // Update hold time only when xPos changes
rttickerhold = millis(); // Update hold time only when xPos changes
}
if (xPos < -RadiotextWidth) xPos = 0;
if (xPos < -RadiotextWidth) xPos = 0; // Reset position if scrolled off
if (advancedRDS) {
RDSSprite.fillSprite(BackgroundColor);
RDSSprite.setTextDatum(TL_DATUM);
RDSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
RDSSprite.setTextColor(
RDSstatus ? RDSColor : RDSDropoutColor,
RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth,
false
);
RDSSprite.drawString(RTString, xPos, 2);
RDSSprite.drawString(RTString, xPos + RadiotextWidth, 2);
RDSSprite.pushSprite(36, 220);
} else {
FullLineSprite.fillSprite(BackgroundColor);
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
FullLineSprite.setTextColor(
RDSstatus ? RDSColor : RDSDropoutColor,
RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth,
false
);
FullLineSprite.drawString(RTString, xPos, 2);
FullLineSprite.drawString(RTString, xPos + RadiotextWidth, 2);
FullLineSprite.fillRect(275, 0, 8, 19, BackgroundColor);
FullLineSprite.drawLine(283, 0, 283, 19, FrameColor);
if (radio.rds.hasRT) {
FullLineSprite.fillCircle(278, 3, 2, radio.rds.rtAB ? GreyoutColor : InsignificantColor);
FullLineSprite.fillCircle(278, 14, 2, radio.rds.rtAB ? InsignificantColor : GreyoutColor);
}
FullLineSprite.pushSprite(36, 220);
}
rtticker = millis();
@@ -922,27 +955,31 @@ void showRadioText() {
}
}
// Update small indicators for RT AB status
if (radio.rds.hasRT && advancedRDS) {
tft.fillCircle(203, 223, 2, radio.rds.rtAB ? GreyoutColor : InsignificantColor);
tft.fillCircle(203, 234, 2, radio.rds.rtAB ? InsignificantColor : GreyoutColor);
}
}
// Update RTold and RadiotextWidth if the string has changed
if (RTold != RTString) {
RadiotextWidth = (advancedRDS ? RDSSprite.textWidth(RTString) : FullLineSprite.textWidth(RTString));
if (wifi) {
Udp.beginPacket(remoteip, 9030);
Udp.print("from=TEF_tuner_" + String(stationlistid, DEC) + ";RT1=");
char RThex[65];
radio.rds.stationText.toCharArray(RThex, 65);
for (int i = 0; i < 64; i++) {
if (RThex[i] < 0x10) Udp.print("0");
if (RThex[i] == ' ') RThex[i] = '_';
if (RThex[i] == ' ') RThex[i] = '_';
Udp.print(String(RThex[i], HEX));
}
Udp.endPacket();
}
RTold = RTString;
}
}