partitions and also class for scrolling text, 87.3% flash usage

This commit is contained in:
2026-01-07 22:12:03 +01:00
parent 3a92d1cdf1
commit f09ff8978f
9 changed files with 124 additions and 107 deletions

View File

@@ -5,7 +5,7 @@
The version in the repository is an ongoing development. It could and will contain bugs. To make sure you use the latest fully tested firmware, check the releases! The version in the repository is an ongoing development. It could and will contain bugs. To make sure you use the latest fully tested firmware, check the releases!
# TEF6686_ESP32 # TEF6686_ESP32
Advanced Tuner software for NXP TEF668x tuners with ESP32 board\ Advanced Tuner software for NXP TEF668x tuners with ESP32 board
More information: https://www.pe5pvb.nl/tef6686/ More information: https://www.pe5pvb.nl/tef6686/
## TFT_eSPI ## TFT_eSPI

View File

@@ -461,7 +461,7 @@ typedef struct _rds_ {
uint32_t dabaffreq; uint32_t dabaffreq;
byte aid_counter; byte aid_counter;
byte fastps; byte fastps;
Detector<unsigned int, 1> ECC; Detector<unsigned int, 1> ECC{0};
bool rdsAerror; bool rdsAerror;
bool rdsBerror; bool rdsBerror;
bool rdsCerror; bool rdsCerror;

View File

@@ -13,6 +13,7 @@
#include "WiFiConnect.h" #include "WiFiConnect.h"
#include "WiFiConnectParam.h" #include "WiFiConnectParam.h"
#include "ESP32Time.h" #include "ESP32Time.h"
#include "scrolling_text.h"
#define ROTARY_PIN_A 34 #define ROTARY_PIN_A 34
#define ROTARY_PIN_B 36 #define ROTARY_PIN_B 36
@@ -245,9 +246,6 @@ extern int XDRBWset;
extern int XDRBWsetold; extern int XDRBWsetold;
extern int xPos; extern int xPos;
extern int xPos2; extern int xPos2;
extern int xPos3;
extern int xPos4;
extern int xPos5;
extern int16_t OStatus; extern int16_t OStatus;
extern int16_t SAvg; extern int16_t SAvg;
extern int16_t SAvg2; extern int16_t SAvg2;
@@ -397,3 +395,7 @@ extern WiFiServer Server;
extern WiFiClient RemoteClient; extern WiFiClient RemoteClient;
extern WiFiUDP Udp; extern WiFiUDP Udp;
extern WebServer webserver; extern WebServer webserver;
extern ScrollingTextDisplay rtplusDisplay;
extern ScrollingTextDisplay eonDisplay;
extern ScrollingTextDisplay eccDisplay;

86
include/scrolling_text.h Normal file
View File

@@ -0,0 +1,86 @@
#pragma once
#include <Arduino.h>
#include <TFT_eSPI.h>
class ScrollingTextDisplay {
private:
TFT_eSprite* sprite;
int yPos;
int maxWidth;
uint16_t backgroundColor;
int xPos;
int textWidth;
unsigned long lastTick;
unsigned long holdTick;
bool isScrolling;
static const unsigned long SCROLL_INTERVAL = 5;
static const unsigned long HOLD_DURATION = 2000;
public:
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, uint16_t bgColor)
: sprite(spr), yPos(y), maxWidth(maxW), backgroundColor(bgColor),
xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false) {}
// Update the display with new text
void update(const String& text, int width, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth) {
textWidth = width;
if (textWidth < maxWidth) {
xPos = 0;
isScrolling = false;
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth);
} else {
isScrolling = true;
if (millis() - lastTick >= SCROLL_INTERVAL) {
if (xPos < -textWidth) xPos = 0;
if (xPos == 0) {
if (millis() - holdTick >= HOLD_DURATION) {
xPos--;
holdTick = millis();
}
} else {
xPos--;
holdTick = millis();
}
drawScrollingText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth);
lastTick = millis();
}
}
}
void reset() {
xPos = 0;
holdTick = millis();
lastTick = millis();
}
void setYPosition(int y) {
yPos = y;
}
bool getIsScrolling() const {
return isScrolling;
}
private:
void drawText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth) {
sprite->fillSprite(backgroundColor);
if (status) sprite->setTextColor(activeColor, activeSmooth, false);
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
sprite->drawString(text, xPos, 2);
sprite->pushSprite(35, yPos);
}
void drawScrollingText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth) {
sprite->fillSprite(backgroundColor);
if (status) sprite->setTextColor(activeColor, activeSmooth, false);
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
sprite->drawString(text, xPos, 2);
sprite->drawString(text, xPos + textWidth, 2);
sprite->pushSprite(35, yPos);
}
};

