Added option Wait time on signal only to dx scanner

This commit is contained in:
Sjef Verhoeven PE5PVB
2024-08-31 15:32:13 +02:00
parent 0165476cbb
commit 8ba879435c
5 changed files with 217 additions and 152 deletions
+29 -13
View File
@@ -101,6 +101,7 @@ bool RDSstatusold;
bool rdsstereoold;
bool rtcset;
bool scandxmode;
bool scanholdonsignal;
bool scanmem;
bool scanmute;
bool screenmute;
@@ -545,6 +546,7 @@ void setup() {
memstoppos = EEPROM.readByte(EE_BYTE_MEMSTOPPOS);
mempionly = EEPROM.readByte(EE_BYTE_MEMPIONLY);
memdoublepi = EEPROM.readByte(EE_BYTE_MEMDOUBLEPI);
scanholdonsignal = EEPROM.readByte(EE_BYTE_WAITONLYONSIGNAL);
if (spispeed == SPI_SPEED_DEFAULT) {
tft.setSPISpeed(SPI_FREQUENCY / 1000000);
@@ -852,7 +854,12 @@ void loop() {
}
if (scandxmode) {
if (millis() >= scantimer + (scanhold == 0 ? 500 : (scanhold * 1000))) {
unsigned long waitTime = (scanhold == 0) ? 500 : (scanhold * 1000);
bool signalCondition = (USN < fmscansens * 30) && (WAM < 230) && (OStatus < 80) && (OStatus > -80);
bool bypassMillisCheck = scanholdonsignal && !signalCondition;
bool shouldScan = bypassMillisCheck || (!bypassMillisCheck && (millis() >= scantimer + waitTime));
if (shouldScan) {
if (scanmem) {
memorypos++;
if (memorypos > scanstop) memorypos = scanstart;
@@ -885,19 +892,26 @@ void loop() {
}
flashingtimer = millis();
}
delay(100);
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
if (RabbitearsUser.length() && RabbitearsPassword.length() && region == REGION_US && radio.rds.correctPI != 0 && frequency >= 8810 && frequency <= 10790 && !(frequency % 10) && ((frequency/10) % 2)) {
if (RabbitearsUser.length() && RabbitearsPassword.length() && region == REGION_US && radio.rds.correctPI != 0 && frequency >= 8810 && frequency <= 10790 && !(frequency % 10) && ((frequency / 10) % 2)) {
byte i = (frequency / 10 - 881) / 2;
if (!rabbitearspi[i]) {
rabbitearspi[i] = radio.rds.correctPI;
rtc.getTime("%FT%TZ").toCharArray(rabbitearstime[i],21); // ISO8601 format like 2024-08-24T12:52:00Z
rtc.getTime("%FT%TZ").toCharArray(rabbitearstime[i], 21);
}
}
if (!initdxscan) {
switch (scancancel) {
case CORRECTPI: if (RDSstatus && radio.rds.correctPI != 0) cancelDXScan(); break;
case SIGNAL: if ((USN < fmscansens * 30) && (WAM < 230) && (OStatus < 80 && OStatus > -80)) cancelDXScan(); break;
case CORRECTPI:
if (RDSstatus && radio.rds.correctPI != 0) cancelDXScan();
break;
case SIGNAL:
if (signalCondition) cancelDXScan();
break;
}
}
}
@@ -3917,7 +3931,7 @@ void TuneUp() {
if (scandxmode && RabbitearsUser.length() && RabbitearsPassword.length()) {
byte i = 0;
bool hasreport = false;
for(i=0; i<100; i++) {
for (i = 0; i < 100; i++) {
if (rabbitearspi[i]) {
hasreport = true;
break;
@@ -3925,7 +3939,7 @@ void TuneUp() {
}
if (hasreport) {
rabbitearssend();
for (i=0; i< 100; i++) {
for (i = 0; i < 100; i++) {
rabbitearspi[i] = 0;
}
}
@@ -4328,6 +4342,7 @@ void DefaultSettings(byte userhardwaremodel) {
EEPROM.writeByte(EE_BYTE_MEMSTOPPOS, 10);
EEPROM.writeByte(EE_BYTE_MEMPIONLY, 1);
EEPROM.writeByte(EE_BYTE_MEMDOUBLEPI, 0);
EEPROM.writeByte(EE_BYTE_WAITONLYONSIGNAL, 1);
for (int i = 0; i < EE_PRESETS_CNT; i++) {
EEPROM.writeByte(i + EE_PRESETS_BAND_START, BAND_FM);
@@ -4564,6 +4579,7 @@ void endMenu() {
EEPROM.writeByte(EE_BYTE_MEMSTOPPOS, memstoppos);
EEPROM.writeByte(EE_BYTE_MEMPIONLY, mempionly);
EEPROM.writeByte(EE_BYTE_MEMDOUBLEPI, memdoublepi);
EEPROM.writeByte(EE_BYTE_WAITONLYONSIGNAL, scanholdonsignal);
EEPROM.commit();
if (af == 2) radio.rds.afreg = true; else radio.rds.afreg = false;
Serial.end();
@@ -4578,7 +4594,7 @@ void endMenu() {
void startFMDXScan() {
initdxscan = true;
for(byte i=0; i<100; i++) {
for (byte i = 0; i < 100; i++) {
rabbitearspi[i] = 0;
rabbitearstime[i][0] = 0;
}
@@ -4618,7 +4634,7 @@ void startFMDXScan() {
}
void rabbitearssend () {
if(WiFi.status() != WL_CONNECTED) return;
if (WiFi.status() != WL_CONNECTED) return;
String RabbitearsURL = "http://rabbitears.info/tvdx/fm_spot";
WiFiClient RabbitearsClient;
HTTPClient http;
@@ -4629,10 +4645,10 @@ void rabbitearssend () {
json += RabbitearsPassword;
json += String("\",");
json += String("\"signal\":{");
for (i=0; i <100; i++) {
for (i = 0; i < 100; i++) {
if (rabbitearspi[i]) {
json += String("\"");
json += String((i*2+881)*100000);
json += String((i * 2 + 881) * 100000);
json += String("\":{\"time\":\"");
json += String(rabbitearstime[i]);
json += String("\",\"pi_code\":");
@@ -4640,9 +4656,9 @@ void rabbitearssend () {
json += String("},");
}
}
json.remove(json.length()-1); // remove trailing comma
json.remove(json.length() - 1); // remove trailing comma
json += String("}}");
http.begin(RabbitearsClient,RabbitearsURL.c_str());
http.begin(RabbitearsClient, RabbitearsURL.c_str());
http.addHeader("Content-Type", "application/json");
http.POST(json);
http.end();
+5 -4
View File
@@ -209,9 +209,9 @@
#define EE_CHECKBYTE_VALUE 10 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#ifdef HAS_AIR_BAND
#define EE_TOTAL_CNT 2258 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2259 // Total occupied eeprom bytes
#else
#define EE_TOTAL_CNT 2253 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2254 // Total occupied eeprom bytes
#endif
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
@@ -322,9 +322,10 @@
#define EE_BYTE_MEMDOUBLEPI 2229
#define EE_STRING_RABBITEARSUSER 2230
#define EE_STRING_RABBITEARSPASSWORD 2241
#define EE_BYTE_WAITONLYONSIGNAL 2253
#ifdef HAS_AIR_BAND
#define EE_BYTE_AIRSTEPSIZE 2252
#define EE_UINT16_FREQUENCY_AIR 2253
#define EE_BYTE_AIRSTEPSIZE 2254
#define EE_UINT16_FREQUENCY_AIR 2255
#endif
// End of EEPROM index defines
+31 -1
View File
@@ -8,7 +8,7 @@
#include <cstring>
byte menuitem;
byte items[10] = {10, static_cast<byte>(dynamicspi ? 10 : 9), 7, 10, 10, 10, 9, 6, 8, 9};
byte items[10] = {10, static_cast<byte>(dynamicspi ? 10 : 9), 7, 10, 10, 10, 9, 6, 9, 9};
extern mem presets[];
bool setWiFiConnectParam = false;
@@ -1453,6 +1453,15 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.drawString(String(amscansens), 298, 2);
break;
case DXMODE:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
FullLineSprite.drawString(removeNewline(myLanguage[language][281]), 6, 2);
FullLineSprite.setTextDatum(TR_DATUM);
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FullLineSprite.drawString((scanholdonsignal ? myLanguage[language][42] : myLanguage[language][30]), 298, 2);
break;
case AUTOMEM:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
@@ -2661,6 +2670,13 @@ void MenuUp() {
OneBigLineSprite.drawString(String(fmscansens), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM9:
scanholdonsignal = !scanholdonsignal;
OneBigLineSprite.drawString((scanholdonsignal ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;
@@ -3602,6 +3618,13 @@ void MenuDown() {
OneBigLineSprite.drawString(String(fmscansens), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM9:
scanholdonsignal = !scanholdonsignal;
OneBigLineSprite.drawString((scanholdonsignal ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;
@@ -4587,6 +4610,13 @@ void DoMenu() {
OneBigLineSprite.drawString(String(fmscansens), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
case ITEM9:
Infoboxprint(myLanguage[language][281]);
OneBigLineSprite.drawString((scanholdonsignal ? myLanguage[language][42] : myLanguage[language][30]), 135, 0);
OneBigLineSprite.pushSprite(24, 118);
break;
}
break;
+1
View File
@@ -57,6 +57,7 @@ extern bool RDSstatusold;
extern bool rdsstereoold;
extern bool usesquelch;
extern bool scandxmode;
extern bool scanholdonsignal;
extern bool scanmem;
extern bool scanmute;
extern bool showclock;
+37 -20
View File
@@ -5,7 +5,7 @@
// [number of languages][number of texts]
static const char* const myLanguage[18][281] PROGMEM = {
static const char* const myLanguage[18][282] PROGMEM = {
{ "English", // English
"Rotary direction changed", // 1
"Please release button", // 2
@@ -286,7 +286,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Nederlands", // Dutch
@@ -569,7 +570,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"gewist", // 277
"Voorkom dubbele PI", // 278
"Bereik", // 279
"Volledig" // 280
"Volledig", // 280
"Wachttijd alleen\nbij signaal" // 281
},
{ "Polski", // Polish
@@ -852,7 +854,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"wyczyszczono", // 277
"Unikaj podwójnego PI", // 278
"Zakres", // 279
"Pełne" // 280
"Pełne", // 280
"Wait time on\nsignal only" // 281
},
{ "Hrvatski", // Croatian
@@ -1135,7 +1138,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Ελληνικά", // Greek
@@ -1418,7 +1422,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"έγινε εκκαθάριση", // 277
"Αποφυγή διπλού PI", // 278
"Εύρος", // 279
"Πλήρης" // 280
"Πλήρης", // 280
"Wait time on\nsignal only" // 281
},
{ "Română", // Romanian
@@ -1701,7 +1706,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Deutsch", // German
@@ -1984,7 +1990,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Český", // Czech
@@ -2267,7 +2274,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Magyar", // Hungarian
@@ -2550,7 +2558,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Français", // French
@@ -2833,7 +2842,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"effacé", // 277
"Prévenir double PI", // 278
"Plage", // 279
"Complet" // 280
"Complet", // 280
"Wait time on\nsignal only" // 281
},
@@ -3117,7 +3127,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Русский", // Russian
@@ -3400,7 +3411,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Українська", // Ukranian
@@ -3683,7 +3695,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Italiano", // Italian
@@ -3966,7 +3979,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"Cancellate", // 277
"Evita PI duplicati", // 278
"Intervallo", // 279
"Piene" // 280
"Piene", // 280
"Wait time on\nsignal only" // 281
},
{ "Simplified Chinese", // Simplified Chinese
@@ -4249,7 +4263,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Norsk", // Norwegian
@@ -4532,7 +4547,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"cleared", // 277
"Prevent double PI", // 278
"Range", // 279
"Full" // 280
"Full", // 280
"Wait time on\nsignal only" // 281
},
{ "Español", // Spanish
@@ -4815,7 +4831,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"borrado", // 277
"Prevenir doble PI", // 278
"Rango", // 279
"Completo" // 280
"Completo", // 280
"Wait time on\nsignal only" // 281
},
@@ -5099,8 +5116,8 @@ static const char* const myLanguage[18][281] PROGMEM = {
"limpo", // 277
"Prevenir PI duplo", // 278
"Intervalo", // 279
"Completo" // 280
"Completo", // 280
"Wait time on\nsignal only" // 281
}
};
#endif