From 6321868feb1f60d8e15ea03596b13426a8954d42 Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Sun, 23 Jul 2023 13:25:50 +0200 Subject: [PATCH] Extra EON PS cleaning and bugfixing --- TEF6686_ESP32.ino | 6 +++--- src/TEF6686.cpp | 35 +++++++++++++++-------------------- src/TEF6686.h | 3 +-- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 92ba49d..eefab4d 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -3858,12 +3858,12 @@ void ShowAFEON() { for (byte i = 0; i < radio.eon_counter; i++) { tftPrint(-1, String(radio.eon[i].picode), 170, 48 + (15 * i), PrimaryColor, PrimaryColorSmooth, FONT16); if (radio.eon[i].ps.length() > 0) { - tftPrint(-1, "PS:", 208, 32, ActiveColor, ActiveColorSmooth, FONT16); + tftPrint(-1, "PS:", 206, 32, ActiveColor, ActiveColorSmooth, FONT16); if (radio.eon[i].ps != eonpsold[i]) { - tftPrint(-1, String(eonpsold[i]), 208, 48 + (15 * i), BackgroundColor, BackgroundColor, FONT16); + tftPrint(-1, String(eonpsold[i]), 206, 48 + (15 * i), BackgroundColor, BackgroundColor, FONT16); eonpsold[i] = radio.eon[i].ps; } - tftPrint(-1, String(radio.eon[i].ps), 208, 48 + (15 * i), SecondaryColor, SecondaryColorSmooth, FONT16); + tftPrint(-1, String(radio.eon[i].ps), 206, 48 + (15 * i), SecondaryColor, SecondaryColorSmooth, FONT16); } if (radio.eon[i].mappedfreq > 0) { diff --git a/src/TEF6686.cpp b/src/TEF6686.cpp index ce51a6e..5fa95a6 100644 --- a/src/TEF6686.cpp +++ b/src/TEF6686.cpp @@ -800,22 +800,22 @@ void TEF6686::readRDS(bool showrdserrors) } } - eon_buffer2[position][(offset * 2) + 0] = eon_buffer[position][(offset * 2) + 0]; // Make a copy of the PS buffer - eon_buffer2[position][(offset * 2) + 1] = eon_buffer[position][(offset * 2) + 1]; - eon_buffer[position][(offset * 2) + 0] = rds.rdsC >> 8; // First character of segment - eon_buffer[position][(offset * 2) + 1] = rds.rdsC & 0xFF; // Second character of segment - eon_buffer[position][(offset * 2) + 2] = '\0'; // Endmarker of segment - - if (offset > 2) { // Last chars are received - if (eon_buffer[position] != eon_buffer2[position]) { // When difference between old and new, let's go... - RDScharConverter(eon_buffer[position], EONPStext[position], sizeof(EONPStext[position]) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII - String utf8String = convertToUTF8(EONPStext[position]); // Convert RDS characterset to ASCII - eon[position].ps = extractUTF8Substring(utf8String, 0, 8, true); // Make sure PS does not exceed 8 characters - } + if (offset < 4 && eon[position].pi == rds.rdsD) { + for (int j = 0; j < 9; j++) EONPStext[position][j] = '\0'; // Clear buffer + eon_buffer[position][(offset * 2) + 0] = rds.rdsC >> 8; // First character of segment + eon_buffer[position][(offset * 2) + 1] = rds.rdsC & 0xFF; // Second character of segment + eon_buffer[position][(offset * 2) + 2] = '\0'; // Endmarker of segment } - if (offset > 4) { + if (offset > 3 && eon[position].pi == rds.rdsD) { // Last chars are received + RDScharConverter(eon_buffer[position], EONPStext[position], sizeof(EONPStext[position]) / sizeof(wchar_t), true); // Convert 8 bit ASCII to 16 bit ASCII + String utf8String = convertToUTF8(EONPStext[position]); // Convert RDS characterset to ASCII + eon[position].ps = extractUTF8Substring(utf8String, 0, 8, true); // Make sure PS does not exceed 8 characters + for (int j = 0; j < 9; j++) eon_buffer[position][j] = '\0'; // Clear buffer + } + + if (offset > 4 && eon[position].pi == rds.rdsD) { if (((rds.rdsC >> 8) * 10 + 8750) == currentfreq) { // Check if mapped frequency belongs to current frequency if (eon[position].mappedfreq == 0) { eon[position].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array @@ -882,13 +882,7 @@ void TEF6686::clearRDS (bool fullsearchrds) } for (int j = 0; j < 9; j++) { EONPStext[i][j] = L'\0'; - } - } - - for (i = 0; i < 9; i++) { - for (int y = 0; y < 5; y++) { - eon_buffer[i][y] = '\0'; - eon_buffer2[i][y] = '\0'; + eon_buffer[i][j] = '\0'; } } @@ -896,6 +890,7 @@ void TEF6686::clearRDS (bool fullsearchrds) RDSplus1[i] = 0; RDSplus2[i] = 0; } + rdsblock = 254; piold = 0; rds.correctPI = 0; diff --git a/src/TEF6686.h b/src/TEF6686.h index 59f72b4..4389822 100644 --- a/src/TEF6686.h +++ b/src/TEF6686.h @@ -247,8 +247,7 @@ class TEF6686 { char ps_buffer[9]; char ps_buffer2[9]; char ptyn_buffer[9]; - char eon_buffer[9][5]; - char eon_buffer2[9][5]; + char eon_buffer[20][9]; bool ps_process; bool rt_process; char rt_buffer[65];