You've already forked TEF6686_ESP32
Merge pull request #444 from ohmytime/Empty_Station_Optimization
Empty station optimization
This commit is contained in:
@@ -160,6 +160,7 @@ byte memoryband[EE_PRESETS_CNT];
|
||||
byte memorybw[EE_PRESETS_CNT];
|
||||
byte memorypos;
|
||||
byte memoryposold;
|
||||
byte memoryposstatus;
|
||||
byte menupage;
|
||||
byte MSold;
|
||||
byte optenc;
|
||||
@@ -502,6 +503,8 @@ void setup() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsStationEmpty()) memoryposstatus = MEM_DARK; else memoryposstatus = MEM_NORMAL;
|
||||
|
||||
tft.init();
|
||||
doTheme();
|
||||
if (displayflip == 0) {
|
||||
@@ -2073,6 +2076,10 @@ void ButtonPress() {
|
||||
if (tunemode == TUNE_MEM) {
|
||||
if (!memorystore) {
|
||||
memorystore = true;
|
||||
if (!IsStationEmpty()) memoryposstatus = MEM_EXIST;
|
||||
else memoryposstatus = MEM_NORMAL;
|
||||
ShowMemoryPos();
|
||||
|
||||
ShowTuneMode();
|
||||
} else {
|
||||
memorystore = false;
|
||||
@@ -2106,6 +2113,10 @@ void ButtonPress() {
|
||||
memory[memorypos] = frequency_SW;
|
||||
}
|
||||
ShowTuneMode();
|
||||
if (memoryposstatus == MEM_DARK || memoryposstatus == MEM_EXIST) {
|
||||
memoryposstatus = MEM_NORMAL;
|
||||
ShowMemoryPos();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
seek = false;
|
||||
@@ -2208,9 +2219,14 @@ void KeyUp() {
|
||||
|
||||
case TUNE_MEM:
|
||||
memorypos++;
|
||||
if (memorypos > EE_PRESETS_CNT - 1) memorypos = 0;
|
||||
if (memorypos > EE_PRESETS_CNT - 1) memorypos = 0;
|
||||
if (!memorystore) {
|
||||
DoMemoryPosTune();
|
||||
} else {
|
||||
if (!IsStationEmpty()) memoryposstatus = MEM_EXIST;
|
||||
else memoryposstatus = MEM_NORMAL;
|
||||
}
|
||||
ShowMemoryPos();
|
||||
if (!memorystore) DoMemoryPosTune();
|
||||
EEPROM.writeByte(EE_BYTE_MEMORYPOS, memorypos);
|
||||
EEPROM.commit();
|
||||
break;
|
||||
@@ -2256,8 +2272,13 @@ void KeyDown() {
|
||||
case TUNE_MEM:
|
||||
memorypos--;
|
||||
if (memorypos > EE_PRESETS_CNT - 1) memorypos = EE_PRESETS_CNT - 1;
|
||||
if (!memorystore) {
|
||||
DoMemoryPosTune();
|
||||
} else {
|
||||
if (!IsStationEmpty()) memoryposstatus = MEM_EXIST;
|
||||
else memoryposstatus = MEM_NORMAL;
|
||||
}
|
||||
ShowMemoryPos();
|
||||
if (!memorystore) DoMemoryPosTune();
|
||||
EEPROM.writeByte(EE_BYTE_MEMORYPOS, memorypos);
|
||||
EEPROM.commit();
|
||||
break;
|
||||
@@ -2285,9 +2306,24 @@ void KeyDown() {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsStationEmpty() {
|
||||
if (memoryband[memorypos] == BAND_FM && memory[memorypos] == EE_PRESETS_FREQUENCY) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShowMemoryPos() {
|
||||
if (tunemode == TUNE_MEM) {
|
||||
if (advancedRDS) tftReplace(-1, String(memoryposold + 1), String(memorypos + 1), 215, 36, SecondaryColor, SecondaryColorSmooth, 16); else tftReplace(-1, String(memoryposold + 1), String(memorypos + 1), 50, 32, PrimaryColor, PrimaryColorSmooth, 16);
|
||||
int memposcolor;
|
||||
log_e("memoryposstatus %d:",memoryposstatus);
|
||||
switch (memoryposstatus) {
|
||||
// case MEM_DARK: memposcolor = GreyoutColor; break;
|
||||
case MEM_DARK: memposcolor = InsignificantColor; break;
|
||||
case MEM_NORMAL: memposcolor = PrimaryColor; break;
|
||||
case MEM_EXIST: memposcolor = SignificantColor; break;
|
||||
}
|
||||
if (advancedRDS) tftReplace(-1, String(memoryposold + 1), String(memorypos + 1), 215, 36, SecondaryColor, SecondaryColorSmooth, 16); else tftReplace(-1, String(memoryposold + 1), String(memorypos + 1), 50, 32, memposcolor, PrimaryColorSmooth, 16);
|
||||
memoryposold = memorypos;
|
||||
} else {
|
||||
if (advancedRDS) tftPrint(-1, String(memorypos + 1), 215, 36, BackgroundColor, BackgroundColor, 16); else tftPrint(-1, String(memorypos + 1), 50, 32, BackgroundColor, BackgroundColor, 16);
|
||||
@@ -2295,6 +2331,14 @@ void ShowMemoryPos() {
|
||||
}
|
||||
|
||||
void DoMemoryPosTune() {
|
||||
// Process empty stations
|
||||
if (IsStationEmpty()) {
|
||||
memoryposstatus = MEM_DARK;
|
||||
return;
|
||||
} else {
|
||||
memoryposstatus = MEM_NORMAL;
|
||||
}
|
||||
|
||||
if (band != memoryband[memorypos]) {
|
||||
band = memoryband[memorypos];
|
||||
SelectBand();
|
||||
|
||||
@@ -243,6 +243,10 @@ enum SPI_SPEED_ENUM {
|
||||
SPI_SPEED_COUNT
|
||||
};
|
||||
|
||||
enum RADIO_MEM_POS_STATUS {
|
||||
MEM_DARK, MEM_NORMAL, MEM_EXIST
|
||||
};
|
||||
|
||||
static const uint8_t TEFLogo[] PROGMEM = {
|
||||
0xff, 0xff, 0xf8, 0x7f, 0xfe, 0x07, 0xff, 0xe0, 0xff, 0xff, 0xf8, 0xff, 0xff, 0x1f, 0xff, 0xe0,
|
||||
0xff, 0xff, 0xf9, 0xff, 0xff, 0x1f, 0xff, 0xe0, 0xff, 0xff, 0xfb, 0xff, 0xfe, 0x3f, 0xff, 0xe0,
|
||||
|
||||
@@ -73,7 +73,7 @@ void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de
|
||||
BackgroundColor = TFT_BLACK;
|
||||
ActiveColor = TFT_WHITE;
|
||||
ActiveColorSmooth = 0x18E3;
|
||||
SignificantColor = TFT_RED;
|
||||
SignificantColor = TFT_GREEN;
|
||||
SignificantColorSmooth = 0x2000;
|
||||
InsignificantColor = TFT_GREEN;
|
||||
InsignificantColorSmooth = 0x00C0;
|
||||
@@ -153,7 +153,7 @@ void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de
|
||||
ActiveColorSmooth = 0x18E3;
|
||||
SignificantColor = TFT_RED;
|
||||
SignificantColorSmooth = 0x2000;
|
||||
InsignificantColor = TFT_GREEN;
|
||||
InsignificantColor = 0xAA1C;
|
||||
InsignificantColorSmooth = 0x00C0;
|
||||
StereoColor = TFT_GREEN;
|
||||
StereoColorSmooth = 0x0200;
|
||||
@@ -203,7 +203,7 @@ void doTheme() { // Use this to put your own colors in: http://www.barth-dev.de
|
||||
BackgroundColor = 0xDFFC;
|
||||
ActiveColor = TFT_BLACK;
|
||||
ActiveColorSmooth = 0xDFFC;
|
||||
SignificantColor = TFT_BLACK;
|
||||
SignificantColor = TFT_RED;
|
||||
SignificantColorSmooth = 0xDFFC;
|
||||
InsignificantColor = TFT_GREEN;
|
||||
InsignificantColorSmooth = 0x0140;
|
||||
|
||||
Reference in New Issue
Block a user