- Fixed clock
- Fixed double mapped frequencies in EON
- All tickers now first freeze before scrolling
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-07-13 23:49:36 +02:00
parent 8461660782
commit e1f763f557
3 changed files with 51 additions and 24 deletions

View File

@@ -124,6 +124,7 @@ byte menupagestotal = 4;
byte MSold; byte MSold;
byte optenc; byte optenc;
byte rdsblockold; byte rdsblockold;
byte rds_minuteold = 254;
byte region; byte region;
byte regionold; byte regionold;
byte rotarymode; byte rotarymode;
@@ -269,8 +270,11 @@ unsigned int SWHighEdgeSet;
unsigned int SWLowEdgeSet; unsigned int SWLowEdgeSet;
unsigned long peakholdmillis; unsigned long peakholdmillis;
unsigned long afticker; unsigned long afticker;
unsigned long aftickerhold;
unsigned long eonticker; unsigned long eonticker;
unsigned long eontickerhold;
unsigned long rtticker; unsigned long rtticker;
unsigned long rttickerhold;
unsigned long rtplusticker; unsigned long rtplusticker;
TEF6686 radio; TEF6686 radio;
@@ -418,7 +422,7 @@ void setup() {
if (rotarymode == 0) rotarymode = 1; else rotarymode = 0; if (rotarymode == 0) rotarymode = 1; else rotarymode = 0;
EEPROM.writeByte(39, rotarymode); EEPROM.writeByte(39, rotarymode);
EEPROM.commit(); EEPROM.commit();
analogWrite(CONTRASTPIN, ContrastSet * 2 + 27); analogWrite(CONTRASTPIN, ContrastSet * 2 + 27);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.fillScreen(BackgroundColor); tft.fillScreen(BackgroundColor);
tft.setTextColor(ActiveColor); tft.setTextColor(ActiveColor);
@@ -437,7 +441,7 @@ void setup() {
} }
EEPROM.writeByte(38, displayflip); EEPROM.writeByte(38, displayflip);
EEPROM.commit(); EEPROM.commit();
analogWrite(CONTRASTPIN, ContrastSet * 2 + 27); analogWrite(CONTRASTPIN, ContrastSet * 2 + 27);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.fillScreen(BackgroundColor); tft.fillScreen(BackgroundColor);
tft.setTextColor(ActiveColor); tft.setTextColor(ActiveColor);
@@ -448,7 +452,7 @@ void setup() {
if (digitalRead(BANDBUTTON) == LOW) { if (digitalRead(BANDBUTTON) == LOW) {
analogWrite(SMETERPIN, 511); analogWrite(SMETERPIN, 511);
analogWrite(CONTRASTPIN, ContrastSet * 2 + 27); analogWrite(CONTRASTPIN, ContrastSet * 2 + 27);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.fillScreen(BackgroundColor); tft.fillScreen(BackgroundColor);
tft.setTextColor(ActiveColor); tft.setTextColor(ActiveColor);
@@ -459,7 +463,7 @@ void setup() {
} }
if (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == HIGH) { if (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, ContrastSet * 2 + 27); analogWrite(CONTRASTPIN, ContrastSet * 2 + 27);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.fillScreen(BackgroundColor); tft.fillScreen(BackgroundColor);
tft.setTextColor(ActiveColor); tft.setTextColor(ActiveColor);
@@ -477,7 +481,7 @@ void setup() {
} }
if (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == LOW) { if (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == LOW) {
analogWrite(CONTRASTPIN, ContrastSet * 2 + 27); analogWrite(CONTRASTPIN, ContrastSet * 2 + 27);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.fillScreen(BackgroundColor); tft.fillScreen(BackgroundColor);
tft.setTextColor(ActiveColor); tft.setTextColor(ActiveColor);
@@ -3166,7 +3170,15 @@ void ShowAdvancedRDS() {
hasafold = radio.rds.hasAF; hasafold = radio.rds.hasAF;
} }
if (millis() - afticker >= 500) { if (millis() - afticker >= 500) {
xPos2 -= charWidth; if (xPos2 == 6) {
if (millis() - aftickerhold >= 2000) {
xPos2 -= charWidth;
aftickerhold = millis();
}
} else {
xPos2 -= charWidth;
aftickerhold = millis();
}
if (xPos2 < -tft.textWidth(afstring) + (charWidth * 14)) xPos2 = 6; if (xPos2 < -tft.textWidth(afstring) + (charWidth * 14)) xPos2 = 6;
sprite2.setFreeFont(FONT7); sprite2.setFreeFont(FONT7);
sprite2.setTextDatum(ML_DATUM); sprite2.setTextDatum(ML_DATUM);
@@ -3178,14 +3190,22 @@ void ShowAdvancedRDS() {
} }
String eonstring; String eonstring;
if (radio.rds.hasEON) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "")+ (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "")+ (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? " " : " | "); else eonstring = myLanguage[language][88]; if (radio.rds.hasEON) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? " " : " | "); else eonstring = myLanguage[language][88];
if (haseonold != radio.rds.hasEON) { if (haseonold != radio.rds.hasEON) {
if (radio.rds.hasEON) tft.setTextColor(SecondaryColor); else tft.setTextColor(GreyoutColor); if (radio.rds.hasEON) tft.setTextColor(SecondaryColor); else tft.setTextColor(GreyoutColor);
tft.drawString("EON", 148, 45, GFXFF); tft.drawString("EON", 148, 45, GFXFF);
haseonold = radio.rds.hasEON; haseonold = radio.rds.hasEON;
} }
if (millis() - eonticker >= 500) { if (millis() - eonticker >= 500) {
xPos3 -= charWidth; if (xPos3 == 6) {
if (millis() - eontickerhold >= 2000) {
xPos3 -= charWidth;
eontickerhold = millis();
}
} else {
xPos3 -= charWidth;
eontickerhold = millis();
}
if (xPos3 < -tft.textWidth(eonstring) + (charWidth * 14)) xPos3 = 6; if (xPos3 < -tft.textWidth(eonstring) + (charWidth * 14)) xPos3 = 6;
sprite2.setFreeFont(FONT7); sprite2.setFreeFont(FONT7);
sprite2.setTextDatum(ML_DATUM); sprite2.setTextDatum(ML_DATUM);
@@ -3255,24 +3275,22 @@ void ShowAdvancedRDS() {
MSold = radio.rds.MS; MSold = radio.rds.MS;
} }
if (radio.rds.hasCT == true) { if (radio.rds.hasCT == true && radio.rds.minutes != rds_minuteold) {
int timeoffset; int timeoffset;
if (radio.rds.offsetplusmin == true) timeoffset = (-1 * radio.rds.offset) / 2; else timeoffset = radio.rds.offset / 2; if (radio.rds.offsetplusmin == true) timeoffset = (-1 * radio.rds.offset) / 2; else timeoffset = radio.rds.offset / 2;
byte rdshour = radio.rds.hours + timeoffset; uint16_t rdshour = radio.rds.hour + timeoffset;
rdshour = (((int)rdshour + 24) % 24); rdshour = (((int)rdshour + 24) % 24);
setTime(rdshour, radio.rds.minutes, 0, 0, 0, 0); setTime(rdshour, radio.rds.minutes, 0, 0, 0, 0);
rds_clock = ((hour() < 10 ? "0" : "") + String(hour()) + ":" + (minute() < 10 ? "0" : "") + String(minute())); rds_clock = ((hour() < 10 ? "0" : "") + String(hour()) + ":" + (minute() < 10 ? "0" : "") + String(minute()));
} else {
rds_clock = "";
}
if (rds_clock != rds_clockold) {
tft.setFreeFont(FONT7); tft.setFreeFont(FONT7);
tft.setTextColor(BackgroundColor); tft.setTextColor(BackgroundColor);
tft.drawRightString(rds_clockold, 205, 105, GFXFF); tft.drawRightString(rds_clockold, 205, 105, GFXFF);
if (radio.rds.hasCT == true) tft.setTextColor(SecondaryColor); else tft.setTextColor(GreyoutColor); tft.drawString("CT", 62, 45, GFXFF); if (radio.rds.hasCT == true) tft.setTextColor(SecondaryColor); else tft.setTextColor(GreyoutColor); tft.drawString("CT", 62, 45, GFXFF);
tft.drawRightString(rds_clock, 205, 105, GFXFF); tft.drawRightString(rds_clock, 205, 105, GFXFF);
rds_clockold = rds_clock; rds_clockold = rds_clock;
rds_minuteold = radio.rds.minutes;
} }
if (rdsblockold != radio.rdsblock) { if (rdsblockold != radio.rdsblock) {
@@ -3499,7 +3517,16 @@ void showPS() {
void showRadioText() { void showRadioText() {
if (radio.rds.hasRT && RDSstatus) { if (radio.rds.hasRT && RDSstatus) {
if (millis() - rtticker >= 350) { if (millis() - rtticker >= 350) {
xPos -= charWidth; if (xPos == 6) {
if (millis() - rttickerhold >= 2000) {
xPos -= charWidth;
rttickerhold = millis();
}
} else {
xPos -= charWidth;
rttickerhold = millis();
}
if (advancedRDS) { if (advancedRDS) {
if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 14)) xPos = 6; if (xPos < -tft.textWidth(radio.rds.stationText + " " + radio.rds.stationText32) + (charWidth * 14)) xPos = 6;
sprite2.setFreeFont(FONT7); sprite2.setFreeFont(FONT7);
@@ -3873,8 +3900,10 @@ void BuildAdvancedRDS() {
tft.drawCircle(86, 15, 9, PrimaryColor); tft.drawCircle(86, 15, 9, PrimaryColor);
} }
tft.setTextColor(GreyoutColor);
tft.setFreeFont(FONT7); tft.setFreeFont(FONT7);
tft.setTextColor(SecondaryColor);
if (radio.rds.hasCT) tft.drawRightString(rds_clockold, 205, 105, GFXFF);
tft.setTextColor(GreyoutColor);
tft.drawString("TP", 6, 45, GFXFF); tft.drawString("TP", 6, 45, GFXFF);
tft.drawString("TA", 24, 45, GFXFF); tft.drawString("TA", 24, 45, GFXFF);
tft.drawString("AF", 42, 45, GFXFF); tft.drawString("AF", 42, 45, GFXFF);
@@ -3894,7 +3923,7 @@ void BuildAdvancedRDS() {
rssiold = 2000; rssiold = 2000;
rdsblockold = 33; rdsblockold = 33;
batteryold = 6; batteryold = 6;
rds_clockold = "";
strcpy(programTypePrevious, "0"); strcpy(programTypePrevious, "0");
strcpy(radioIdPrevious, "0"); strcpy(radioIdPrevious, "0");
programServicePrevious = "0"; programServicePrevious = "0";
@@ -4119,7 +4148,6 @@ void BuildDisplay() {
SNRold = 254; SNRold = 254;
af_counterold = 254; af_counterold = 254;
batteryold = 6; batteryold = 6;
rds_clockold = "";
strcpy(programTypePrevious, "0"); strcpy(programTypePrevious, "0");
strcpy(radioIdPrevious, "0"); strcpy(radioIdPrevious, "0");
programServicePrevious = "0"; programServicePrevious = "0";

View File

@@ -526,7 +526,6 @@ void TEF6686::readRDS(bool showrdserrors)
if (rds.correct) { if (rds.correct) {
// CT // CT
uint32_t mjd; uint32_t mjd;
rds.hasCT = true;
mjd = (rds.rdsB & 0x03); mjd = (rds.rdsB & 0x03);
mjd <<= 15; mjd <<= 15;
mjd += ((rds.rdsC >> 1) & 0x7FFF); mjd += ((rds.rdsC >> 1) & 0x7FFF);
@@ -545,8 +544,8 @@ void TEF6686::readRDS(bool showrdserrors)
rds.months = M + 2 - (12 * J); rds.months = M + 2 - (12 * J);
rds.years = 100 * (C - 49) + Y + J; rds.years = 100 * (C - 49) + Y + J;
rds.hours = (rds.rdsD >> 12) & 0x0f; rds.hour = ((rds.rdsD >> 12) & 0x0f);
rds.hours += (rds.rdsC << 4) & 0x0010; rds.hour += ((rds.rdsC << 4) & 0x0010);
rds.minutes = (rds.rdsD >> 6) & 0x3f; rds.minutes = (rds.rdsD >> 6) & 0x3f;
rds.offsetplusmin = bitRead(rds.rdsD, 5); rds.offsetplusmin = bitRead(rds.rdsD, 5);
rds.offset = (rds.rdsD & 0x3f); rds.offset = (rds.rdsD & 0x3f);
@@ -668,9 +667,9 @@ void TEF6686::readRDS(bool showrdserrors)
if (eon[position].mappedfreq == 0) { if (eon[position].mappedfreq == 0) {
eon[position].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array eon[position].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array
} else { } else {
if (eon[position].mappedfreq2 == 0) { if (eon[position].mappedfreq2 == 0 && eon[position].mappedfreq != (rds.rdsC & 0xFF) * 10 + 8750) {
eon[position].mappedfreq2 = ((rds.rdsC & 0xFF) * 10 + 8750); eon[position].mappedfreq2 = ((rds.rdsC & 0xFF) * 10 + 8750);
} else if (eon[position].mappedfreq3 == 0) { } else if (eon[position].mappedfreq3 == 0 && eon[position].mappedfreq != (rds.rdsC & 0xFF) * 10 + 8750 && eon[position].mappedfreq2 != (rds.rdsC & 0xFF) * 10 + 8750) {
eon[position].mappedfreq3 = ((rds.rdsC & 0xFF) * 10 + 8750); eon[position].mappedfreq3 = ((rds.rdsC & 0xFF) * 10 + 8750);
} }
} }

View File

@@ -107,7 +107,7 @@ typedef struct _rds_ {
String PTYN; String PTYN;
char stationType[18]; char stationType[18];
char picode[6]; char picode[6];
uint16_t hours, minutes, days, months, years, offsetplusmin, rdsA, rdsB, rdsC, rdsD, rdsErr; uint16_t hour, minutes, days, months, years, offsetplusmin, rdsA, rdsB, rdsC, rdsD, rdsErr;
int8_t offset; int8_t offset;
unsigned int ECC; unsigned int ECC;
unsigned int LIC; unsigned int LIC;