You've already forked TEF6686_ESP32
better scroll hold, and make everything use the class
This commit is contained in:
@@ -619,6 +619,7 @@ class TEF6686 {
|
|||||||
bool togglebit;
|
bool togglebit;
|
||||||
bool runningbit;
|
bool runningbit;
|
||||||
uint8_t segments_received[16];
|
uint8_t segments_received[16];
|
||||||
|
uint8_t segments_received_lps[8];
|
||||||
bool initab;
|
bool initab;
|
||||||
bool afinit;
|
bool afinit;
|
||||||
bool errorfreepi;
|
bool errorfreepi;
|
||||||
|
|||||||
@@ -218,8 +218,6 @@ extern int Squelchold;
|
|||||||
extern int SStatusold;
|
extern int SStatusold;
|
||||||
extern int Stereostatus;
|
extern int Stereostatus;
|
||||||
extern int XDRBWset;
|
extern int XDRBWset;
|
||||||
extern int xPos;
|
|
||||||
extern int xPos2;
|
|
||||||
extern int16_t OStatus;
|
extern int16_t OStatus;
|
||||||
extern int16_t SAvg;
|
extern int16_t SAvg;
|
||||||
extern int16_t SAvg2;
|
extern int16_t SAvg2;
|
||||||
@@ -326,8 +324,6 @@ extern unsigned long ModulationpeakPreviousMillis;
|
|||||||
extern unsigned long NTPtimer;
|
extern unsigned long NTPtimer;
|
||||||
extern unsigned long peakholdmillis;
|
extern unsigned long peakholdmillis;
|
||||||
extern unsigned long processed_rdsblocksold[33];
|
extern unsigned long processed_rdsblocksold[33];
|
||||||
extern unsigned long pslongticker;
|
|
||||||
extern unsigned long pslongtickerhold;
|
|
||||||
extern unsigned long rtticker;
|
extern unsigned long rtticker;
|
||||||
extern unsigned long rttickerhold;
|
extern unsigned long rttickerhold;
|
||||||
extern unsigned long rotarytimer;
|
extern unsigned long rotarytimer;
|
||||||
@@ -358,6 +354,8 @@ extern WiFiClient RemoteClient;
|
|||||||
extern WiFiUDP Udp;
|
extern WiFiUDP Udp;
|
||||||
extern WebServer webserver;
|
extern WebServer webserver;
|
||||||
|
|
||||||
|
extern ScrollingTextDisplay aidDisplay;
|
||||||
|
extern ScrollingTextDisplay lpsDisplay;
|
||||||
extern ScrollingTextDisplay rtplusDisplay;
|
extern ScrollingTextDisplay rtplusDisplay;
|
||||||
extern ScrollingTextDisplay eonDisplay;
|
extern ScrollingTextDisplay eonDisplay;
|
||||||
extern ScrollingTextDisplay eccDisplay;
|
extern ScrollingTextDisplay eccDisplay;
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ private:
|
|||||||
bool isScrolling;
|
bool isScrolling;
|
||||||
std::function<void(TFT_eSprite*, bool)> postDrawCallback;
|
std::function<void(TFT_eSprite*, bool)> postDrawCallback;
|
||||||
int usedH;
|
int usedH;
|
||||||
|
bool hold;
|
||||||
|
int xOffset;
|
||||||
|
|
||||||
static const unsigned long SCROLL_INTERVAL = 5;
|
static const unsigned long SCROLL_INTERVAL = 5;
|
||||||
static const unsigned long HOLD_DURATION = 2000;
|
static const unsigned long HOLD_DURATION = 2000;
|
||||||
static const int SCROLL_GAP = 10;
|
static const int SCROLL_GAP = 10;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int inuseH = -1 ) :
|
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int x = 35, int inuseH = -1 ) :
|
||||||
sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedH(inuseH) {}
|
sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedH(inuseH), hold(false), xOffset(x) {}
|
||||||
|
|
||||||
void setPostDrawCallback(std::function<void(TFT_eSprite*, bool)> callback) {
|
void setPostDrawCallback(std::function<void(TFT_eSprite*, bool)> callback) {
|
||||||
postDrawCallback = callback;
|
postDrawCallback = callback;
|
||||||
@@ -39,12 +41,13 @@ public:
|
|||||||
if(!isScrolling) holdTick = millis();
|
if(!isScrolling) holdTick = millis();
|
||||||
isScrolling = true;
|
isScrolling = true;
|
||||||
if(millis() - lastTick >= SCROLL_INTERVAL) {
|
if(millis() - lastTick >= SCROLL_INTERVAL) {
|
||||||
if(xPos <= -(textWidth + SCROLL_GAP)) xPos = 0;
|
if(xPos <= -(textWidth + SCROLL_GAP)) {xPos += textWidth + SCROLL_GAP; hold = true;}
|
||||||
|
|
||||||
if(xPos == 0) {
|
if(hold) {
|
||||||
if(millis() - holdTick >= HOLD_DURATION) {
|
if(millis() - holdTick >= HOLD_DURATION) {
|
||||||
xPos--;
|
xPos--;
|
||||||
holdTick = millis();
|
holdTick = millis();
|
||||||
|
hold = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xPos--;
|
xPos--;
|
||||||
@@ -97,6 +100,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(postDrawCallback) postDrawCallback(sprite, false);
|
if(postDrawCallback) postDrawCallback(sprite, false);
|
||||||
sprite->pushSprite(35, yPos, TFT_TRANSPARENT);
|
if(yPos != 0) sprite->pushSprite(xOffset, yPos, TFT_TRANSPARENT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1486,7 +1486,11 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
|
|
||||||
case RDS_GROUP_15A: {
|
case RDS_GROUP_15A: {
|
||||||
if (pslong_process && rds.stationNameLong.length() > 0) rds.hasLongPS = true;
|
if (pslong_process && rds.stationNameLong.length() > 0) rds.hasLongPS = true;
|
||||||
uint8_t offset = (rds.rdsB & 7) * 4;
|
uint8_t segment = rds.rdsB & 7;
|
||||||
|
uint8_t offset = segment * 4;
|
||||||
|
|
||||||
|
if(segments_received_lps[segment] >= (rds.rdsCerror + rds.rdsBerror)) segments_received_lps[segment] = rds.rdsCerror + rds.rdsBerror;
|
||||||
|
else return;
|
||||||
|
|
||||||
pslong_buffer2[offset + 0] = pslong_buffer[offset + 0];
|
pslong_buffer2[offset + 0] = pslong_buffer[offset + 0];
|
||||||
pslong_buffer2[offset + 1] = pslong_buffer[offset + 1];
|
pslong_buffer2[offset + 1] = pslong_buffer[offset + 1];
|
||||||
@@ -1629,6 +1633,7 @@ void TEF6686::clearRDS(bool fullsearchrds) {
|
|||||||
afmethodBprobe = afmethodBtrigger = _hasEnhancedRT = false;
|
afmethodBprobe = afmethodBtrigger = _hasEnhancedRT = false;
|
||||||
rds.ps12error = rds.ps34error = rds.ps56error = rds.ps78error = true;
|
rds.ps12error = rds.ps34error = rds.ps56error = rds.ps78error = true;
|
||||||
memset(segments_received, 99, sizeof(segments_received));
|
memset(segments_received, 99, sizeof(segments_received));
|
||||||
|
memset(segments_received_lps, 99, sizeof(segments_received_lps));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
||||||
|
|||||||
@@ -204,8 +204,6 @@ int Squelchold;
|
|||||||
int SStatusold;
|
int SStatusold;
|
||||||
int Stereostatus;
|
int Stereostatus;
|
||||||
int XDRBWset;
|
int XDRBWset;
|
||||||
int xPos;
|
|
||||||
int xPos2;
|
|
||||||
int16_t OStatus;
|
int16_t OStatus;
|
||||||
int16_t SAvg;
|
int16_t SAvg;
|
||||||
int16_t SAvg2;
|
int16_t SAvg2;
|
||||||
@@ -312,8 +310,6 @@ unsigned long ModulationpeakPreviousMillis;
|
|||||||
unsigned long NTPtimer;
|
unsigned long NTPtimer;
|
||||||
unsigned long peakholdmillis;
|
unsigned long peakholdmillis;
|
||||||
unsigned long processed_rdsblocksold[33];
|
unsigned long processed_rdsblocksold[33];
|
||||||
unsigned long pslongticker;
|
|
||||||
unsigned long pslongtickerhold;
|
|
||||||
unsigned long rtticker;
|
unsigned long rtticker;
|
||||||
unsigned long rttickerhold;
|
unsigned long rttickerhold;
|
||||||
unsigned long rotarytimer;
|
unsigned long rotarytimer;
|
||||||
@@ -351,7 +347,9 @@ WiFiClient RemoteClient;
|
|||||||
WiFiUDP Udp;
|
WiFiUDP Udp;
|
||||||
WebServer webserver(80);
|
WebServer webserver(80);
|
||||||
|
|
||||||
ScrollingTextDisplay rtplusDisplay(&GeneralTextSprite, 147, 173, 19);
|
ScrollingTextDisplay aidDisplay(&FullLineSprite, 220, 270, 5);
|
||||||
ScrollingTextDisplay eonDisplay(&GeneralTextSprite, 174, 173, 19);
|
ScrollingTextDisplay lpsDisplay(&PSSprite, 0, 150);
|
||||||
|
ScrollingTextDisplay rtplusDisplay(&GeneralTextSprite, 147, 173, 35, 19);
|
||||||
|
ScrollingTextDisplay eonDisplay(&GeneralTextSprite, 174, 173, 35, 19);
|
||||||
ScrollingTextDisplay eccDisplay(&FullLineSprite, 198, 270);
|
ScrollingTextDisplay eccDisplay(&FullLineSprite, 198, 270);
|
||||||
ScrollingTextDisplay rtDisplay(&FullLineSprite, 220, 270);
|
ScrollingTextDisplay rtDisplay(&FullLineSprite, 220, 270);
|
||||||
10
src/gui.cpp
10
src/gui.cpp
@@ -608,9 +608,7 @@ void BuildAFScreen() {
|
|||||||
rds_clockold = "";
|
rds_clockold = "";
|
||||||
dropout = false;
|
dropout = false;
|
||||||
rdsreset = true;
|
rdsreset = true;
|
||||||
rtplusDisplay.reset();
|
aidDisplay.reset();
|
||||||
eonDisplay.reset();
|
|
||||||
eccDisplay.reset();
|
|
||||||
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;
|
||||||
@@ -2980,9 +2978,8 @@ void BuildAdvancedRDS() {
|
|||||||
dropout = false;
|
dropout = false;
|
||||||
rdsreset = true;
|
rdsreset = true;
|
||||||
ShowMemoryPos();
|
ShowMemoryPos();
|
||||||
xPos = 0;
|
|
||||||
xPos2 = 0;
|
|
||||||
rtplusDisplay.reset();
|
rtplusDisplay.reset();
|
||||||
|
lpsDisplay.reset();
|
||||||
eonDisplay.reset();
|
eonDisplay.reset();
|
||||||
eccDisplay.reset();
|
eccDisplay.reset();
|
||||||
rtDisplay.reset();
|
rtDisplay.reset();
|
||||||
@@ -3109,6 +3106,7 @@ void BuildDisplay() {
|
|||||||
BWreset = true;
|
BWreset = true;
|
||||||
dropout = false;
|
dropout = false;
|
||||||
rtplusDisplay.reset();
|
rtplusDisplay.reset();
|
||||||
|
lpsDisplay.reset();
|
||||||
eonDisplay.reset();
|
eonDisplay.reset();
|
||||||
eccDisplay.reset();
|
eccDisplay.reset();
|
||||||
rtDisplay.reset();
|
rtDisplay.reset();
|
||||||
@@ -3124,8 +3122,6 @@ void BuildDisplay() {
|
|||||||
radio.rds.hasTMC.call();
|
radio.rds.hasTMC.call();
|
||||||
radio.rds.hasCT.call();
|
radio.rds.hasCT.call();
|
||||||
radio.rds.hasRTplus.call();
|
radio.rds.hasRTplus.call();
|
||||||
xPos = 0;
|
|
||||||
xPos2 = 0;
|
|
||||||
MPold = 99;
|
MPold = 99;
|
||||||
USold = 99;
|
USold = 99;
|
||||||
}
|
}
|
||||||
|
|||||||
58
src/rds.cpp
58
src/rds.cpp
@@ -437,32 +437,9 @@ void showPS() {
|
|||||||
stationNameLongOld = stationNameLongString;
|
stationNameLongOld = stationNameLongString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle scrolling logic for long PS
|
lpsDisplay.update(stationNameLongString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
||||||
if (PSSprite.textWidth(trimTrailingSpaces(radio.rds.stationNameLong)) < 150) {
|
|
||||||
xPos2 = 0;
|
|
||||||
PSSprite.fillSprite(BackgroundColor);
|
|
||||||
PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
|
|
||||||
PSSprite.drawString(stationNameLongString, xPos2, 2);
|
|
||||||
} else {
|
|
||||||
if (millis() - pslongticker >= 5) {
|
|
||||||
if (xPos2 == 0 && millis() - pslongtickerhold < 2000) {
|
|
||||||
// Hold at position 0
|
|
||||||
} else {
|
|
||||||
xPos2--;
|
|
||||||
pslongtickerhold = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xPos2 < -PSLongWidth) xPos2 = 0;
|
|
||||||
pslongticker = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
PSSprite.fillSprite(BackgroundColor);
|
|
||||||
PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
|
|
||||||
PSSprite.drawString(stationNameLongString, xPos2 + 8, 2);
|
|
||||||
PSSprite.drawString(stationNameLongString, xPos2 + PSLongWidth, 2);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
xPos2 = 0;
|
lpsDisplay.reset();
|
||||||
PSSprite.fillSprite(BackgroundColor);
|
PSSprite.fillSprite(BackgroundColor);
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
@@ -491,7 +468,7 @@ void showPS() {
|
|||||||
if (PSold != radio.rds.stationName) ps12errorold = ps34errorold = ps56errorold = ps78errorold = true;
|
if (PSold != radio.rds.stationName) ps12errorold = ps34errorold = ps56errorold = ps78errorold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!screenmute) PSSprite.pushSprite(36, advancedRDS ? 72 : 185);
|
if (!screenmute) PSSprite.pushSprite(36, advancedRDS ? 72 : 185, TFT_TRANSPARENT);
|
||||||
|
|
||||||
if (wifi && radio.rds.stationName.length() > 0 && PSold != radio.rds.stationName) {
|
if (wifi && radio.rds.stationName.length() > 0 && PSold != radio.rds.stationName) {
|
||||||
Udp.beginPacket(remoteip, 9030);
|
Udp.beginPacket(remoteip, 9030);
|
||||||
@@ -762,34 +739,7 @@ void ShowAFEON() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FullLineSprite.textWidth(trimTrailingSpaces(AIDString)) < 270) {
|
aidDisplay.update(AIDString, true, ActiveColor, ActiveColorSmooth, 0, 0, BackgroundColor);
|
||||||
xPos = 0;
|
|
||||||
FullLineSprite.fillSprite(BackgroundColor);
|
|
||||||
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
|
|
||||||
FullLineSprite.drawString(AIDString, xPos, 2);
|
|
||||||
FullLineSprite.drawLine(283, 0, 283, 19, FrameColor);
|
|
||||||
FullLineSprite.pushSprite(5, 220);
|
|
||||||
} else {
|
|
||||||
if (millis() - rtticker >= 5) {
|
|
||||||
if (xPos < -AIDWidth) xPos = 0;
|
|
||||||
if (xPos == 0) {
|
|
||||||
if (millis() - rttickerhold >= 2000) {
|
|
||||||
xPos--;
|
|
||||||
rttickerhold = millis();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
xPos--;
|
|
||||||
rttickerhold = millis();
|
|
||||||
}
|
|
||||||
FullLineSprite.fillSprite(BackgroundColor);
|
|
||||||
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
|
|
||||||
FullLineSprite.drawString(AIDString, xPos, 2);
|
|
||||||
FullLineSprite.drawString(AIDString, xPos + AIDWidth, 2);
|
|
||||||
FullLineSprite.drawLine(314, 0, 314, 19, FrameColor);
|
|
||||||
FullLineSprite.pushSprite(5, 220);
|
|
||||||
rtticker = millis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user