Merge pull request #205 from ohmytime/Band_mod

Mod: Add auto tunemode for AM band
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-08-06 15:47:45 +02:00
committed by GitHub
+63 -45
View File
@@ -153,6 +153,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;
@@ -1651,7 +1652,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;
@@ -1858,7 +1858,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) {
@@ -1977,39 +1977,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) {
@@ -2779,17 +2790,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:
@@ -2811,10 +2821,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, 16); tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, 16);
} 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, 16); tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, 16);
} }
@@ -2838,10 +2852,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, 16); tftPrint(0, "BAND", 22, 60, GreyoutColor, BackgroundColor, 16);
} 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, 16); tftPrint(0, "AUTO", 22, 60, GreyoutColor, BackgroundColor, 16);
} }