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
+28 -10
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,6 +1968,7 @@ void ButtonPress() {
} }
} }
} else { } else {
if (band < BAND_GAP) {
if (iMSEQ == 0) iMSEQ = 1; if (iMSEQ == 0) iMSEQ = 1;
if (iMSEQ == 4) { if (iMSEQ == 4) {
@@ -2001,6 +2002,16 @@ void ButtonPress() {
EEPROM.writeByte(EE_BYTE_IMSSET, iMSset); EEPROM.writeByte(EE_BYTE_IMSSET, iMSset);
EEPROM.writeByte(EE_BYTE_EQSET, EQset); EEPROM.writeByte(EE_BYTE_EQSET, EQset);
EEPROM.commit(); EEPROM.commit();
} else {
if (band == BAND_SW) {
if (tunemode != TUNE_MEM) {
nowToggleSWMIBand = !nowToggleSWMIBand;
tunemode = TUNE_MEM;
doTuneMode();
ShowTuneMode();
}
}
}
} }
} }
if (screensaverset) { if (screensaverset) {
@@ -3432,18 +3443,17 @@ void doBW() {
void doTuneMode() { void doTuneMode() {
switch (tunemode) { switch (tunemode) {
case TUNE_MAN: case TUNE_MAN:
if (band < BAND_GAP) { if (band == BAND_SW) {
if (showSWMIBand && nowToggleSWMIBand) tunemode = TUNE_MI_BAND;
else tunemode = TUNE_AUTO;
} else {
tunemode = TUNE_AUTO; tunemode = TUNE_AUTO;
}
if (stepsize != 0) { if (stepsize != 0) {
stepsize = 0; stepsize = 0;
RoundStep(); RoundStep();
ShowStepSize(); ShowStepSize();
} }
} else if (band == BAND_SW && showSWMIBand) {
tunemode = TUNE_MI_BAND;
} else {
tunemode = TUNE_MEM;
}
break; break;
case TUNE_MI_BAND: case TUNE_MI_BAND:
case TUNE_AUTO: case TUNE_AUTO:
@@ -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);
} }