even faster boot up and completly new start screen

This commit is contained in:
2026-01-14 20:57:32 +01:00
parent 77b7f45d90
commit f5a03c7e6c
30 changed files with 7313 additions and 7758 deletions

View File

@@ -8,7 +8,7 @@
uint8_t dropped_groups = 0;
bool lastBitState = false;
uint16_t TEF6686::getBlockA(void) {
uint16_t TEF6686::getBlockA() {
uint16_t blockA;
devTEF_Radio_Get_RDS_Status(NULL, &blockA, NULL, NULL, NULL, NULL);
return blockA;
@@ -106,7 +106,7 @@ uint16_t TEF6686::TestAF() {
void TEF6686::init(byte TEF) {
Tuner_Reset();
while(devTEF_APPL_Get_Operation_Status() != 0) delay(5);
while(devTEF_APPL_Get_Operation_Status() != 0) delay(2);
uint32_t clock = 12000000;
@@ -125,12 +125,12 @@ void TEF6686::init(byte TEF) {
// Start the firmware
devTEF_Set_Cmd(TEF_INIT, 0, 0);
while(devTEF_APPL_Get_Operation_Status() != 1) delay(5); // Wait for it to load
while(devTEF_APPL_Get_Operation_Status() != 1) delay(2); // Wait for it to load
if(clock != 9216000) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_ReferenceClock, 6, (clock >> 16) & 0xffff, clock & 0xffff, (clock == 55466670) ? 1 : 0);
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_Activate, 2, 1); // Setup done, start radio
while(devTEF_APPL_Get_Operation_Status() != 2) delay(5); // Wait for it to start
while(devTEF_APPL_Get_Operation_Status() != 2) delay(2); // Wait for it to start
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 6, 0, 360, 300);
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 4, 0, 4000);
@@ -156,7 +156,6 @@ void TEF6686::getIdentification(uint16_t *device, uint16_t *hw_version, uint16_t
void TEF6686::power(bool mode) {
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_OperationMode, 2, mode);
if (mode == 0) devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 1, 10000);
}
void TEF6686::extendBW(bool yesno) {
@@ -164,7 +163,7 @@ void TEF6686::extendBW(bool yesno) {
}
void TEF6686::SetFreq(uint16_t frequency) {
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, frequency);
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 1, frequency);
currentfreq = ((frequency + 5) / 10) * 10;
currentfreq2 = frequency;
}
@@ -359,9 +358,9 @@ void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel,
void TEF6686::readRDS(byte showrdserrors) {
if(rds.filter && ps_process) devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
else {
for(int i = 0; i < 3; i++) {
for(int i = 0; i < 4; i++) {
devTEF_Radio_Get_RDS_Data(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
delay(2);
delay(1);
if(bitRead(rds.rdsStat, 15)) break;
}
}
@@ -437,7 +436,7 @@ void TEF6686::readRDS(byte showrdserrors) {
fs::File file;
if (rds.region == 1 && SPIFFS.begin(true)) {
delay(5);
delay(2);
if (currentfreq2 < 9000) file = SPIFFS.open("/USA_87-90.csv");
else if (currentfreq2 > 9000 && currentfreq2 < 9200) file = SPIFFS.open("/USA_90-92.csv");
else if (currentfreq2 > 9200 && currentfreq2 < 9400) file = SPIFFS.open("/USA_92-94.csv");
@@ -449,7 +448,7 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (currentfreq2 > 10400 && currentfreq2 < 10600) file = SPIFFS.open("/USA_104-106.csv");
else if (currentfreq2 > 10600) file = SPIFFS.open("/USA_106-108.csv");
delay(5);
delay(2);
if (file) {
int i = 0;
while (file.available() && !isprint(file.peek())) {
@@ -1312,21 +1311,21 @@ void TEF6686::readRDS(byte showrdserrors) {
uint16_t length_marker_1 = (rds.rdsC >> 1) & 0x3F;
uint16_t start_marker_2 = (rds.rdsD >> 5) & 0x3F;
uint16_t length_marker_2 = (rds.rdsD & 0x1F);
togglebit = bitRead(lowByte(rds.rdsB), 4);
runningbit = bitRead(lowByte(rds.rdsB), 3);
togglebit = bitRead(rds.rdsB, 4);
runningbit = bitRead(rds.rdsB, 3);
switch (rds.rdsplusTag1) {
case 0: rds.rdsplusTag1 = 169; break;
case 1 ... 53: rds.rdsplusTag1 += 111; break;
case 59 ... 63: rds.rdsplusTag1 += 105; break;
default: rds.rdsplusTag1 = 169; break;
case 0: rds.rdsplusTag1 = 168; break;
case 1 ... 53: rds.rdsplusTag1 += 110; break;
case 59 ... 63: rds.rdsplusTag1 += 104; break;
default: rds.rdsplusTag1 = 168; break;
}
switch (rds.rdsplusTag2) {
case 0: rds.rdsplusTag2 = 169; break;
case 1 ... 53: rds.rdsplusTag2 += 111; break;
case 59 ... 63: rds.rdsplusTag2 += 105; break;
default: rds.rdsplusTag2 = 169; break;
case 0: rds.rdsplusTag2 = 168; break;
case 1 ... 53: rds.rdsplusTag2 += 110; break;
case 59 ... 63: rds.rdsplusTag2 += 104; break;
default: rds.rdsplusTag2 = 168; break;
}
if (togglebit) {

View File

@@ -32,7 +32,7 @@ bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t l
uint8_t devTEF_APPL_Get_Operation_Status() {
uint8_t buf[2];
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(2);
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(3);
return Convert8bto16b(buf);
}

View File

@@ -9,7 +9,7 @@ bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
Wire.beginTransmission(TEF668X_ADDRESS);
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
uint8_t r = Wire.endTransmission();
if (!Data_Accelerator) delay(2);
if (!Data_Accelerator) delay(1);
return (r == 0) ? true : false;
}

View File

@@ -778,7 +778,7 @@ void XDRGTKRoutine() {
if (!screenmute) {
tft.drawRoundRect(10, 30, 300, 170, 5, ActiveColor);
tft.fillRoundRect(12, 32, 296, 166, 5, BackgroundColor);
tftPrint(ACENTER, textUI(34), 160, 100, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(33), 160, 100, ActiveColor, ActiveColorSmooth, 28);
}
DataPrint("U");
@@ -905,7 +905,7 @@ void tryWiFi() {
if (!setupmode && wifi) {
tft.drawRoundRect(1, 20, 319, 180, 5, ActiveColor);
tft.fillRoundRect(3, 22, 315, 176, 5, BackgroundColor);
Infoboxprint(textUI(55));
Infoboxprint(textUI(54));
}
if (wifi) {
if (wc.autoConnect()) {
@@ -917,9 +917,9 @@ void tryWiFi() {
webserver.begin();
NTPupdate();
remoteip = IPAddress(WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
if (!setupmode) tftPrint(ACENTER, textUI(57), 155, 128, InsignificantColor, InsignificantColorSmooth, 28);
if (!setupmode) tftPrint(ACENTER, textUI(56), 155, 128, InsignificantColor, InsignificantColorSmooth, 28);
} else {
if (!setupmode) tftPrint(ACENTER, textUI(56), 155, 128, SignificantColor, SignificantColorSmooth, 28);
if (!setupmode) tftPrint(ACENTER, textUI(55), 155, 128, SignificantColor, SignificantColorSmooth, 28);
Server.end();
webserver.stop();
Udp.stop();

View File

@@ -25,7 +25,6 @@ bool memorystore;
bool memreset, memtune;
bool menu, menuopen;
bool mwstepsize;
bool optenc;
bool rdsflagreset;
bool rdsreset;
bool rdsstatscreen;

File diff suppressed because it is too large Load Diff

View File

@@ -41,9 +41,9 @@ void handleRoot() {
html += "<img src=\"/logo.png\" alt=\"FMDX website\">";
html += "</a>";
html += "<h1>" + String(textUI(286)) + "</h1>";
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(287)) + "</button>";
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(289)) + "</button>";
html += "<h1>" + String(textUI(285)) + "</h1>";
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(286)) + "</button>";
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(288)) + "</button>";
// Sorting function with icons
html += "<script>";
@@ -143,9 +143,9 @@ void handleRoot() {
}
file.close();
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(299)) + "</td></tr>";
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(298)) + "</td></tr>";
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(288)) + "</td></tr>";
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(287)) + "</td></tr>";
html += "</table>";
html += "</body></html>";

View File

@@ -20,8 +20,12 @@ using fs::FS;
#include "touch.h"
#include "nonvolatile.h"
#include "utils.h"
#include "system_console.h"
#pragma endregion
Console console(&tft);
bool gpio_chip = false;
#pragma region to move
void Round30K(unsigned int freq) {
if (freq % FREQ_OIRT_STEP_30K == 1) frequency_OIRT = (freq + 1);
@@ -59,13 +63,6 @@ void Touch_IRQ_Handler() {
}
void deepSleep() {
#ifdef SMETERPIN
analogWrite(SMETERPIN, 0);
#endif
#ifdef STANDBYLED
pinMode(STANDBYLED, OUTPUT);
digitalWrite(STANDBYLED, LOW);
#endif
MuteScreen(1);
StoreFrequency();
radio.power(1);
@@ -108,9 +105,7 @@ void EdgeBeeper() {
const char* textUI(uint16_t number) {
if (number >= language_entrynumber) return "Overflow";
else {
return (const char*)pgm_read_ptr(&(myLanguage[language][number]));
}
else return (const char*)pgm_read_ptr(&(myLanguage[language][number]));
}
void doBWtuneUp() {
@@ -158,13 +153,10 @@ void ShowRSSI() {
if (wifi) rssi = WiFi.RSSI(); else rssi = 0;
if (rssiold != rssi) {
rssiold = rssi;
if (!wifi && batterydetect) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, BackgroundColor);
} else if (rssi == 0) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
} else if (rssi > -50 && rssi < 0) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, WifiColorHigh);
} else if (rssi > -60) {
if (!wifi && batterydetect) tft.drawBitmap(282, 3, WiFi4, 30, 25, BackgroundColor);
else if (rssi == 0) tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
else if (rssi > -50 && rssi < 0) tft.drawBitmap(282, 3, WiFi4, 30, 25, WifiColorHigh);
else if (rssi > -60) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
tft.drawBitmap(282, 3, WiFi3, 30, 25, WifiColorHigh);
} else if (rssi > -70) {
@@ -245,7 +237,7 @@ void SetTunerPatch() {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
if(FORBIDDEN_TUNER(TEF)) {
tftPrint(ACENTER, textUI(35), 150, 78, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(34), 150, 78, ActiveColor, ActiveColorSmooth, 28);
for (;;);
}
EEPROM.writeByte(EE_BYTE_TEF, TEF);
@@ -556,7 +548,7 @@ void BANDBUTTONPress() {
}
}
while (digitalRead(BANDBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void LimitAMFrequency() {
@@ -615,7 +607,7 @@ void BWButtonPress() {
}
}
while (digitalRead(BWBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void doStereoToggle() {
@@ -830,7 +822,7 @@ void ShowNum(int val) {
byte numval[16] = {2, 3, 127, 5, 6, 0, 9, 13, 8, 7, 4, 1, 0, 0, 0, 0};
int GetNum() {
if(!gpio_chip) return -1;
// Get input port 0 and 1
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x00);
@@ -1156,9 +1148,11 @@ void setup() {
setupmode = true;
bool tef_found = false;
Wire.begin();
Wire.setClock(400000);
delay(3);
delay(1);
Serial.begin(115200);
Serial.println();
@@ -1174,9 +1168,13 @@ void setup() {
if(address == RX8010SJ_ADDRESS) {
Serial.print(" RTC");
rx_rtc_avail = true;
} else if(address == TEF668X_ADDRESS) {
Serial.print(" TEF");
tef_found = true;
} else if(address == XL9555_ADDRESS) {
Serial.print(" GPIO");
gpio_chip = true;
}
else if(address == TEF668X_ADDRESS) Serial.print(" TEF");
else if(address == XL9555_ADDRESS) Serial.print(" GPIO");
Serial.println(" !");
} else if (error == 4) {
Serial.print("Unknown error at 0x");
@@ -1185,26 +1183,6 @@ void setup() {
}
}
rtc.setTime(0);
if(rx_rtc_avail) {
bool reset = rx_rtc.initModule(); // initModule, not initAdapter, adapter also reinits wire
if(reset) {
RX8010SJ::DateTime defaulttime = RX8010SJ::DateTime();
defaulttime.second = 00;
defaulttime.minute = 00;
defaulttime.hour = 18;
defaulttime.dayOfWeek = 1;
defaulttime.dayOfMonth = 13;
defaulttime.month = 1;
defaulttime.year = 26;
Serial.println("RTC reset with defaults");
rx_rtc.writeDateTime(defaulttime);
} else {
rtcset = true;
sync_from_rx_rtc();
}
}
Serial.flush();
Serial.end();
@@ -1268,19 +1246,8 @@ void setup() {
doTheme();
if (displayflip == 0) {
#ifdef ARS
tft.setRotation(0);
#else
tft.setRotation(3);
#endif
} else {
#ifdef ARS
tft.setRotation(2);
#else
tft.setRotation(1);
#endif
}
if (displayflip == 0) tft.setRotation(3);
else tft.setRotation(1);
tft.invertDisplay(!invertdisplay);
@@ -1290,10 +1257,6 @@ void setup() {
pinMode(ROTARY_BUTTON, INPUT);
pinMode(ROTARY_PIN_A, INPUT);
pinMode(ROTARY_PIN_B, INPUT);
#ifdef STANDBYLED
pinMode(STANDBYLED, OUTPUT);
digitalWrite(STANDBYLED, HIGH);
#endif
pinMode(TOUCHIRQ, INPUT);
pinMode(EXT_IRQ, INPUT_PULLUP);
@@ -1302,7 +1265,6 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE);
tft.setSwapBytes(true);
tft.fillScreen(BackgroundColor);
SPIFFS.begin();
@@ -1342,6 +1304,7 @@ void setup() {
SignalSprite.setSwapBytes(true);
UpdateFonts();
tft.fillScreen(BackgroundColor);
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
if (rotarymode == 0) rotarymode = 1; else rotarymode = 0;
@@ -1356,18 +1319,10 @@ void setup() {
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
if (displayflip == 0) {
displayflip = 1;
#ifdef ARS
tft.setRotation(2);
#else
tft.setRotation(1);
#endif
} else {
displayflip = 0;
#ifdef ARS
tft.setRotation(0);
#else
tft.setRotation(3);
#endif
}
EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, displayflip);
EEPROM.commit();
@@ -1378,37 +1333,16 @@ void setup() {
}
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == LOW) {
#ifdef SMETERPIN
analogWrite(SMETERPIN, 511);
#endif
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(4));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(BANDBUTTON) == LOW) delay(50);
#ifdef SMETERPIN
analogWrite(SMETERPIN, 0);
#endif
}
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == LOW && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
if (optenc == 0) {
optenc = 1;
Infoboxprint(textUI(6));
} else {
optenc = 0;
Infoboxprint(textUI(7));
}
EEPROM.writeByte(EE_BYTE_OPTENC, optenc);
EEPROM.commit();
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(ROTARY_BUTTON) == LOW) delay(50);
}
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == LOW && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
DefaultSettings();
Infoboxprint(textUI(66));
Infoboxprint(textUI(65));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == LOW) delay(50);
esp_restart();
@@ -1416,8 +1350,8 @@ void setup() {
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(282));
tftPrint(ACENTER, textUI(283), 155, 100, ActiveColor, ActiveColorSmooth, 28);
Infoboxprint(textUI(281));
tftPrint(ACENTER, textUI(282), 155, 100, ActiveColor, ActiveColorSmooth, 28);
tft.calibrateTouch(TouchCalData, PrimaryColor, BackgroundColor, 30);
EEPROM.writeUInt(EE_UINT16_CALTOUCH1, TouchCalData[0]);
EEPROM.writeUInt(EE_UINT16_CALTOUCH2, TouchCalData[1]);
@@ -1429,7 +1363,7 @@ void setup() {
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == LOW) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(69));
Infoboxprint(textUI(68));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
invertdisplay = !invertdisplay;
tft.invertDisplay(!invertdisplay);
@@ -1440,26 +1374,58 @@ void setup() {
tft.setTouch(TouchCalData);
tft.fillScreen(BackgroundColor);
tftPrint(ACENTER, textUI(8), 160, 3, PrimaryColor, PrimaryColorSmooth, 28);
tftPrint(ACENTER, "Firmware " + String(VERSION), 160, 152, PrimaryColor, PrimaryColorSmooth, 16);
tft.fillScreen(TFT_BLACK);
tft.fillRect(120, 230, 16, 6, GreyoutColor);
tft.fillRect(152, 230, 16, 6, GreyoutColor);
tft.fillRect(184, 230, 16, 6, GreyoutColor);
tft.pushImage(78, 34, 163, 84, radiologo);
tft.drawBitmap(130, 124, TEFLogo, 59, 23, ActiveColor);
tft.pushImage((tft.width() - 163) / 2, (tft.height() - 84) / 2, 163, 84, radiologo, TFT_BLACK);
tft.drawBitmap((tft.width() - 59) / 2, 24, TEFLogo, 59, 23, ActiveColor);
for (int x = 0; x <= ContrastSet; x++) {
analogWrite(CONTRASTPIN, map(x, 0, 100, 15, 255));
delay(10);
}
tft.fillRect(120, 230, 16, 6, PrimaryColor);
console.print("Firmware " + String(VERSION));
if(!tef_found) {
console.print(textUI(8));
while (true) delay(1);
}
rtc.setTime(0);
if(rx_rtc_avail) {
bool reset = rx_rtc.initModule(); // initModule, not initAdapter, adapter also reinits wire
if(reset) {
RX8010SJ::DateTime defaulttime = RX8010SJ::DateTime();
defaulttime.second = 00;
defaulttime.minute = 5;
defaulttime.hour = 19;
defaulttime.dayOfWeek = 2;
defaulttime.dayOfMonth = 14;
defaulttime.month = 1;
defaulttime.year = 26;
rx_rtc.writeDateTime(defaulttime);
console.print("RX8010SJ was reset, no time");
} else {
rtcset = true;
console.print("RX8010SJ is used as a time source");
sync_from_rx_rtc();
}
} else console.print("RX8010SJ is not available at address " + String(RX8010SJ_ADDRESS, HEX));
if(gpio_chip) {
console.print("XL9555 found, setting up");
// Configures the GPIO chip for input in every pin
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x06);
Wire.write(0xFF);
Wire.write(0xFF);
Wire.endTransmission();
} else console.print("XL9555 found not found on address " + String(XL9555_ADDRESS, HEX) + ". Numpad will not work");
TEF = EEPROM.readByte(EE_BYTE_TEF);
if(FORBIDDEN_TUNER(TEF)) SetTunerPatch();
// The tuner being missing here, would cause a infinite loop with no exit and no error, as it resets and polls the chip if it reset, if no response then we try again, and now, you see?
radio.init(TEF);
uint16_t device, hw, sw;
@@ -1470,55 +1436,46 @@ void setup() {
fullsearchrds = false;
fmsi = false;
chipmodel = 0;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6686 Lithio", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6686 Lithio");
#ifndef DEEPELEC_DP_66X
} else if (lowByte(device) == 1) {
fullsearchrds = true;
chipmodel = 1;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6687 Lithio FMSI", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6687 Lithio FMSI");
} else if (lowByte(device) == 9) {
fullsearchrds = false;
chipmodel = 2;
fmsi = false;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6688 Lithio DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6688 Lithio DR");
} else if (lowByte(device) == 3) {
fullsearchrds = true;
chipmodel = 3;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6689 Lithio FMSI DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6689 Lithio FMSI DR");
#endif
} else {
tftPrint(ACENTER, textUI(9), 160, 172, SignificantColor, SignificantColorSmooth, 28);
tft.fillRect(152, 230, 16, 6, SignificantColor);
while (true);
}
tftPrint(ACENTER, "Patch: v" + String(TEF) + " HW " + String(hw >> 8) + "." + String(hw & 0xff) + " SW " + String(sw >> 8) + "." + String(sw & 0xff), 160, 202, ActiveColor, ActiveColorSmooth, 16);
console.print("Chip Patch: v" + String(TEF) + " HW " + String(hw >> 8) + "." + String(hw & 0xff) + " SW " + String(sw >> 8) + "." + String(sw & 0xff));
// Configures the GPIO chip for input in every pin
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x06);
Wire.write(0xFF);
Wire.write(0xFF);
Wire.endTransmission();
if(analogRead(BATTERY_PIN) < 200) batterydetect = false;
else console.print("Battery detected.");
if (analogRead(BATTERY_PIN) < 200) batterydetect = false;
if (!SPIFFS.exists("/logbook.csv")) handleCreateNewLogbook();
if(!SPIFFS.exists("/logbook.csv")) {
handleCreateNewLogbook();
console.print("Creating a new logbook.");
}
if (wifi) {
console.print("Trying WiFi");
tryWiFi();
tft.fillRect(184, 230, 16, 6, PrimaryColor);
delay(1750);
} else {
Server.end();
Udp.stop();
tft.fillRect(184, 230, 16, 6, SignificantColor);
}
while(digitalRead(ROTARY_BUTTON) == LOW) delay(75);
console.print("Init done.");
radio.setVolume(VolSet);
radio.setOffset(LevelOffset);
radio.setAMOffset(AMLevelOffset);
@@ -1669,7 +1626,7 @@ void loop() {
flashingtimer = millis();
}
if (!scanholdflag) delay(100);
if (!scanholdflag) delay(75);
radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if (!initdxscan) {
@@ -1705,7 +1662,7 @@ void loop() {
if (advancedRDS) {
tft.drawRoundRect(10, 30, 300, 170, 2, ActiveColor);
tft.fillRoundRect(12, 32, 296, 166, 2, BackgroundColor);
tftPrint(ACENTER, textUI(34), 160, 100, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(33), 160, 100, ActiveColor, ActiveColorSmooth, 28);
} else ShowFreq(1);
}
@@ -2356,8 +2313,6 @@ void SelectBand() {
if (tunemode == TUNE_MI_BAND) tunemode = TUNE_MAN;
if (!leave) {
radio.power(0);
delay(50);
if (band == BAND_FM) radio.SetFreq(frequency);
if (band == BAND_OIRT) radio.SetFreq(frequency_OIRT);
}
@@ -2367,9 +2322,8 @@ void SelectBand() {
freqold = frequency_AM;
if (!externaltune && tunemode != TUNE_MEM) CheckBandForbiddenFM();
doBW();
if (radio.rds.region == 0) {
tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
} else {
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
else {
tftPrint(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth, 16);
}
@@ -2394,18 +2348,18 @@ void SelectBand() {
ShowTuneMode();
ShowStepSize();
tftPrint(ALEFT, textUI(101), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(102), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(103), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(104), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(105), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(106), 70, 32, BackgroundColor, BackgroundColor, 16);
switch (band) {
case BAND_LW: tftPrint(ALEFT, textUI(102), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_MW: tftPrint(ALEFT, textUI(103), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_SW: tftPrint(ALEFT, textUI(104), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_FM: tftPrint(ALEFT, textUI(105), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_OIRT: tftPrint(ALEFT, textUI(106), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_LW: tftPrint(ALEFT, textUI(101), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_MW: tftPrint(ALEFT, textUI(102), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_SW: tftPrint(ALEFT, textUI(103), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_FM: tftPrint(ALEFT, textUI(104), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_OIRT: tftPrint(ALEFT, textUI(105), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
}
}
leave = false;
@@ -2501,7 +2455,7 @@ void ModeButtonPress() {
}
}
while (digitalRead(MODEBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void RoundStep() {
@@ -2951,11 +2905,11 @@ void ShowFreq(int mode) {
FrequencySprite.drawString(String(freq / 100) + "." + (freq % 100 < 10 ? "0" : "") + String(freq % 100) + " ", 218, -6, freqfont);
freqold = freq;
break;
case 1: Infoboxprint(textUI(34)); break;
case 2: Infoboxprint(textUI(290)); break;
case 3: Infoboxprint(textUI(291)); break;
case 4: Infoboxprint(textUI(295)); break;
case 5: Infoboxprint(textUI(284)); break;
case 1: Infoboxprint(textUI(33)); break;
case 2: Infoboxprint(textUI(289)); break;
case 3: Infoboxprint(textUI(290)); break;
case 4: Infoboxprint(textUI(294)); break;
case 5: Infoboxprint(textUI(283)); break;
}
FrequencySprite.pushSprite(46, 46);
@@ -3004,19 +2958,6 @@ void ShowSignalLevel() {
SAvg4 = (((SAvg4 * 9) + 5) / 10) + WAM;
SAvg5 = (((SAvg5 * 9) + 5) / 10) + USN;
#ifdef SMETERPIN
float sval = 0;
int16_t smeter = 0;
if (SStatus > 0) {
if (SStatus < 1000) {
sval = 51 * ((pow(10, (((float)SStatus) / 1000))) - 1);
smeter = int16_t(sval);
} else smeter = 511;
}
smeter = int16_t(sval);
#endif
SStatus = SAvg / 10;
CN = SAvg2 / 10;
MP = SAvg4 / 10;
@@ -3052,10 +2993,6 @@ void ShowSignalLevel() {
}
}
#ifdef SMETERPIN
if (!menu) analogWrite(SMETERPIN, smeter);
#endif
int SStatusprint = 0;
if (unit == 0) SStatusprint = SStatus;
if (unit == 1) SStatusprint = ((SStatus * 100) + 10875) / 100;
@@ -3838,26 +3775,16 @@ void read_encoder() {
encval += enc_states[( old_AB & 0x0f )];
if (!(255 - old_AB)) encval = 0;
if (optenc) {
if (encval > 4) {
if (rotarymode) rotary = -1; else rotary = 1;
encval = 0;
} else if (encval < -4) {
if (rotarymode) rotary = 1; else rotary = -1;
encval = 0;
}
} else {
if (encval > 3) {
if (rotarymode) rotary = -1; else rotary = 1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
} else if (encval < -3) {
if (rotarymode) rotary = 1; else rotary = -1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
}
if (encval > 3) {
if (rotarymode) rotary = -1; else rotary = 1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
} else if (encval < -3) {
if (rotarymode) rotary = 1; else rotary = -1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
}
}
@@ -3867,26 +3794,19 @@ void tftReplace(int8_t offset, const String & textold, const String & text, int1
else if (fontsize == 28) selectedFont = 1;
else if (fontsize == 48) selectedFont = 2;
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
tft.setTextColor(background, background, false);
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
tft.drawString(textold, x, y, selectedFont);
tft.setTextColor(color, smoothcolor, false);
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
String modifiedText = text;
modifiedText.replace("\n", " ");
tft.setTextColor(color, smoothcolor, false);
tft.drawString(modifiedText, x, y, selectedFont);
}
@@ -3953,7 +3873,7 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
tft.drawRect(59, 109, 202, 8, FrameColor);
tft.fillRect(60, 110, 200, 6, GreyoutColor);
tftPrint(ARIGHT, textUI(272), 120, 155, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ARIGHT, textUI(271), 120, 155, ActiveColor, ActiveColorSmooth, 16);
for (frequency = startfreq * 10; frequency <= stopfreq * 10; frequency += 10) {
if (stopScanning) break;
@@ -4046,39 +3966,4 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
SQ = false;
return error;
}
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_task_wdt.h"
#ifndef ARDUINO_LOOP_STACK_SIZE
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
#define ARDUINO_LOOP_STACK_SIZE 8192
#else
#define ARDUINO_LOOP_STACK_SIZE CONFIG_ARDUINO_LOOP_STACK_SIZE
#endif
#endif
TaskHandle_t loopTaskHandle = NULL;
bool loopTaskWDTEnabled;
__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {
return ARDUINO_LOOP_STACK_SIZE;
}
void loopTask(void *pvParameters)
{
setup();
for(;;) {
if(loopTaskWDTEnabled) esp_task_wdt_reset();
loop();
if (serialEventRun) serialEventRun();
}
}
extern "C" void app_main() {
initArduino();
xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
}

View File

@@ -155,7 +155,6 @@ void loadData() {
rotarymode = EEPROM.readByte(EE_BYTE_ROTARYMODE);
tunemode = EEPROM.readByte(EE_BYTE_TUNEMODE);
if (tunemode == TUNE_MAN) stepsize = EEPROM.readByte(EE_BYTE_STEPSIZE); else stepsize = 0;
optenc = EEPROM.readByte(EE_BYTE_OPTENC);
iMSset = EEPROM.readByte(EE_BYTE_IMSSET);
EQset = EEPROM.readByte(EE_BYTE_EQSET);
band = EEPROM.readByte(EE_BYTE_BAND);
@@ -267,7 +266,6 @@ void DefaultSettings() {
EEPROM.writeByte(EE_BYTE_TEF, 0);
EEPROM.writeByte(EE_BYTE_STEPSIZE, 0);
EEPROM.writeByte(EE_BYTE_TUNEMODE, 0);
EEPROM.writeByte(EE_BYTE_OPTENC, 0);
EEPROM.writeByte(EE_BYTE_IMSSET, 1);
EEPROM.writeByte(EE_BYTE_EQSET, 1);
EEPROM.writeByte(EE_BYTE_BAND, BAND_FM);

View File

@@ -54,7 +54,7 @@ void ShowAdvancedRDS() {
if (radio.rds.ECC.changed(0)) {
if (!screenmute) {
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? textUI(73) : radio.rds.ECCtext); else ECCString = "N/A";
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? textUI(72) : radio.rds.ECCtext); else ECCString = "N/A";
}
if (wifi) {
@@ -68,7 +68,7 @@ void ShowAdvancedRDS() {
if(!screenmute) eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
String eonstring;
if (radio.eon_counter > 0) 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 = textUI(88);
if (radio.eon_counter > 0) 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 = textUI(87);
if (radio.rds.hasEON.changed(0)) {
if (!screenmute) {
if (radio.eon_counter > 0) tftPrint(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor, 16);
@@ -78,7 +78,7 @@ void ShowAdvancedRDS() {
if(!screenmute) eonDisplay.update(eonstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
String rtplusstring;
if (radio.rds.hasRTplus) 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) 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(88);
if (radio.rds.hasRTplus.changed(0)) {
if (!screenmute) {
if (radio.rds.hasRTplus) tftPrint(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor, 16);
@@ -404,7 +404,7 @@ void showPI() {
void showPTY() {
if(radio.rds.PTY.changed(0)) {
String PTYString = String(radio.rds.PTY) + "/" + (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(228 + radio.rds.PTY));
String PTYString = String(radio.rds.PTY) + "/" + (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(227 + radio.rds.PTY));
GeneralTextSprite.fillSprite(TFT_TRANSPARENT);
GeneralTextSprite.fillRect(0, 0, 160, 19, BackgroundColor);
if(RDSstatus) GeneralTextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
@@ -596,7 +596,7 @@ void ShowAFEON() {
if (radio.rds.hasAF && afpagenr == 1) {
if (!hasafold) {
tftPrint(ALEFT, textUI(87), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(86), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, "AF:", 4, 32, ActiveColor, ActiveColorSmooth, 16);
hasafold = true;
}
@@ -619,7 +619,7 @@ void ShowAFEON() {
if (radio.eon_counter > 0 && afpagenr > 1) {
if (!haseonold) {
tftPrint(ALEFT, textUI(88), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(87), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, "PI", 4, 32, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ACENTER, "TA", 250, 32, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ACENTER, "TP", 276, 32, ActiveColor, ActiveColorSmooth, 16);
@@ -756,7 +756,7 @@ void ShowAFEON() {
aid_counterold = radio.rds.aid_counter;
if (AIDStringTemp != AIDStringold) {
AIDString = String(textUI(33)) + " - " + String(textUI(79)) + ": " + AIDStringTemp + " ";
AIDString = String(textUI(32)) + " - " + String(textUI(78)) + ": " + AIDStringTemp + " ";
AIDWidth = FullLineSprite.textWidth(AIDString);
AIDStringold = AIDString;
}