You've already forked TEF6686_ESP32
small refactorings
This commit is contained in:
@@ -11,7 +11,7 @@ void Communication() {
|
|||||||
if (packetSize > 0) {
|
if (packetSize > 0) {
|
||||||
char packetBuffer[packetSize + 1];
|
char packetBuffer[packetSize + 1];
|
||||||
Udp.read(packetBuffer, packetSize);
|
Udp.read(packetBuffer, packetSize);
|
||||||
packetBuffer[packetSize] = '\0'; // Ensure valid string
|
packetBuffer[packetSize] = '\0';
|
||||||
Udp.endPacket();
|
Udp.endPacket();
|
||||||
|
|
||||||
String packet = String(packetBuffer);
|
String packet = String(packetBuffer);
|
||||||
@@ -28,23 +28,24 @@ void Communication() {
|
|||||||
char command = packet.charAt(1);
|
char command = packet.charAt(1);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'U':
|
case 'U':
|
||||||
case 'D':
|
case 'D': {
|
||||||
tunemode = TUNE_MAN;
|
tunemode = TUNE_MAN;
|
||||||
ShowTuneMode();
|
ShowTuneMode();
|
||||||
if (command == 'U') TuneUp(); else TuneDown();
|
if (command == 'U') TuneUp(); else TuneDown();
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
case '<':
|
case '<': {
|
||||||
if (command == '>') direction = true; else direction = false;
|
if (command == '>') direction = true; else direction = false;
|
||||||
Seek(direction);
|
Seek(direction);
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'T':
|
case 'T': {
|
||||||
uint16_t freqtemp;
|
uint16_t freqtemp = packet.substring(2).toInt();
|
||||||
freqtemp = packet.substring(2).toInt();
|
|
||||||
if (BAND_FM) freqtemp -= ConverterSet * 1000;
|
if (BAND_FM) freqtemp -= ConverterSet * 1000;
|
||||||
if (seek) seek = false;
|
if (seek) seek = false;
|
||||||
radio.clearRDS(fullsearchrds);
|
radio.clearRDS(fullsearchrds);
|
||||||
@@ -74,11 +75,12 @@ void Communication() {
|
|||||||
}
|
}
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'S': if (!scandxmode) startFMDXScan(); break;
|
case 'S': {if (!scandxmode) startFMDXScan(); break;}
|
||||||
case 'E': if (scandxmode) cancelDXScan(); break;
|
case 'E': {if (scandxmode) cancelDXScan(); break;}
|
||||||
|
|
||||||
case 'R': radio.clearRDS(fullsearchrds); break;
|
case 'R': {radio.clearRDS(fullsearchrds); break;}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -168,8 +170,6 @@ void Communication() {
|
|||||||
passwordcrypt();
|
passwordcrypt();
|
||||||
RemoteClient.print(saltkey + "\n");
|
RemoteClient.print(saltkey + "\n");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (Server.hasClient()) Server.available().stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wificonnected && !RemoteClient.connected()) {
|
if (wificonnected && !RemoteClient.connected()) {
|
||||||
@@ -195,9 +195,7 @@ void Communication() {
|
|||||||
RemoteClient.print("o1,0\n");
|
RemoteClient.print("o1,0\n");
|
||||||
RemoteClient.print("G" + String(!EQset) + String(!iMSset) + "\n");
|
RemoteClient.print("G" + String(!EQset) + String(!iMSset) + "\n");
|
||||||
store = true;
|
store = true;
|
||||||
} else {
|
} else RemoteClient.print("a0\n");
|
||||||
RemoteClient.print("a0\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
43
src/main.cpp
43
src/main.cpp
@@ -1035,8 +1035,8 @@ void setup() {
|
|||||||
if (TEF != 102 && TEF != 205) SetTunerPatch();
|
if (TEF != 102 && TEF != 205) SetTunerPatch();
|
||||||
|
|
||||||
radio.init(TEF);
|
radio.init(TEF);
|
||||||
uint16_t device, hw, sw;
|
|
||||||
|
|
||||||
|
uint16_t device, hw, sw;
|
||||||
radio.getIdentification(&device, &hw, &sw);
|
radio.getIdentification(&device, &hw, &sw);
|
||||||
if (TEF != (highByte(hw) * 100 + highByte(sw))) SetTunerPatch();
|
if (TEF != (highByte(hw) * 100 + highByte(sw))) SetTunerPatch();
|
||||||
|
|
||||||
@@ -1088,7 +1088,7 @@ void setup() {
|
|||||||
Udp.stop();
|
Udp.stop();
|
||||||
tft.fillRect(184, 230, 16, 6, SignificantColor);
|
tft.fillRect(184, 230, 16, 6, SignificantColor);
|
||||||
}
|
}
|
||||||
delay(1500);
|
delay(1000);
|
||||||
|
|
||||||
radio.setVolume(VolSet);
|
radio.setVolume(VolSet);
|
||||||
radio.setOffset(LevelOffset);
|
radio.setOffset(LevelOffset);
|
||||||
@@ -1389,11 +1389,8 @@ void loop() {
|
|||||||
tftPrint(ALEFT, "100", 160, 144, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ALEFT, "100", 160, 144, ActiveColor, ActiveColorSmooth, 16);
|
||||||
tftPrint(ACENTER, "A", 7, 128, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ACENTER, "A", 7, 128, ActiveColor, ActiveColorSmooth, 16);
|
||||||
for (byte segments = 0; segments < 94; segments++) {
|
for (byte segments = 0; segments < 94; segments++) {
|
||||||
if (segments > 54) {
|
if (segments > 54 && (((segments - 53) % 10) == 0)) tft.fillRect(16 + (2 * segments), 141, 2, 2, BarSignificantColor);
|
||||||
if (((segments - 53) % 10) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, BarSignificantColor);
|
else if(((segments + 1) % 6) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, ModBarInsignificantColor);
|
||||||
} else {
|
|
||||||
if (((segments + 1) % 6) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, ModBarInsignificantColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
|
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
|
||||||
@@ -2654,14 +2651,12 @@ void KeyUp() {
|
|||||||
case TUNE_MAN:
|
case TUNE_MAN:
|
||||||
TuneUp();
|
TuneUp();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUNE_AUTO:
|
case TUNE_AUTO:
|
||||||
direction = true;
|
direction = true;
|
||||||
seek = true;
|
seek = true;
|
||||||
seekinit = true;
|
seekinit = true;
|
||||||
Seek(direction);
|
Seek(direction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUNE_MEM:
|
case TUNE_MEM:
|
||||||
memorypos++;
|
memorypos++;
|
||||||
if (memorypos > EE_PRESETS_CNT - 1) memorypos = 0;
|
if (memorypos > EE_PRESETS_CNT - 1) memorypos = 0;
|
||||||
@@ -2816,7 +2811,6 @@ void DoMemoryPosTune() {
|
|||||||
#endif
|
#endif
|
||||||
radio.clearRDS(fullsearchrds);
|
radio.clearRDS(fullsearchrds);
|
||||||
|
|
||||||
// Process empty stations
|
|
||||||
if (IsStationEmpty()) {
|
if (IsStationEmpty()) {
|
||||||
memoryposstatus = MEM_DARK;
|
memoryposstatus = MEM_DARK;
|
||||||
return;
|
return;
|
||||||
@@ -3725,9 +3719,9 @@ void TuneUp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stepsize == 1) temp = 1;
|
if (stepsize == 1) temp = 1;
|
||||||
if (stepsize == 2) temp = 10;
|
else if (stepsize == 2) temp = 10;
|
||||||
if (stepsize == 3) temp = 100;
|
else if (stepsize == 3) temp = 100;
|
||||||
if (stepsize == 4) temp = 1000;
|
else if (stepsize == 4) temp = 1000;
|
||||||
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
|
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
|
||||||
|
|
||||||
if (band == BAND_FM) {
|
if (band == BAND_FM) {
|
||||||
@@ -3817,9 +3811,9 @@ void TuneDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stepsize == 1) temp = 1;
|
if (stepsize == 1) temp = 1;
|
||||||
if (stepsize == 2) temp = 10;
|
else if (stepsize == 2) temp = 10;
|
||||||
if (stepsize == 3) temp = 100;
|
else if (stepsize == 3) temp = 100;
|
||||||
if (stepsize == 4) temp = 1000;
|
else if (stepsize == 4) temp = 1000;
|
||||||
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
|
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
|
||||||
|
|
||||||
if (band == BAND_FM) {
|
if (band == BAND_FM) {
|
||||||
@@ -3919,12 +3913,10 @@ void read_encoder() {
|
|||||||
if (millis() - rotarytimer >= 15) {
|
if (millis() - rotarytimer >= 15) {
|
||||||
rotarycounteraccelerator = 2; // Steady fast
|
rotarycounteraccelerator = 2; // Steady fast
|
||||||
rotarycounter = 0;
|
rotarycounter = 0;
|
||||||
}
|
} else if (millis() - rotarytimer >= 30) {
|
||||||
if (millis() - rotarytimer >= 30) {
|
|
||||||
rotarycounteraccelerator = 4;
|
rotarycounteraccelerator = 4;
|
||||||
rotarycounter = 0;
|
rotarycounter = 0;
|
||||||
}
|
} else if (millis() - rotarytimer >= 45) {
|
||||||
if (millis() - rotarytimer >= 45) {
|
|
||||||
rotarycounteraccelerator = 6; // Quick flicks
|
rotarycounteraccelerator = 6; // Quick flicks
|
||||||
rotarycounter = 0;
|
rotarycounter = 0;
|
||||||
}
|
}
|
||||||
@@ -3999,7 +3991,7 @@ void MuteScreen(bool setting) {
|
|||||||
|
|
||||||
void DefaultSettings() {
|
void DefaultSettings() {
|
||||||
EEPROM.writeByte(EE_BYTE_CHECKBYTE, EE_CHECKBYTE_VALUE);
|
EEPROM.writeByte(EE_BYTE_CHECKBYTE, EE_CHECKBYTE_VALUE);
|
||||||
EEPROM.writeUInt(EE_UINT16_FREQUENCY_FM, 10000);
|
EEPROM.writeUInt(EE_UINT16_FREQUENCY_FM, 9500);
|
||||||
EEPROM.writeUInt(EE_UINT16_FREQUENCY_OIRT, FREQ_FM_OIRT_START);
|
EEPROM.writeUInt(EE_UINT16_FREQUENCY_OIRT, FREQ_FM_OIRT_START);
|
||||||
EEPROM.writeByte(EE_BYTE_VOLSET, 0);
|
EEPROM.writeByte(EE_BYTE_VOLSET, 0);
|
||||||
EEPROM.writeUInt(EE_UINT16_CONVERTERSET, 0);
|
EEPROM.writeUInt(EE_UINT16_CONVERTERSET, 0);
|
||||||
@@ -4143,10 +4135,10 @@ void tftReplace(int8_t offset, const String & textold, const String & text, int1
|
|||||||
const uint8_t *selectedFont = nullptr;
|
const uint8_t *selectedFont = nullptr;
|
||||||
if (language == LANGUAGE_CHS) {
|
if (language == LANGUAGE_CHS) {
|
||||||
if (fontsize == 16) selectedFont = FONT16_CHS;
|
if (fontsize == 16) selectedFont = FONT16_CHS;
|
||||||
if (fontsize == 28) selectedFont = FONT28_CHS;
|
else if (fontsize == 28) selectedFont = FONT28_CHS;
|
||||||
} else {
|
} else {
|
||||||
if (fontsize == 16) selectedFont = FONT16;
|
if (fontsize == 16) selectedFont = FONT16;
|
||||||
if (fontsize == 28) selectedFont = FONT28;
|
else if (fontsize == 28) selectedFont = FONT28;
|
||||||
}
|
}
|
||||||
if (fontsize == 48) selectedFont = FONT48;
|
if (fontsize == 48) selectedFont = FONT48;
|
||||||
|
|
||||||
@@ -4179,10 +4171,10 @@ void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int colo
|
|||||||
const uint8_t *selectedFont = nullptr;
|
const uint8_t *selectedFont = nullptr;
|
||||||
if (language == LANGUAGE_CHS) {
|
if (language == LANGUAGE_CHS) {
|
||||||
if (fontsize == 16) selectedFont = FONT16_CHS;
|
if (fontsize == 16) selectedFont = FONT16_CHS;
|
||||||
if (fontsize == 28) selectedFont = FONT28_CHS;
|
else if (fontsize == 28) selectedFont = FONT28_CHS;
|
||||||
} else {
|
} else {
|
||||||
if (fontsize == 16) selectedFont = FONT16;
|
if (fontsize == 16) selectedFont = FONT16;
|
||||||
if (fontsize == 28) selectedFont = FONT28;
|
else if (fontsize == 28) selectedFont = FONT28;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontsize == 48) selectedFont = FONT48;
|
if (fontsize == 48) selectedFont = FONT48;
|
||||||
@@ -4224,7 +4216,6 @@ void UpdateFonts(byte mode) {
|
|||||||
OneBigLineSprite.loadFont(FONT28);
|
OneBigLineSprite.loadFont(FONT28);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
FullLineSprite.unloadFont();
|
FullLineSprite.unloadFont();
|
||||||
OneBigLineSprite.unloadFont();
|
OneBigLineSprite.unloadFont();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
ModeButtonPress();
|
ModeButtonPress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (menuopen) { // Menu navigation
|
if (menuopen) {
|
||||||
if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown(); // ---------------
|
if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown();
|
||||||
if (x > 240 && x < 300 && y > 150 && y < 190) KeyUp();
|
if (x > 240 && x < 300 && y > 150 && y < 190) KeyUp();
|
||||||
if ((x > 240 && x < 300 && y > 40 && y < 80) || (x > 130 && x < 190 && y > 150 && y < 190)) {
|
if ((x > 240 && x < 300 && y > 40 && y < 80) || (x > 130 && x < 190 && y > 150 && y < 190)) {
|
||||||
touchrepeat = false;
|
touchrepeat = false;
|
||||||
@@ -93,18 +93,18 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!menu && !BWtune) { // All pages except menu
|
if (!menu && !BWtune) {
|
||||||
if (x > 30 && x < 65 && y > 0 && y < 30 && band < BAND_GAP) { // ---------------------
|
if (x > 30 && x < 65 && y > 0 && y < 30 && band < BAND_GAP) {
|
||||||
doStereoToggle(); // Stereo toggle
|
doStereoToggle();
|
||||||
return;
|
return;
|
||||||
} else if (x > 155 && x < 250 && y > 0 && y < 30) {
|
} else if (x > 155 && x < 250 && y > 0 && y < 30) {
|
||||||
BuildBWSelector(); // Set bandwidth
|
BuildBWSelector();
|
||||||
BWtune = true;
|
BWtune = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BWtune) { // BW menu
|
if (BWtune) {
|
||||||
if (y > 35 && y < 65) {
|
if (y > 35 && y < 65) {
|
||||||
if (x > 7 && x < 77) BWtemp = 1;
|
if (x > 7 && x < 77) BWtemp = 1;
|
||||||
if (x > 87 && x < 157) BWtemp = 2;
|
if (x > 87 && x < 157) BWtemp = 2;
|
||||||
@@ -177,26 +177,26 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) { // Normal radio mode
|
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) {
|
||||||
if (x > 0 && x < 320 && y > 180 && y < 240 && band < BAND_GAP) { // -----------------
|
if (x > 0 && x < 320 && y > 180 && y < 240 && band < BAND_GAP) {
|
||||||
leave = true;
|
leave = true;
|
||||||
BuildAdvancedRDS(); // Switch to Advanced RDS View
|
BuildAdvancedRDS();
|
||||||
return;
|
return;
|
||||||
} else if (x > 60 && x < 240 && y > 40 && y < 100) {
|
} else if (x > 60 && x < 240 && y > 40 && y < 100) {
|
||||||
doBandToggle(); // Toggle bands
|
doBandToggle();
|
||||||
return;
|
return;
|
||||||
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
|
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
|
||||||
doTuneMode(); // Toggle tune mode
|
doTuneMode();
|
||||||
return;
|
return;
|
||||||
} else if (x > 250 && x < 320 && y > 50 && y < 80) {
|
} else if (x > 250 && x < 320 && y > 50 && y < 80) {
|
||||||
toggleiMSEQ(); // Toggle iMQ/EQ
|
toggleiMSEQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) { // Advanced RDS mode
|
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) {
|
||||||
if (x > 0 && x < 320 && y > 120 && y < 170) { // -----------------
|
if (x > 0 && x < 320 && y > 120 && y < 170) {
|
||||||
leave = true;
|
leave = true;
|
||||||
BuildDisplay(); // Switch to normal radio view
|
BuildDisplay();
|
||||||
SelectBand();
|
SelectBand();
|
||||||
return;
|
return;
|
||||||
} else if (x > 0 && x < 320 && y > 180 && y < 240) {
|
} else if (x > 0 && x < 320 && y > 180 && y < 240) {
|
||||||
|
|||||||
11
test/README
11
test/README
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Test Runner and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
|
||||||
Reference in New Issue
Block a user