diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 23d8164..c5dd4bb 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -206,7 +206,6 @@ int BWAutoColor; int BWAutoColorSmooth; int BWOld; int bwupdatetimer; -int charWidth = tft.textWidth("AA"); int DeEmphasis; int ForceMono; int FrameColor; @@ -248,6 +247,7 @@ int Squelch; int Squelchold; int SStatusold; int Stereostatus; +int TickerSpace = tft.textWidth("AA"); int volume; int XDRBWset; int XDRBWsetold; diff --git a/src/gui.cpp b/src/gui.cpp index e187155..d40239d 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -228,7 +228,7 @@ void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de BWAutoColor = Cherry; BWAutoColorSmooth = CherrySmooth; BatteryValueColor = Cherry; - BatteryValueColorSmooth = CherrySmooth; + BatteryValueColorSmooth = CherrySmooth; break; case 7: // Whiteout theme PrimaryColor = Black; @@ -463,6 +463,7 @@ void BuildAFScreen() { afmethodBold = false; PIold = " "; PSold = " "; + xPos = 0; for (byte i = 0; i < 20; i++) { mappedfreqold[i] = 0; mappedfreqold2[i] = 0; @@ -854,6 +855,10 @@ void BuildAdvancedRDS() { dropout = false; rdsreset = true; ShowMemoryPos(); + xPos = 0; + xPos2 = 0; + xPos3 = 0; + xPos4 = 0; } void BuildDisplay() { @@ -983,6 +988,7 @@ void BuildDisplay() { stationStateold = " "; BWreset = true; dropout = false; + xPos = 0; if (band < BAND_GAP) tftPrint(-1, "MHz", 258, 76, ActiveColor, ActiveColorSmooth, 28); else tftPrint(-1, "kHz", 258, 76, ActiveColor, ActiveColorSmooth, 28); } diff --git a/src/gui.h b/src/gui.h index 6d1b273..df4eaee 100644 --- a/src/gui.h +++ b/src/gui.h @@ -152,6 +152,10 @@ extern int Squelchold; extern int SStatusold; extern int StereoColor; extern int StereoColorSmooth; +extern int xPos; +extern int xPos2; +extern int xPos3; +extern int xPos4; extern int16_t SStatus; extern int8_t LevelOffset; extern int8_t LowLevelSet; diff --git a/src/rds.cpp b/src/rds.cpp index 8aed6a7..42302b8 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -5,6 +5,17 @@ #include "constants.h" #include +int Radiotextlengthold; +int RadiotextWidth; +int AIDlengthold; +int AIDWidth; +int afstringlengthold; +int afstringWidth; +int eonstringlengthold; +int eonstringWidth; +int rtplusstringlengthold; +int rtplusstringWidth; + void ShowAdvancedRDS() { if (!dropout) { if (radio.rds.rdsAerror) tft.fillCircle(86, 41, 5, SignificantColor); else tft.fillCircle(86, 41, 5, InsignificantColor); @@ -72,19 +83,29 @@ void ShowAdvancedRDS() { } if (millis() - afticker >= 15) { - if (xPos2 == 0) { - if (millis() - aftickerhold >= 2000) { + if (radio.rds.hasAF) { + if (afstring.length() != afstringlengthold) { + afstringWidth = tft.textWidth(afstring) + TickerSpace; + afstringlengthold = afstring.length(); + } + if (xPos2 < -(afstringWidth + TickerSpace)) xPos2 = 0; + if (xPos2 == 0) { + if (millis() - aftickerhold >= 2000) { + xPos2 --; + aftickerhold = millis(); + } + } else { xPos2 --; aftickerhold = millis(); } } else { - xPos2 --; - aftickerhold = millis(); + xPos2 = 0; } - if (xPos2 < -tft.textWidth(afstring) + (charWidth * 14)) xPos2 = 0; + RDSSprite.fillSprite(BackgroundColor); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RDSSprite.drawString(afstring, xPos2, 2); + if (radio.rds.hasAF) RDSSprite.drawString(afstring, xPos2 + afstringWidth + TickerSpace, 2); RDSSprite.pushSprite(35, 197); afticker = millis(); } @@ -99,19 +120,29 @@ void ShowAdvancedRDS() { } if (millis() - eonticker >= 15) { - if (xPos3 == 0) { - if (millis() - eontickerhold >= 2000) { + + if (radio.rds.hasEON) { + if (eonstring.length() != eonstringlengthold) { + eonstringWidth = tft.textWidth(eonstring) + TickerSpace; + eonstringlengthold = eonstring.length(); + } + if (xPos3 < -(eonstringWidth + TickerSpace)) xPos3 = 0; + if (xPos3 == 0) { + if (millis() - eontickerhold >= 2000) { + xPos3 --; + eontickerhold = millis(); + } + } else { xPos3 --; eontickerhold = millis(); } } else { - xPos3 --; - eontickerhold = millis(); + xPos3 = 0; } - if (xPos3 < -tft.textWidth(eonstring) + (charWidth * 14)) xPos3 = 0; RDSSprite.fillSprite(BackgroundColor); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RDSSprite.drawString(eonstring, xPos3, 2); + if (radio.rds.hasEON) RDSSprite.drawString(eonstring, xPos3 + eonstringWidth + TickerSpace, 2); RDSSprite.pushSprite(35, 172); eonticker = millis(); } @@ -127,19 +158,28 @@ void ShowAdvancedRDS() { } if (millis() - rtplusticker >= 15) { - if (xPos4 == 0) { - if (millis() - rtplustickerhold >= 2000) { + if (radio.rds.hasRDSplus) { + if (rtplusstring.length() != rtplusstringlengthold) { + rtplusstringWidth = tft.textWidth(rtplusstring) + TickerSpace; + rtplusstringlengthold = rtplusstring.length(); + } + if (xPos4 < -(rtplusstringWidth + TickerSpace)) xPos4 = 0; + if (xPos4 == 0) { + if (millis() - rtplustickerhold >= 2000) { + xPos4 --; + rtplustickerhold = millis(); + } + } else { xPos4 --; rtplustickerhold = millis(); } } else { - xPos4 --; - rtplustickerhold = millis(); + xPos4 = 0; } - if (xPos4 < -tft.textWidth(rtplusstring) + (charWidth * 14)) xPos4 = 0; RDSSprite.fillSprite(BackgroundColor); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RDSSprite.drawString(rtplusstring, xPos4, 2); + if (radio.rds.hasRDSplus) RDSSprite.drawString(rtplusstring, xPos4 + rtplusstringWidth + TickerSpace, 2); RDSSprite.pushSprite(35, 146); rtplusticker = millis(); } @@ -279,12 +319,14 @@ void readRds() { AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); AdvRadiotextSprite.pushSprite(35, 220); } else if (!advancedRDS && radio.rds.stationText.length() < 29) { xPos = 0; RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); RadiotextSprite.pushSprite(38, 220); } @@ -323,12 +365,14 @@ void readRds() { AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); AdvRadiotextSprite.pushSprite(35, 220); } else if (!advancedRDS && radio.rds.stationText.length() < 29) { xPos = 0; RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); RadiotextSprite.pushSprite(38, 220); } @@ -561,6 +605,10 @@ void showCT() { void showRadioText() { if (radio.rds.hasRT && radio.rds.stationText.length() > 0) { + if (String(radio.rds.stationText + radio.rds.stationText32).length() != Radiotextlengthold) { + RadiotextWidth = tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + TickerSpace; + Radiotextlengthold = String(radio.rds.stationText + radio.rds.stationText32).length(); + } if (advancedRDS && radio.rds.stationText.length() < 20) { xPos = 0; AdvRadiotextSprite.fillSprite(BackgroundColor); @@ -576,7 +624,7 @@ void showRadioText() { } else { if (millis() - rtticker >= 15) { if (xPos == 0) { - if (millis() - rttickerhold >= 2000) { + if (millis() - rttickerhold >= 1000) { xPos --; rttickerhold = millis(); } @@ -584,17 +632,19 @@ void showRadioText() { xPos --; rttickerhold = millis(); } + + if (xPos < -(RadiotextWidth + TickerSpace)) xPos = 0; if (advancedRDS) { - if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 10)) xPos = 0; AdvRadiotextSprite.fillSprite(BackgroundColor); if (RDSstatus) AdvRadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); else AdvRadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); AdvRadiotextSprite.pushSprite(35, 220); } else { - if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 20)) xPos = 0; RadiotextSprite.fillSprite(BackgroundColor); if (RDSstatus) RadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); + RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2); RadiotextSprite.pushSprite(38, 220); } rtticker = millis(); @@ -795,8 +845,14 @@ void ShowAFEON() { aid_counterold = radio.rds.aid_counter; } + if (AIDString.length() != AIDlengthold) { + AIDWidth = tft.textWidth(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString) + TickerSpace; + AIDlengthold = AIDString.length(); + } + + if (xPos < -(AIDWidth + TickerSpace)) xPos = 0; if (xPos == 0) { - if (millis() - rttickerhold >= 2000) { + if (millis() - rttickerhold >= 1000) { xPos --; rttickerhold = millis(); } @@ -804,12 +860,12 @@ void ShowAFEON() { xPos --; rttickerhold = millis(); } - if (xPos < -tft.textWidth(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString) + (charWidth * 14)) xPos = 0; RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); RadiotextSprite.drawString(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString, xPos, 2); + RadiotextSprite.drawString(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString, xPos + AIDWidth + TickerSpace, 2); RadiotextSprite.pushSprite(5, 220); } } } -#pragma GCC diagnostic pop +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/src/rds.h b/src/rds.h index ab4cef2..1f9b009 100644 --- a/src/rds.h +++ b/src/rds.h @@ -57,7 +57,6 @@ extern int ActiveColorSmooth; extern int BackgroundColor; extern int BWAutoColor; extern int BWAutoColorSmooth; -extern int charWidth; extern int GreyoutColor; extern int InsignificantColor; extern int InsignificantColorSmooth; @@ -71,6 +70,7 @@ extern int SecondaryColor; extern int SecondaryColorSmooth; extern int SignificantColor; extern int SignificantColorSmooth; +extern int TickerSpace; extern int xPos; extern int xPos2; extern int xPos3;