4
maxapp.csv Normal file
View File

@@ -0,0 +1,4 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
factory, app, factory,, 0x30E000,
spiffs, data, spiffs,,0xE0000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 factory app factory 0x30E000
4 spiffs data spiffs 0xE0000

View File

@@ -13,7 +13,7 @@ platform = espressif32
upload_speed = 921600 upload_speed = 921600
board = esp32dev board = esp32dev
framework = arduino framework = arduino
board_build.partitions = huge_app.csv board_build.partitions = maxapp.csv
build_flags = build_flags =
-Wall -Wall
-Wextra -Wextra

View File

@@ -226,9 +226,6 @@ int XDRBWset;
int XDRBWsetold; int XDRBWsetold;
int xPos; int xPos;
int xPos2; int xPos2;
int xPos3;
int xPos4;
int xPos5;
int16_t OStatus; int16_t OStatus;
int16_t SAvg; int16_t SAvg;
int16_t SAvg2; int16_t SAvg2;
@@ -378,3 +375,7 @@ WiFiServer Server(7373);
WiFiClient RemoteClient; WiFiClient RemoteClient;
WiFiUDP Udp; WiFiUDP Udp;
WebServer webserver(80); WebServer webserver(80);
ScrollingTextDisplay rtplusDisplay(&RDSSprite, 146, 165, BackgroundColor);
ScrollingTextDisplay eonDisplay(&RDSSprite, 172, 165, BackgroundColor);
ScrollingTextDisplay eccDisplay(&RDSSprite, 199, 270, BackgroundColor);

View File

