Code optimalisation

This commit is contained in:
Sjef Verhoeven PE5PVB
2024-05-26 01:42:32 +02:00
parent 15cc9ec89a
commit d04e05607d
3 changed files with 45 additions and 34 deletions
+15 -15
View File
@@ -527,10 +527,7 @@ void setup() {
MWHighEdgeSet = mwstepsize == false ? FREQ_MW_HIGH_EDGE_MAX_9K : FREQ_MW_HIGH_EDGE_MAX_10K;
SWLowEdgeSet = FREQ_SW_LOW_EDGE_MIN;
SWHighEdgeSet = FREQ_SW_HIGH_EDGE_MAX;
if (LowEdgeOIRTSet < FREQ_FM_OIRT_START || LowEdgeOIRTSet > FREQ_FM_OIRT_END) LowEdgeOIRTSet = FREQ_FM_OIRT_START;
if (HighEdgeOIRTSet < FREQ_FM_OIRT_START || HighEdgeOIRTSet > FREQ_FM_OIRT_END) HighEdgeOIRTSet = FREQ_FM_OIRT_END;
LowEdgeOIRTSet = LowEdgeOIRTSet;
LowEdgeOIRTSet = FREQ_FM_OIRT_START;
HighEdgeOIRTSet = FREQ_FM_OIRT_END;
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].band = EEPROM.readByte(i + EE_PRESETS_BAND_START);
@@ -547,14 +544,12 @@ void setup() {
}
}
btStop();
if (USBmode) Serial.begin(19200); else Serial.begin(115200);
if (iMSset == 1 && EQset == 1) iMSEQ = 2;
if (iMSset == 0 && EQset == 1) iMSEQ = 3;
if (iMSset == 1 && EQset == 0) iMSEQ = 4;
if (iMSset == 0 && EQset == 0) iMSEQ = 1;
if (iMSset && EQset) iMSEQ = 2;
if (!iMSset && EQset) iMSEQ = 3;
if (iMSset && !EQset) iMSEQ = 4;
if (!iMSset && !EQset) iMSEQ = 1;
switch (band) {
case BAND_LW:
@@ -578,8 +573,6 @@ void setup() {
break;
}
if (IsStationEmpty()) memoryposstatus = MEM_DARK; else memoryposstatus = MEM_NORMAL;
tft.init();
tft.initDMA();
@@ -799,17 +792,19 @@ void setup() {
Wire.endTransmission();
}
SelectBand();
if (tunemode == TUNE_MEM) DoMemoryPosTune();
SelectBand();
setupmode = false;
if (edgebeep) radio.tone(50, -5, 2000);
radio.I2Sin(false);
if (!usesquelch) radio.setUnMute();
if (screensaverset) {
ScreensaverTimerInit();
ScreensaverTimerSet(screensaverOptions[screensaverset]);
}
tottimer = millis();
}
@@ -820,7 +815,6 @@ void loop() {
unsigned long totprobe = tot * 60000;
if (millis() >= tottimer + totprobe) deepSleep();
}
if (digitalRead(BANDBUTTON) == LOW ) BANDBUTTONPress();
if (scandxmode) {
if (millis() >= scantimer + (scanhold * 1000)) {
@@ -1073,6 +1067,12 @@ void loop() {
}
}
if (digitalRead(BANDBUTTON) == LOW) {
tottimer = millis();
if (screensavertriggered && !touchrotating) WakeToSleep(REVERSE);
BANDBUTTONPress();
}
if (digitalRead(ROTARY_BUTTON) == LOW) {
tottimer = millis();
if (screensavertriggered && !touchrotating) WakeToSleep(REVERSE);
+7 -7
View File
@@ -484,8 +484,8 @@ void BuildAFScreen() {
}
void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.pushImage (-8, -(position + 2), 320, 240, configurationbackground);
if (selected) FullLineSprite.pushImage(0, 0, 304, 20, selector);
FullLineSprite.pushImage (-8, -(position + 2), 320, 240, configurationbackground);
if (selected) FullLineSprite.pushImage(0, 0, 304, 20, selector);
switch (item) {
case 0:
@@ -1736,7 +1736,7 @@ void MenuUp() {
}
}
}
ShowOneLine(menuoption, menuitem, true);
} else {
OneBigLineSprite.pushImage(-11, -88, 292, 170, popupbackground);
@@ -2559,7 +2559,7 @@ void MenuUp() {
void MenuDown() {
if (!menuopen) {
ShowOneLine(menuoption, menuitem, false);
ShowOneLine(menuoption, menuitem, false);
if (hardwaremodel == BASE_ILI9341) {
menuoption -= ITEM_GAP;
@@ -3411,10 +3411,10 @@ void DoMenu() {
if (!menuopen) {
if (menupage != INDEX) {
menuopen = true;
tft.pushImage (13, 30, 292, 170, popupbackground);
tft.pushImage (13, 30, 292, 170, popupbackground);
}
OneBigLineSprite.pushImage(-11, -88, 292, 170, popupbackground);
OneBigLineSprite.pushImage(-11, -88, 292, 170, popupbackground);
OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
OneBigLineSprite.setTextDatum(TC_DATUM);
@@ -4166,7 +4166,7 @@ void DoMenu() {
XDRGTK_key = XDRGTK_key_input.getValue();
EEPROM.writeString(EE_STRING_XDRGTK_KEY, XDRGTK_key);
EEPROM.commit();
UpdateFonts(0);
UpdateFonts(0);
wifi = true;
tryWiFi();
delay(2000);
+23 -12
View File
@@ -47,11 +47,15 @@ void ShowAdvancedRDS() {
}
if (ptynold != radio.rds.PTYN || rdsreset) {
if (!screenmute) tftPrint(-1, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor, 16);
if (!screenmute) tftPrint(-1, ptynold, 216, 109, BackgroundColor, BackgroundColor, 16);
if (radio.rds.PTYN.length() == 0) radio.rds.PTYN = "PTYN N/A";
if (!screenmute) tftPrint(-1, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth, 16);
ptynold = radio.rds.PTYN;
if (!screenmute) {
if (ptynold != "PTYN N/A") {
tftPrint(-1, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor, 16);
tftPrint(-1, ptynold, 216, 109, BackgroundColor, BackgroundColor, 16);
}
if (radio.rds.PTYN.length() == 0) radio.rds.PTYN = "PTYN N/A";
tftPrint(-1, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth, 16);
ptynold = radio.rds.PTYN;
}
}
if (licold != radio.rds.LIC || rdsreset) {
@@ -60,8 +64,8 @@ void ShowAdvancedRDS() {
tftPrint(-1, LIColdString, 242, 208, BackgroundColor, BackgroundColor, 16);
if (radio.rds.hasLIC) tftPrint(-1, (radio.rds.LICtext.length() == 0 ? myLanguage[language][73] : radio.rds.LICtext), 242, 208, RDSColor, RDSColorSmooth, 16); else tftPrint(-1, "N/A", 242, 208, RDSColor, RDSColorSmooth, 16);
if (radio.rds.LICtext.length() == 0) LIColdString = myLanguage[language][73]; else LIColdString = radio.rds.LICtext;
licold = radio.rds.LIC;
}
licold = radio.rds.LIC;
}
String pinstring = String(radio.rds.pinDay) + " " + String(radio.rds.pinHour) + ":" + (radio.rds.pinMin < 10 ? "0" : "") + String(radio.rds.pinMin);
@@ -306,6 +310,7 @@ void readRds() {
radio.readRDS(showrdserrors);
RDSstatus = radio.rds.hasRDS;
ShowRDSLogo(RDSstatus);
if (!screenmute && !afscreen) {
if (!RDSstatus) {
if (radio.rds.correctPI != 0 && !dropout) {
@@ -329,10 +334,11 @@ void readRds() {
}
}
PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
PSSprite.drawString(PSold, 0, 0);
if (!radio.rds.hasLongPS) {
PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false);
PSSprite.drawString(PSold, 0, 0);
if (advancedRDS) {
PSSprite.pushSprite(36, 74);
} else {
@@ -384,10 +390,11 @@ void readRds() {
}
}
PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSColor, RDSColorSmooth, false);
PSSprite.drawString(PSold, 0, 0);
if (!radio.rds.hasLongPS) {
PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSColor, RDSColorSmooth, false);
PSSprite.drawString(PSold, 0, 0);
if (advancedRDS) {
PSSprite.pushSprite(36, 74);
} else {
@@ -580,6 +587,7 @@ void showPI() {
if (RDSSPYUSB) Serial.print("G:\r\nRESET-------\r\n\r\n");
if (RDSSPYTCP) RemoteClient.print("G:\r\nRESET-------\r\n\r\n");
}
if (!screenmute) {
if (advancedRDS) {
if (region == REGION_EU) {
@@ -628,6 +636,7 @@ void showPI() {
stationIDold = radio.rds.stationIDtext;
stationStateold = radio.rds.stationStatetext;
}
if (wifi) {
Udp.beginPacket(remoteip, 9030);
Udp.print("from=TEF_tuner " + String(stationlistid, DEC) + ";PI=" + String(radio.rds.picode, 4));
@@ -654,6 +663,7 @@ void showPTY() {
}
}
PTYold = radio.rds.stationType;
if (wifi) {
Udp.beginPacket(remoteip, 9030);
Udp.print("from=TEF_tuner " + String(stationlistid, DEC) + ";PTY=");
@@ -822,6 +832,7 @@ void showRadioText() {
}
}
}
if (radio.rds.hasRT) {
if (!advancedRDS) {
if (radio.rds.rtAB) {