Added endless scrolling in tickers

This commit is contained in:
Sjef Verhoeven PE5PVB
2024-01-26 23:58:10 +01:00
parent 824994fffb
commit de83b31f4e
5 changed files with 90 additions and 24 deletions
+1 -1
View File
@@ -206,7 +206,6 @@ int BWAutoColor;
int BWAutoColorSmooth; int BWAutoColorSmooth;
int BWOld; int BWOld;
int bwupdatetimer; int bwupdatetimer;
int charWidth = tft.textWidth("AA");
int DeEmphasis; int DeEmphasis;
int ForceMono; int ForceMono;
int FrameColor; int FrameColor;
@@ -248,6 +247,7 @@ int Squelch;
int Squelchold; int Squelchold;
int SStatusold; int SStatusold;
int Stereostatus; int Stereostatus;
int TickerSpace = tft.textWidth("AA");
int volume; int volume;
int XDRBWset; int XDRBWset;
int XDRBWsetold; int XDRBWsetold;
+7 -1
View File
@@ -228,7 +228,7 @@ void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de
BWAutoColor = Cherry; BWAutoColor = Cherry;
BWAutoColorSmooth = CherrySmooth; BWAutoColorSmooth = CherrySmooth;
BatteryValueColor = Cherry; BatteryValueColor = Cherry;
BatteryValueColorSmooth = CherrySmooth; BatteryValueColorSmooth = CherrySmooth;
break; break;
case 7: // Whiteout theme case 7: // Whiteout theme
PrimaryColor = Black; PrimaryColor = Black;
@@ -463,6 +463,7 @@ void BuildAFScreen() {
afmethodBold = false; afmethodBold = false;
PIold = " "; PIold = " ";
PSold = " "; PSold = " ";
xPos = 0;
for (byte i = 0; i < 20; i++) { for (byte i = 0; i < 20; i++) {
mappedfreqold[i] = 0; mappedfreqold[i] = 0;
mappedfreqold2[i] = 0; mappedfreqold2[i] = 0;
@@ -854,6 +855,10 @@ void BuildAdvancedRDS() {
dropout = false; dropout = false;
rdsreset = true; rdsreset = true;
ShowMemoryPos(); ShowMemoryPos();
xPos = 0;
xPos2 = 0;
xPos3 = 0;
xPos4 = 0;
} }
void BuildDisplay() { void BuildDisplay() {
@@ -983,6 +988,7 @@ void BuildDisplay() {
stationStateold = " "; stationStateold = " ";
BWreset = true; BWreset = true;
dropout = false; 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); if (band < BAND_GAP) tftPrint(-1, "MHz", 258, 76, ActiveColor, ActiveColorSmooth, 28); else tftPrint(-1, "kHz", 258, 76, ActiveColor, ActiveColorSmooth, 28);
} }
+4
View File
@@ -152,6 +152,10 @@ extern int Squelchold;
extern int SStatusold; extern int SStatusold;
extern int StereoColor; extern int StereoColor;
extern int StereoColorSmooth; extern int StereoColorSmooth;
extern int xPos;
extern int xPos2;
extern int xPos3;
extern int xPos4;
extern int16_t SStatus; extern int16_t SStatus;
extern int8_t LevelOffset; extern int8_t LevelOffset;
extern int8_t LowLevelSet; extern int8_t LowLevelSet;
+77 -21
View File
@@ -5,6 +5,17 @@
#include "constants.h" #include "constants.h"
#include <TimeLib.h> #include <TimeLib.h>
int Radiotextlengthold;
int RadiotextWidth;
int AIDlengthold;
int AIDWidth;
int afstringlengthold;
int afstringWidth;
int eonstringlengthold;
int eonstringWidth;
int rtplusstringlengthold;
int rtplusstringWidth;
void ShowAdvancedRDS() { void ShowAdvancedRDS() {
if (!dropout) { if (!dropout) {
if (radio.rds.rdsAerror) tft.fillCircle(86, 41, 5, SignificantColor); else tft.fillCircle(86, 41, 5, InsignificantColor); 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 (millis() - afticker >= 15) {
if (xPos2 == 0) { if (radio.rds.hasAF) {
if (millis() - aftickerhold >= 2000) { 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 --; xPos2 --;
aftickerhold = millis(); aftickerhold = millis();
} }
} else { } else {
xPos2 --; xPos2 = 0;
aftickerhold = millis();
} }
if (xPos2 < -tft.textWidth(afstring) + (charWidth * 14)) xPos2 = 0;
RDSSprite.fillSprite(BackgroundColor); RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(afstring, xPos2, 2); RDSSprite.drawString(afstring, xPos2, 2);
if (radio.rds.hasAF) RDSSprite.drawString(afstring, xPos2 + afstringWidth + TickerSpace, 2);
RDSSprite.pushSprite(35, 197); RDSSprite.pushSprite(35, 197);
afticker = millis(); afticker = millis();
} }
@@ -99,19 +120,29 @@ void ShowAdvancedRDS() {
} }
if (millis() - eonticker >= 15) { 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 --; xPos3 --;
eontickerhold = millis(); eontickerhold = millis();
} }
} else { } else {
xPos3 --; xPos3 = 0;
eontickerhold = millis();
} }
if (xPos3 < -tft.textWidth(eonstring) + (charWidth * 14)) xPos3 = 0;
RDSSprite.fillSprite(BackgroundColor); RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(eonstring, xPos3, 2); RDSSprite.drawString(eonstring, xPos3, 2);
if (radio.rds.hasEON) RDSSprite.drawString(eonstring, xPos3 + eonstringWidth + TickerSpace, 2);
RDSSprite.pushSprite(35, 172); RDSSprite.pushSprite(35, 172);
eonticker = millis(); eonticker = millis();
} }
@@ -127,19 +158,28 @@ void ShowAdvancedRDS() {
} }
if (millis() - rtplusticker >= 15) { if (millis() - rtplusticker >= 15) {
if (xPos4 == 0) { if (radio.rds.hasRDSplus) {
if (millis() - rtplustickerhold >= 2000) { 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 --; xPos4 --;
rtplustickerhold = millis(); rtplustickerhold = millis();
} }
} else { } else {
xPos4 --; xPos4 = 0;
rtplustickerhold = millis();
} }
if (xPos4 < -tft.textWidth(rtplusstring) + (charWidth * 14)) xPos4 = 0;
RDSSprite.fillSprite(BackgroundColor); RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(rtplusstring, xPos4, 2); RDSSprite.drawString(rtplusstring, xPos4, 2);
if (radio.rds.hasRDSplus) RDSSprite.drawString(rtplusstring, xPos4 + rtplusstringWidth + TickerSpace, 2);
RDSSprite.pushSprite(35, 146); RDSSprite.pushSprite(35, 146);
rtplusticker = millis(); rtplusticker = millis();
} }
@@ -279,12 +319,14 @@ void readRds() {
AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.fillSprite(BackgroundColor);
AdvRadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); AdvRadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); 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); AdvRadiotextSprite.pushSprite(35, 220);
} else if (!advancedRDS && radio.rds.stationText.length() < 29) { } else if (!advancedRDS && radio.rds.stationText.length() < 29) {
xPos = 0; xPos = 0;
RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.fillSprite(BackgroundColor);
RadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); RadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); 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); RadiotextSprite.pushSprite(38, 220);
} }
@@ -323,12 +365,14 @@ void readRds() {
AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.fillSprite(BackgroundColor);
AdvRadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); AdvRadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); 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); AdvRadiotextSprite.pushSprite(35, 220);
} else if (!advancedRDS && radio.rds.stationText.length() < 29) { } else if (!advancedRDS && radio.rds.stationText.length() < 29) {
xPos = 0; xPos = 0;
RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.fillSprite(BackgroundColor);
RadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); RadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos, 2); 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); RadiotextSprite.pushSprite(38, 220);
} }
@@ -561,6 +605,10 @@ void showCT() {
void showRadioText() { void showRadioText() {
if (radio.rds.hasRT && radio.rds.stationText.length() > 0) { 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) { if (advancedRDS && radio.rds.stationText.length() < 20) {
xPos = 0; xPos = 0;
AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.fillSprite(BackgroundColor);
@@ -576,7 +624,7 @@ void showRadioText() {
} else { } else {
if (millis() - rtticker >= 15) { if (millis() - rtticker >= 15) {
if (xPos == 0) { if (xPos == 0) {
if (millis() - rttickerhold >= 2000) { if (millis() - rttickerhold >= 1000) {
xPos --; xPos --;
rttickerhold = millis(); rttickerhold = millis();
} }
@@ -584,17 +632,19 @@ void showRadioText() {
xPos --; xPos --;
rttickerhold = millis(); rttickerhold = millis();
} }
if (xPos < -(RadiotextWidth + TickerSpace)) xPos = 0;
if (advancedRDS) { if (advancedRDS) {
if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 10)) xPos = 0;
AdvRadiotextSprite.fillSprite(BackgroundColor); AdvRadiotextSprite.fillSprite(BackgroundColor);
if (RDSstatus) AdvRadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); else AdvRadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); 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, 2);
AdvRadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2);
AdvRadiotextSprite.pushSprite(35, 220); AdvRadiotextSprite.pushSprite(35, 220);
} else { } else {
if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 20)) xPos = 0;
RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.fillSprite(BackgroundColor);
if (RDSstatus) RadiotextSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RadiotextSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); 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, 2);
RadiotextSprite.drawString(radio.rds.stationText + " " + radio.rds.stationText32, xPos + RadiotextWidth + TickerSpace, 2);
RadiotextSprite.pushSprite(38, 220); RadiotextSprite.pushSprite(38, 220);
} }
rtticker = millis(); rtticker = millis();
@@ -795,8 +845,14 @@ void ShowAFEON() {
aid_counterold = radio.rds.aid_counter; 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 (xPos == 0) {
if (millis() - rttickerhold >= 2000) { if (millis() - rttickerhold >= 1000) {
xPos --; xPos --;
rttickerhold = millis(); rttickerhold = millis();
} }
@@ -804,12 +860,12 @@ void ShowAFEON() {
xPos --; xPos --;
rttickerhold = millis(); rttickerhold = millis();
} }
if (xPos < -tft.textWidth(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString) + (charWidth * 14)) xPos = 0;
RadiotextSprite.fillSprite(BackgroundColor); RadiotextSprite.fillSprite(BackgroundColor);
RadiotextSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); 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, 2);
RadiotextSprite.drawString(String(myLanguage[language][93]) + " - " + String(myLanguage[language][79]) + ": " + AIDString, xPos + AIDWidth + TickerSpace, 2);
RadiotextSprite.pushSprite(5, 220); RadiotextSprite.pushSprite(5, 220);
} }
} }
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
+1 -1
View File
@@ -57,7 +57,6 @@ extern int ActiveColorSmooth;
extern int BackgroundColor; extern int BackgroundColor;
extern int BWAutoColor; extern int BWAutoColor;
extern int BWAutoColorSmooth; extern int BWAutoColorSmooth;
extern int charWidth;
extern int GreyoutColor; extern int GreyoutColor;
extern int InsignificantColor; extern int InsignificantColor;
extern int InsignificantColorSmooth; extern int InsignificantColorSmooth;
@@ -71,6 +70,7 @@ extern int SecondaryColor;
extern int SecondaryColorSmooth; extern int SecondaryColorSmooth;
extern int SignificantColor; extern int SignificantColor;
extern int SignificantColorSmooth; extern int SignificantColorSmooth;
extern int TickerSpace;
extern int xPos; extern int xPos;
extern int xPos2; extern int xPos2;
extern int xPos3; extern int xPos3;