Mod: Add auto tunemode for AM band

This commit is contained in:
ohmytime
2023-08-06 21:33:28 +08:00
parent 92fee2b536
commit 5dd1468885
+63 -45
View File
@@ -151,6 +151,7 @@ byte screensaverOptions[5] = {0, 3, 10, 30, 60};
byte screensaverset; byte screensaverset;
byte showmodulation; byte showmodulation;
byte showSWMIBand; byte showSWMIBand;
byte nowToggleSWMIBand = 0;
byte SNRold; byte SNRold;
byte stepsize; byte stepsize;
byte StereoLevel; byte StereoLevel;
@@ -1642,7 +1643,6 @@ void ToggleSWMIBand(bool frequencyup) {
void SelectBand() { void SelectBand() {
if (band > BAND_GAP) { if (band > BAND_GAP) {
seek = false; seek = false;
if (tunemode == TUNE_AUTO) tunemode = TUNE_MAN;
if (tunemode == TUNE_MI_BAND && band != BAND_SW) tunemode = TUNE_MAN; if (tunemode == TUNE_MI_BAND && band != BAND_SW) tunemode = TUNE_MAN;
BWreset = true; BWreset = true;
BWset = 2; BWset = 2;
@@ -1849,7 +1849,7 @@ void ShowStepSize() {
tft.fillRect(224, 38, 15, 4, GreyoutColor); tft.fillRect(224, 38, 15, 4, GreyoutColor);
tft.fillRect(193, 38, 15, 4, GreyoutColor); tft.fillRect(193, 38, 15, 4, GreyoutColor);
if (band < BAND_GAP) tft.fillRect(148, 38, 15, 4, GreyoutColor); else tft.fillRect(162, 38, 15, 4, GreyoutColor); if (band < BAND_GAP) tft.fillRect(148, 38, 15, 4, GreyoutColor); else tft.fillRect(162, 38, 15, 4, GreyoutColor);
if (band < BAND_GAP) tft.fillRect(116, 38, 15, 4, GreyoutColor); else tft.fillRect(128, 38, 15, 4, GreyoutColor); if (band < BAND_GAP) tft.fillRect(116, 38, 15, 4, GreyoutColor); else if (band != BAND_LW) tft.fillRect(128, 38, 15, 4, GreyoutColor);
if (stepsize == 1) tft.fillRect(224, 38, 15, 4, InsignificantColor); if (stepsize == 1) tft.fillRect(224, 38, 15, 4, InsignificantColor);
if (stepsize == 2) tft.fillRect(193, 38, 15, 4, InsignificantColor); if (stepsize == 2) tft.fillRect(193, 38, 15, 4, InsignificantColor);
if (stepsize == 3) { if (stepsize == 3) {
@@ -1968,39 +1968,50 @@ void ButtonPress() {
} }
} }
} else { } else {
if (iMSEQ == 0) iMSEQ = 1; if (band < BAND_GAP) {
if (iMSEQ == 0) iMSEQ = 1;
if (iMSEQ == 4) { if (iMSEQ == 4) {
iMSset = 0; iMSset = 0;
EQset = 0; EQset = 0;
updateiMS(); updateiMS();
updateEQ(); updateEQ();
iMSEQ = 0; iMSEQ = 0;
}
if (iMSEQ == 3) {
iMSset = 1;
EQset = 0;
updateiMS();
updateEQ();
iMSEQ = 4;
}
if (iMSEQ == 2) {
iMSset = 0;
EQset = 1;
updateiMS();
updateEQ();
iMSEQ = 3;
}
if (iMSEQ == 1) {
iMSset = 1;
EQset = 1;
updateiMS();
updateEQ();
iMSEQ = 2;
}
EEPROM.writeByte(EE_BYTE_IMSSET, iMSset);
EEPROM.writeByte(EE_BYTE_EQSET, EQset);
EEPROM.commit();
} else {
if (band == BAND_SW) {
if (tunemode != TUNE_MEM) {
nowToggleSWMIBand = !nowToggleSWMIBand;
tunemode = TUNE_MEM;
doTuneMode();
ShowTuneMode();
}
}
} }
if (iMSEQ == 3) {
iMSset = 1;
EQset = 0;
updateiMS();
updateEQ();
iMSEQ = 4;
}
if (iMSEQ == 2) {
iMSset = 0;
EQset = 1;
updateiMS();
updateEQ();
iMSEQ = 3;
}
if (iMSEQ == 1) {
iMSset = 1;
EQset = 1;
updateiMS();
updateEQ();
iMSEQ = 2;
}
EEPROM.writeByte(EE_BYTE_IMSSET, iMSset);
EEPROM.writeByte(EE_BYTE_EQSET, EQset);
EEPROM.commit();
} }
} }
if (screensaverset) { if (screensaverset) {
@@ -3432,17 +3443,16 @@ void doBW() {
void doTuneMode() { void doTuneMode() {
switch (tunemode) { switch (tunemode) {
case TUNE_MAN: case TUNE_MAN:
if (band < BAND_GAP) { if (band == BAND_SW) {
tunemode = TUNE_AUTO; if (showSWMIBand && nowToggleSWMIBand) tunemode = TUNE_MI_BAND;
if (stepsize != 0) { else tunemode = TUNE_AUTO;
stepsize = 0;
RoundStep();
ShowStepSize();
}
} else if (band == BAND_SW && showSWMIBand) {
tunemode = TUNE_MI_BAND;
} else { } else {
tunemode = TUNE_MEM; tunemode = TUNE_AUTO;
}
if (stepsize != 0) {
stepsize = 0;
RoundStep();
ShowStepSize();
} }
break; break;
case TUNE_MI_BAND: case TUNE_MI_BAND:
@@ -3464,10 +3474,14 @@ void doTuneMode() {
void ShowTuneMode() { void ShowTuneMode() {
switch (tunemode) { switch (tunemode) {
case TUNE_MAN: case TUNE_MAN:
if (band == BAND_SW) { if (band == BAND_SW && nowToggleSWMIBand) {
tftPrint(0, "AUTO", 22, 60, BackgroundColor, BackgroundColor, FONT16);
tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor); tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor);
tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, FONT16); tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, FONT16);
} else { } else {
tftPrint(0, "BAND", 22, 60, BackgroundColor, BackgroundColor, FONT16);
tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor); tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor);
tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, FONT16); tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, FONT16);
} }
@@ -3491,10 +3505,14 @@ void ShowTuneMode() {
break; break;
case TUNE_MEM: case TUNE_MEM:
if (band == BAND_SW) { if (band == BAND_SW && nowToggleSWMIBand) {
tftPrint(0, "AUTO", 22, 60, BackgroundColor, BackgroundColor, FONT16);
tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor); tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor);
tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, FONT16); tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, FONT16);
} else { } else {
tftPrint(0, "BAND", 22, 60, BackgroundColor, BackgroundColor, FONT16);
tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor); tft.drawRoundRect(1, 57, 42, 20, 5, GreyoutColor);
tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, FONT16); tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, FONT16);
} }