AFEON fixes

- Fix crash when more than 12 EON's
- Fix page numbering
- Fix EON overwritten texts
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-10-24 22:51:48 +02:00
parent 038403f267
commit 32d866328a
7 changed files with 33 additions and 29 deletions

View File

@@ -174,6 +174,7 @@ byte unit;
byte spispeed; byte spispeed;
byte spispeedold; byte spispeedold;
char buff[16]; char buff[16];
char eonpicodeold[20][6];
char programTypePrevious[18]; char programTypePrevious[18];
char radioIdPrevious[7]; char radioIdPrevious[7];
const uint8_t* currentFont = nullptr; const uint8_t* currentFont = nullptr;
@@ -252,7 +253,7 @@ String AIDString;
String cryptedpassword; String cryptedpassword;
String CurrentThemeString; String CurrentThemeString;
String ECColdtxt; String ECColdtxt;
String eonpsold[11]; String eonpsold[20];
String eonstringold; String eonstringold;
String LIColdString; String LIColdString;
String pinstringold; String pinstringold;

View File

@@ -527,9 +527,9 @@ void TEF6686::readRDS(byte showrdserrors)
if (rdsblock == 0 && rds.rdsC != rdsCold) { // Only when in GROUP 0A if (rdsblock == 0 && rds.rdsC != rdsCold) { // Only when in GROUP 0A
if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250) { if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250) {
afinit = true; // AF detected afinit = true; // AF detected
rds.hasAF = true; rds.hasAF = true;
} }
if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq && rds.hasAF && afmethodBtrigger) { if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250 && ((rds.rdsC & 0xFF) * 10 + 8750) == currentfreq && rds.hasAF && afmethodBtrigger) {
afmethodB = true; // Check for AF method B afmethodB = true; // Check for AF method B
@@ -1240,7 +1240,7 @@ void TEF6686::readRDS(byte showrdserrors)
bool isValuePresent = false; bool isValuePresent = false;
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
if (eon[i].pi == rds.rdsD) { // Check if EON is already in array if (eon[i].pi == rds.rdsD || rds.rdsA == rds.rdsD) { // Check if EON is already in array
isValuePresent = true; isValuePresent = true;
break; break;
} }

View File

@@ -712,6 +712,6 @@ class TEF6686 {
uint16_t rdsCold; uint16_t rdsCold;
uint8_t af_counterb; uint8_t af_counterb;
uint8_t af_counterbcheck; uint8_t af_counterbcheck;
bool afmethodBtrigger; bool afmethodBtrigger;
}; };
#endif #endif

View File

@@ -335,7 +335,6 @@ void BuildAFScreen() {
tftPrint(0, myLanguage[language][93], 160, 222, ActiveColor, ActiveColorSmooth, 16); tftPrint(0, myLanguage[language][93], 160, 222, ActiveColor, ActiveColorSmooth, 16);
tftPrint(-1, myLanguage[language][88], 184, 48, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(-1, myLanguage[language][88], 184, 48, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(-1, myLanguage[language][87], 6, 48, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(-1, myLanguage[language][87], 6, 48, PrimaryColor, PrimaryColorSmooth, 16);
for (byte i = 0; i < 20; i++) mappedfreqold[i] = 0;
RDSstatusold = false; RDSstatusold = false;
ShowFreq(0); ShowFreq(0);
Stereostatusold = false; Stereostatusold = false;
@@ -351,7 +350,9 @@ void BuildAFScreen() {
strcpy(radioIdPrevious, ""); strcpy(radioIdPrevious, "");
programServicePrevious = ""; programServicePrevious = "";
afmethodBold = false; afmethodBold = false;
for (byte i = 0; i < 11; i++) eonpsold[i] = ""; for (byte i = 0; i < 20; i++) eonpsold[i] = "";
for (byte i = 0; i < 20; i++) mappedfreqold[i] = 0;
for (byte i = 0; i < 20; i++) eonpicodeold[0][i] = '\0';
} }
} }

View File

@@ -107,6 +107,7 @@ extern byte touchrotating;
extern byte unit; extern byte unit;
extern byte spispeed; extern byte spispeed;
extern byte spispeedold; extern byte spispeedold;
extern char eonpicodeold[20][6];
extern char programTypePrevious[18]; extern char programTypePrevious[18];
extern char radioIdPrevious[7]; extern char radioIdPrevious[7];
extern float batteryVold; extern float batteryVold;
@@ -147,7 +148,7 @@ extern int8_t LowLevelSet;
extern int8_t VolSet; extern int8_t VolSet;
extern String afstringold; extern String afstringold;
extern String CurrentThemeString; extern String CurrentThemeString;
extern String eonpsold[11]; extern String eonpsold[20];
extern String eonstringold; extern String eonstringold;
extern String pinstringold; extern String pinstringold;
extern String programServicePrevious; extern String programServicePrevious;

View File

@@ -381,7 +381,7 @@ void readRds() {
void showPI() { void showPI() {
if (strcmp(radio.rds.picode, radioIdPrevious)) { if (strcmp(radio.rds.picode, radioIdPrevious)) {
if (!radio.rds.rdsAerror && !radio.rds.rdsBerror && !radio.rds.rdsCerror && !radio.rds.rdsDerror && radio.rds.rdsA != radio.rds.correctPI && PIold.length() > 1) radio.clearRDS(fullsearchrds); if (!afscreen && !radio.rds.rdsAerror && !radio.rds.rdsBerror && !radio.rds.rdsCerror && !radio.rds.rdsDerror && radio.rds.rdsA != radio.rds.correctPI && PIold.length() > 1) radio.clearRDS(fullsearchrds);
if (!screenmute) { if (!screenmute) {
if (advancedRDS) { if (advancedRDS) {
if (region == REGION_EU) tftReplace(0, PIold, radio.rds.picode, 275, 75, PrimaryColor, PrimaryColorSmooth, 28); if (region == REGION_EU) tftReplace(0, PIold, radio.rds.picode, 275, 75, PrimaryColor, PrimaryColorSmooth, 28);
@@ -553,6 +553,15 @@ void showRadioText() {
} }
void ShowAFEON() { void ShowAFEON() {
if (radio.af_counter > 30 || radio.eon_counter > 9) {
if (!afpage) {
afpage = true;
afpagenr = 1;
}
}
if (afpage) tftPrint(1, String(afpagenr) + "/2", 315, 222, SecondaryColor, SecondaryColorSmooth, 16);
if (radio.rds.hasAF) { if (radio.rds.hasAF) {
if (!hasafold) { if (!hasafold) {
if (!screenmute) tftPrint(-1, myLanguage[language][87], 6, 54, BackgroundColor, BackgroundColor, 16); if (!screenmute) tftPrint(-1, myLanguage[language][87], 6, 54, BackgroundColor, BackgroundColor, 16);
@@ -560,16 +569,7 @@ void ShowAFEON() {
hasafold = true; hasafold = true;
} }
if (radio.af_counter > 30 || radio.eon_counter > 9) { if (af_counterold != radio.af_updatecounter && (afpage != 2 && radio.af_counter < 31)) {
if (!afpage) {
afpage = true;
afpagenr = 1;
}
} else {
afpagenr = 0;
}
if (af_counterold != radio.af_updatecounter) {
tft.fillRect(2, 48, 166, 150, BackgroundColor); tft.fillRect(2, 48, 166, 150, BackgroundColor);
for (byte i = 0; i < radio.af_counter; i++) { for (byte i = 0; i < radio.af_counter; i++) {
byte x = i - (afpagenr == 2 ? 30 : 0); byte x = i - (afpagenr == 2 ? 30 : 0);
@@ -588,7 +588,6 @@ void ShowAFEON() {
if (radio.af_counter > 10 + (afpagenr == 2 ? 30 : 0)) tft.drawLine(59, 54, 59, 191, SecondaryColor); if (radio.af_counter > 10 + (afpagenr == 2 ? 30 : 0)) tft.drawLine(59, 54, 59, 191, SecondaryColor);
if (radio.af_counter > 20 + (afpagenr == 2 ? 30 : 0)) tft.drawLine(113, 54, 113, 191, SecondaryColor); if (radio.af_counter > 20 + (afpagenr == 2 ? 30 : 0)) tft.drawLine(113, 54, 113, 191, SecondaryColor);
if (afpage && !screenmute) tftPrint(1, String(afpagenr) + "/2", 315, 222, SecondaryColor, SecondaryColorSmooth, 16);
af_counterold = radio.af_updatecounter; af_counterold = radio.af_updatecounter;
} }
} }
@@ -605,21 +604,22 @@ void ShowAFEON() {
byte y = 0; byte y = 0;
if (afpagenr == 2) y = 10; if (afpagenr == 2) y = 10;
for (byte i = 0; i < radio.eon_counter; i++) { for (byte i = 0; i < radio.eon_counter; i++) {
if (strcmp(eonpicodeold[i + y], radio.eon[i + y].picode) != 0) tftPrint(-1, String(eonpicodeold[i + y]), 170, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
tftPrint(-1, String(radio.eon[i + y].picode), 170, 48 + (15 * i), PrimaryColor, PrimaryColorSmooth, 16); tftPrint(-1, String(radio.eon[i + y].picode), 170, 48 + (15 * i), PrimaryColor, PrimaryColorSmooth, 16);
strcpy(eonpicodeold[i + y], radio.eon[i + y].picode);
if (radio.eon[i + y].ps.length() > 0) { if (radio.eon[i + y].ps.length() > 0) {
tftPrint(-1, "PS:", 206, 32, ActiveColor, ActiveColorSmooth, 16); tftPrint(-1, "PS:", 206, 32, ActiveColor, ActiveColorSmooth, 16);
if (radio.eon[i + y].ps != eonpsold[i + y]) {
tftPrint(-1, String(eonpsold[i + y]), 206, 48 + (15 * i), BackgroundColor, BackgroundColor, 16); if (strcmp(radio.eon[i + y].ps.c_str(), eonpsold[i + y].c_str()) != 0) tftPrint(-1, String(eonpsold[i + y]), 206, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
eonpsold[i + y] = radio.eon[i + y].ps;
}
tftPrint(-1, String(radio.eon[i + y].ps), 206, 48 + (15 * i), SecondaryColor, SecondaryColorSmooth, 16); tftPrint(-1, String(radio.eon[i + y].ps), 206, 48 + (15 * i), SecondaryColor, SecondaryColorSmooth, 16);
eonpsold[i + y] = radio.eon[i + y].ps;
} }
if (radio.eon[i + y].mappedfreq > 0) { if (radio.eon[i + y].mappedfreq > 0) {
tftPrint(1, "FREQ:", 316, 32, ActiveColor, ActiveColorSmooth, 16); tftPrint(1, "FREQ:", 316, 32, ActiveColor, ActiveColorSmooth, 16);
if (radio.eon[i + y].mappedfreq != mappedfreqold[i + y]) {
tftPrint(1, String(mappedfreqold[i + y] / 100) + "." + String((mappedfreqold[i + y] % 100) / 10), 316, 48 + (15 * i), BackgroundColor, BackgroundColor, 16); if (radio.eon[i + y].mappedfreq != mappedfreqold[i + y]) tftPrint(1, String(mappedfreqold[i + y] / 100) + "." + String((mappedfreqold[i + y] % 100) / 10), 316, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
}
tftPrint(1, String(radio.eon[i + y].mappedfreq / 100) + "." + String((radio.eon[i + y].mappedfreq % 100) / 10), 316, 48 + (15 * i), PrimaryColor, PrimaryColorSmooth, 16); tftPrint(1, String(radio.eon[i + y].mappedfreq / 100) + "." + String((radio.eon[i + y].mappedfreq % 100) / 10), 316, 48 + (15 * i), PrimaryColor, PrimaryColorSmooth, 16);
mappedfreqold[i + y] = radio.eon[i + y].mappedfreq; mappedfreqold[i + y] = radio.eon[i + y].mappedfreq;
} }

View File

@@ -46,6 +46,7 @@ extern byte MSold;
extern byte rdsblockold; extern byte rdsblockold;
extern byte region; extern byte region;
extern byte stationlistid; extern byte stationlistid;
extern char eonpicodeold[20][6];
extern char programTypePrevious[18]; extern char programTypePrevious[18];
extern char radioIdPrevious[7]; extern char radioIdPrevious[7];
extern int ActiveColor; extern int ActiveColor;
@@ -71,7 +72,7 @@ extern IPAddress remoteip;
extern String afstringold; extern String afstringold;
extern String AIDString; extern String AIDString;
extern String ECColdtxt; extern String ECColdtxt;
extern String eonpsold[11]; extern String eonpsold[20];
extern String eonstringold; extern String eonstringold;
extern String LIColdString; extern String LIColdString;
extern String pinstringold; extern String pinstringold;