@@ -609,10 +609,9 @@ void BuildAFScreen() {
dropout = false; dropout = false;
rdsreset = true; rdsreset = true;
xPos = 0; xPos = 0;
xPos2 = 0; rtplusDisplay.reset();
xPos3 = 0; eonDisplay.reset();
xPos4 = 0; eccDisplay.reset();
xPos5 = 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;
@@ -2994,10 +2993,10 @@ void BuildAdvancedRDS() {
rdsreset = true; rdsreset = true;
ShowMemoryPos(); ShowMemoryPos();
xPos = 0; xPos = 0;
rtplusDisplay.reset();
eonDisplay.reset();
eccDisplay.reset();
xPos2 = 0; xPos2 = 0;
xPos3 = 0;
xPos4 = 0;
xPos5 = 0;
} }
void BuildDisplay() { void BuildDisplay() {
@@ -3114,10 +3113,10 @@ void BuildDisplay() {
BWreset = true; BWreset = true;
dropout = false; dropout = false;
xPos = 0; xPos = 0;
rtplusDisplay.reset();
eonDisplay.reset();
eccDisplay.reset();
xPos2 = 0; xPos2 = 0;
xPos3 = 0;
xPos4 = 0;
xPos5 = 0;
MPold = 99; MPold = 99;
USold = 99; USold = 99;
} }

View File

@@ -66,32 +66,7 @@ void ShowAdvancedRDS() {
eccstringWidth = RDSSprite.textWidth(ECCString); eccstringWidth = RDSSprite.textWidth(ECCString);
} }
if (eccstringWidth < 270) { eccDisplay.update(ECCString, eccstringWidth, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth);
xPos2 = 0;
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(ECCString, xPos2, 2);
RDSSprite.pushSprite(35, 199);
} else {
if (millis() - eccticker >= 5) {
if (xPos2 < -eccstringWidth) xPos2 = 0;
if (xPos2 == 0) {
if (millis() - ecctickerhold >= 2000) {
xPos2--;
ecctickerhold = millis();
}
} else {
xPos2--;
ecctickerhold = millis();
}
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(ECCString, xPos2, 2);
RDSSprite.drawString(ECCString, xPos2 + eccstringWidth, 2);
RDSSprite.pushSprite(35, 199);
eccticker = millis();
}
}
} }
ECColdString = ECCString; ECColdString = ECCString;
@@ -118,32 +93,7 @@ void ShowAdvancedRDS() {
eonstringold = eonstring; eonstringold = eonstring;
} }
if (eonstringWidth < 165) { eonDisplay.update(eonstring, eonstringWidth, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth);
xPos3 = 0;
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(eonstring, xPos3, 2);
RDSSprite.pushSprite(35, 172);
} else {
if (millis() - eonticker >= 5) {
if (xPos3 < -eonstringWidth) xPos3 = 0;
if (xPos3 == 0) {
if (millis() - eontickerhold >= 2000) {
xPos3--;
eontickerhold = millis();
}
} else {
xPos3--;
eontickerhold = millis();
}
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(eonstring, xPos3, 2);
RDSSprite.drawString(eonstring, xPos3 + eonstringWidth, 2);
RDSSprite.pushSprite(35, 172);
eonticker = millis();
}
}
String rtplusstring; String rtplusstring;
if (radio.rds.hasRTplus.get()) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : "") + " "; else rtplusstring = textUI(89); if (radio.rds.hasRTplus.get()) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : "") + " "; else rtplusstring = textUI(89);
@@ -158,32 +108,7 @@ void ShowAdvancedRDS() {
rtplusstringold = rtplusstring; rtplusstringold = rtplusstring;
} }
if (rtplusstringWidth < 165) { rtplusDisplay.update(rtplusstring, rtplusstringWidth, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth);
xPos4 = 0;
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(rtplusstring, xPos4, 2);
RDSSprite.pushSprite(35, 146);
} else {
if (millis() - rtplusticker >= 5) {
if (xPos4 < -rtplusstringWidth) xPos4 = 0;
if (xPos4 == 0) {
if (millis() - rtplustickerhold >= 2000) {
xPos4 --;
rtplustickerhold = millis();
}
} else {
xPos4 --;
rtplustickerhold = millis();
}
RDSSprite.fillSprite(BackgroundColor);
if (RDSstatus) RDSSprite.setTextColor(RDSColor, RDSColorSmooth, false); else RDSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
RDSSprite.drawString(rtplusstring, xPos4, 2);
RDSSprite.drawString(rtplusstring, xPos4 + rtplusstringWidth, 2);
RDSSprite.pushSprite(35, 146);
rtplusticker = millis();
}
}
if (TPold != radio.rds.TP) { if (TPold != radio.rds.TP) {
if (!screenmute) { if (!screenmute) {
@@ -547,30 +472,30 @@ void showPS() {
// Handle scrolling logic for long PS // Handle scrolling logic for long PS
if (PSSprite.textWidth(trimTrailingSpaces(radio.rds.stationNameLong)) < 150) { if (PSSprite.textWidth(trimTrailingSpaces(radio.rds.stationNameLong)) < 150) {
xPos5 = 0; xPos2 = 0;
PSSprite.fillSprite(BackgroundColor); PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false); PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
PSSprite.drawString(stationNameLongString, xPos5, 2); PSSprite.drawString(stationNameLongString, xPos2, 2);
} else { } else {
if (millis() - pslongticker >= 5) { if (millis() - pslongticker >= 5) {
if (xPos5 == 0 && millis() - pslongtickerhold < 2000) { if (xPos2 == 0 && millis() - pslongtickerhold < 2000) {
// Hold at position 0 // Hold at position 0
} else { } else {
xPos5--; xPos2--;
pslongtickerhold = millis(); pslongtickerhold = millis();
} }
if (xPos5 < -PSLongWidth) xPos5 = 0; if (xPos2 < -PSLongWidth) xPos2 = 0;
pslongticker = millis(); pslongticker = millis();
} }
PSSprite.fillSprite(BackgroundColor); PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false); PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
PSSprite.drawString(stationNameLongString, xPos5 + 8, 2); PSSprite.drawString(stationNameLongString, xPos2 + 8, 2);
PSSprite.drawString(stationNameLongString, xPos5 + PSLongWidth, 2); PSSprite.drawString(stationNameLongString, xPos2 + PSLongWidth, 2);
} }
} else { } else {
xPos5 = 0; xPos2 = 0;
PSSprite.fillSprite(BackgroundColor); PSSprite.fillSprite(BackgroundColor);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {