changing between 3 freqs

This commit is contained in:
richonguzman 2024-02-28 17:29:18 -03:00
parent 0d28a12458
commit 93fd1e6d30
6 changed files with 133 additions and 86 deletions

View File

@ -1,7 +1,7 @@
{
"beacons": [
{
"callsign": "NOCALL-7",
"callsign": "CA2RXU-7",
"symbol": "[",
"overlay": "/",
"micE": "",
@ -19,7 +19,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CA2RXU-7",
"symbol": ">",
"overlay": "/",
"micE": "",
@ -37,7 +37,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CA2RXU-7",
"symbol": "b",
"overlay": "/",
"micE": "",
@ -57,7 +57,7 @@
],
"display": {
"showSymbol": true,
"ecoMode": false,
"ecoMode": true,
"timeout": 4,
"turn180" : false
},
@ -76,7 +76,7 @@
"disableGPS": false
},
"winlink": {
"password": "ABCDEF"
"password": "VMRJPJ"
},
"bme": {
"active": false,
@ -84,20 +84,20 @@
"heightCorrection": 0
},
"notification": {
"ledTx": false,
"ledTxPin": 13,
"ledMessage": false,
"ledMessagePin": 2,
"ledFlashlight": false,
"ledFlashlightPin": 14,
"buzzerActive": false,
"buzzerPinTone": 33,
"buzzerPinVcc": 25,
"bootUpBeep": false,
"txBeep": false,
"messageRxBeep": false,
"stationBeep": false,
"lowBatteryBeep": false
"ledTx": true,
"ledTxPin": 25,
"ledMessage": true,
"ledMessagePin": 13,
"ledFlashlight": true,
"ledFlashlightPin": 14,
"buzzerActive": true,
"buzzerPinTone": 4,
"buzzerPinVcc": 2,
"bootUpBeep": true,
"txBeep": false,
"messageRxBeep": true,
"stationBeep": true,
"lowBatteryBeep": false
},
"lora": [
{

View File

@ -49,7 +49,7 @@ BluetoothSerial SerialBT;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif
String versionDate = "2024.02.24";
String versionDate = "2024.02.28";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();

View File

@ -8,6 +8,7 @@
#include "configuration.h"
#include "button_utils.h"
#include "power_utils.h"
#include "pins_config.h"
#include "msg_utils.h"
#include "display.h"
@ -67,21 +68,21 @@ namespace KEYBOARD_Utils {
}
}
else if (menuDisplay >= 20 && menuDisplay <= 26) {
else if (menuDisplay >= 20 && menuDisplay <= 27) {
menuDisplay--;
if (menuDisplay < 20) {
menuDisplay = 26;
}
} else if (menuDisplay >= 210 && menuDisplay <= 211) {
menuDisplay--;
if (menuDisplay < 210) {
menuDisplay = 211;
menuDisplay = 27;
}
} else if (menuDisplay >= 220 && menuDisplay <= 221) {
menuDisplay--;
if (menuDisplay < 220) {
menuDisplay = 221;
}
} else if (menuDisplay >= 240 && menuDisplay <= 241) {
menuDisplay--;
if (menuDisplay < 240) {
menuDisplay = 241;
}
}
else if (menuDisplay >= 30 && menuDisplay <= 31) {
@ -167,21 +168,21 @@ namespace KEYBOARD_Utils {
menuDisplay = 11;
}
else if (menuDisplay >= 20 && menuDisplay <= 26) {
else if (menuDisplay >= 20 && menuDisplay <= 27) {
menuDisplay++;
if (menuDisplay > 26) {
if (menuDisplay > 27) {
menuDisplay = 20;
}
} else if (menuDisplay >= 210 && menuDisplay <= 211) {
menuDisplay++;
if (menuDisplay > 211) {
menuDisplay = 210;
}
} else if (menuDisplay >= 220 && menuDisplay <= 221) {
menuDisplay++;
if (menuDisplay > 221) {
menuDisplay = 220;
}
} else if (menuDisplay >= 240 && menuDisplay <= 241) {
menuDisplay++;
if (menuDisplay > 241) {
menuDisplay = 240;
}
}
else if (menuDisplay >= 30 && menuDisplay <= 31) {
@ -291,7 +292,7 @@ namespace KEYBOARD_Utils {
}
void rightArrow() {
if (menuDisplay == 0) {
if (menuDisplay == 0 || menuDisplay == 200) {
if(myBeaconsIndex >= (myBeaconsSize-1)) {
myBeaconsIndex = 0;
} else {
@ -301,9 +302,12 @@ namespace KEYBOARD_Utils {
displayTime = millis();
statusState = true;
statusTime = millis();
show_display("__ INFO __", "", " CHANGING CALLSIGN!", 1000);
show_display("__ INFO __", "", " CHANGING CALLSIGN!", "", "-----> " + Config.beacons[myBeaconsIndex].callsign, 2000);
STATION_Utils::saveCallsingIndex(myBeaconsIndex);
} else if ((menuDisplay>=1 && menuDisplay<=3) || (menuDisplay>=11 &&menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay>=30 && menuDisplay<=31)) {
if (menuDisplay == 200) {
menuDisplay = 20;
}
} else if ((menuDisplay>=1 && menuDisplay<=3) || (menuDisplay>=11 &&menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=27) || (menuDisplay>=30 && menuDisplay<=31)) {
menuDisplay = menuDisplay*10;
} else if (menuDisplay == 10) {
MSG_Utils::loadMessagesFromMemory("APRS");
@ -338,8 +342,10 @@ namespace KEYBOARD_Utils {
show_display(" APRS Thu.", "", " Keep Subscribed" ," for 12hours more", 2000);
MSG_Utils::sendMessage(0, "ANSRVR", "K HOTG");
}
else if (menuDisplay == 210) {
LoRa_Utils::changeFreq();
} else if (menuDisplay == 220) {
if (!displayEcoMode) {
displayEcoMode = true;
show_display("_DISPLAY__", "", " ECO MODE -> ON", 1000);
@ -347,7 +353,7 @@ namespace KEYBOARD_Utils {
displayEcoMode = false;
show_display("_DISPLAY__", "", " ECO MODE -> OFF", 1000);
}
} else if (menuDisplay == 211) {
} else if (menuDisplay == 221) {
if (screenBrightness ==1) {
show_display("_SCREEN___", "", "SCREEN BRIGHTNESS MAX", 1000);
screenBrightness = 255;
@ -355,11 +361,11 @@ namespace KEYBOARD_Utils {
show_display("_SCREEN___", "", "SCREEN BRIGHTNESS MIN", 1000);
screenBrightness = 1;
}
} else if (menuDisplay == 230) {
show_display("_STATUS___", "", "WRITE STATUS","STILL IN DEVELOPMENT!", 2000); /////////////////////////
} else if (menuDisplay == 231) {
show_display("_STATUS___", "", "SELECT STATUS","STILL IN DEVELOPMENT!", 2000); /////////////////////////
} else if (menuDisplay == 240) {
show_display("_STATUS___", "", "WRITE STATUS","STILL IN DEVELOPMENT!", 2000); /////////////////////////
} else if (menuDisplay == 241) {
show_display("_STATUS___", "", "SELECT STATUS","STILL IN DEVELOPMENT!", 2000); /////////////////////////
} else if (menuDisplay == 250) {
show_display("_NOTIFIC__", "", "NOTIFICATIONS","STILL IN DEVELOPMENT!", 2000); /////////////////////////
}
@ -553,25 +559,16 @@ namespace KEYBOARD_Utils {
} else if (key == 8) { // Delete Last Key
messageText = messageText.substring(0, messageText.length()-1);
}
} else if (menuDisplay == 200 && key == 13) {
if(myBeaconsIndex >= (myBeaconsSize - 1)) {
myBeaconsIndex = 0;
} else {
myBeaconsIndex++;
}
display_toggle(true);
displayTime = millis();
statusState = true;
statusTime = millis();
show_display("__ INFO __", "", " CHANGING CALLSIGN!", 1000);
STATION_Utils::saveCallsingIndex(myBeaconsIndex);
menuDisplay = 0;
} else if (menuDisplay == 250 && key == 13) {
} else if (menuDisplay == 260 && key == 13) {
show_display("", "", " REBOOTING ...", 2000);
ESP.restart();
} else if (menuDisplay == 260 && key == 13) {
} else if (menuDisplay == 270 && key == 13) {
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
show_display("", "", " POWER OFF ...", 2000);
POWER_Utils::shutdown();
#else
show_display("", "", "ESP32 CAN'T POWER OFF", 2000);
#endif
} else if ((menuDisplay == 5021 || menuDisplay == 5031 || menuDisplay == 5041 || menuDisplay == 5051) && key >= 48 && key <= 57) {
winlinkMailNumber = key;
} else if ((menuDisplay == 5021 || menuDisplay == 5031 || menuDisplay == 5041 || menuDisplay == 5051) && key == 8) {

View File

@ -11,6 +11,8 @@
extern logging::Logger logger;
extern Configuration Config;
extern LoraType *currentLoRaType;
extern int loraIndex;
extern int loraIndexSize;
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(OE5HWN_MeshCom)
@ -32,6 +34,50 @@ namespace LoRa_Utils {
#endif
}
void changeFreq() {
if(loraIndex >= (loraIndexSize - 1)) {
loraIndex = 0;
} else {
loraIndex++;
}
currentLoRaType = &Config.loraTypes[loraIndex];
#ifdef HAS_SX126X
float freq = (float)currentLoRaType->frequency/1000000;
radio.setFrequency(freq);
radio.setSpreadingFactor(currentLoRaType->spreadingFactor);
radio.setBandwidth(currentLoRaType->signalBandwidth);
radio.setCodingRate(currentLoRaType->codingRate4);
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3) || defined(HELTEC_V3_GPS)
radio.setOutputPower(currentLoRaType->power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22.
#endif
#if defined(ESP32_DIY_1W_LoRa_GPS) || defined(OE5HWN_MeshCom)
radio.setOutputPower(currentLoRaType->power);
#endif
#endif
#ifdef HAS_SX127X
LoRa.setFrequency(currentLoRaType->frequency);
LoRa.setSpreadingFactor(currentLoRaType->spreadingFactor);
LoRa.setSignalBandwidth(currentLoRaType->signalBandwidth);
LoRa.setCodingRate4(currentLoRaType->codingRate4);
LoRa.setTxPower(currentLoRaType->power);
#endif
String loraCountryFreq;
switch (loraIndex) {
case 0:
loraCountryFreq = "EU/WORLD";
break;
case 1:
loraCountryFreq = "POLAND";
break;
case 2:
loraCountryFreq = "UK";
break;
}
String currentLoRainfo = "LoRa " + loraCountryFreq + " / Freq: " + String(currentLoRaType->frequency) + " / SF:" + String(currentLoRaType->spreadingFactor) + " / CR: " + String(currentLoRaType->codingRate4);
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", currentLoRainfo.c_str());
show_display("LORA FREQ>", "", "CHANGED TO: " + loraCountryFreq, "", "", "", 2000);
}
void setup() {
#ifdef HAS_SX126X
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
@ -69,10 +115,7 @@ namespace LoRa_Utils {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
//long freq = Config.loramodule.frequency;
long freq = currentLoRaType->frequency;
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Frequency: %d", freq);
if (!LoRa.begin(freq)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "LoRa", "Starting LoRa failed!");
show_display("ERROR", "Starting LoRa failed!");
@ -80,16 +123,14 @@ namespace LoRa_Utils {
delay(1000);
}
}
//LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor);
LoRa.setSpreadingFactor(currentLoRaType->spreadingFactor);
//LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth);
LoRa.setSignalBandwidth(currentLoRaType->signalBandwidth);
//LoRa.setCodingRate4(Config.loramodule.codingRate4);
LoRa.setCodingRate4(currentLoRaType->codingRate4);
LoRa.enableCrc();
//LoRa.setTxPower(Config.loramodule.power);
LoRa.setTxPower(currentLoRaType->power);
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");
String currentLoRainfo = "LoRa Freq: " + String(currentLoRaType->frequency) + " / SF:" + String(currentLoRaType->spreadingFactor) + " / CR: " + String(currentLoRaType->codingRate4);
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", currentLoRainfo.c_str());
#endif
}

View File

@ -13,6 +13,7 @@ struct ReceivedLoRaPacket {
namespace LoRa_Utils {
void setFlag();
void changeFreq();
void setup();
void sendNewPacket(const String &newPacket);
ReceivedLoRaPacket receivePacket();

View File

@ -179,39 +179,47 @@ namespace MENU_Utils {
//////////
case 20: // 2.Configuration ---> Callsign
show_display("_CONFIG___", " Power Off", "> Callsign Change"," Display", " " + checkBTType() + " (" + checkProcessActive(bluetoothActive) + ")",lastLine);
show_display("_CONFIG___", " Power Off", "> Change Callsign ", " Change Frequency", " Display",lastLine);
break;
case 21: // 2.Configuration ---> Display
show_display("_CONFIG___", " Callsign Change", "> Display", " " + checkBTType() + " ("+ checkProcessActive(bluetoothActive) + ")", " Status",lastLine);
case 21: // 2.Configuration ---> Change Freq
show_display("_CONFIG___", " Change Callsign ", "> Change Frequency", " Display", " " + checkBTType() + " ("+ checkProcessActive(bluetoothActive) + ")",lastLine);
break;
case 22: // 2.Configuration ---> Bluetooth
case 22: // 2.Configuration ---> Display
show_display("_CONFIG___", " Change Frequency", "> Display", " " + checkBTType() + " ("+ checkProcessActive(bluetoothActive) + ")", " Status",lastLine);
break;
case 23: // 2.Configuration ---> Bluetooth
show_display("_CONFIG___", " Display", "> " + checkBTType() + " (" + checkProcessActive(bluetoothActive) + ")", " Status", " Notifications", lastLine);
break;
case 23: // 2.Configuration ---> Status
case 24: // 2.Configuration ---> Status
show_display("_CONFIG___", " " + checkBTType() + " (" + checkProcessActive(bluetoothActive) + ")", "> Status"," Notifications", " Reboot",lastLine);
break;
case 24: // 2.Configuration ---> Notifications
case 25: // 2.Configuration ---> Notifications
show_display("_CONFIG___", " Status", "> Notifications", " Reboot", " Power Off",lastLine);
break;
case 25: // 2.Configuration ---> Reboot
show_display("_CONFIG___", " Notifications", "> Reboot", " Power Off", " Callsign Change",lastLine);
case 26: // 2.Configuration ---> Reboot
show_display("_CONFIG___", " Notifications", "> Reboot", " Power Off", " Change Callsign",lastLine);
break;
case 26: // 2.Configuration ---> Power Off
show_display("_CONFIG___", " Reboot", "> Power Off", " Callsign Change", " Display",lastLine);
case 27: // 2.Configuration ---> Power Off
show_display("_CONFIG___", " Reboot", "> Power Off", " Change Callsign", " Change Frequency",lastLine);
break;
case 200: // 2.Configuration ---> Callsign
show_display("_CALLSIGN_", ""," Confirm Change?","","","<Back Enter=Confirm");
case 200: // 2.Configuration ---> Change Callsign
show_display("_CALLSIGN_", ""," Confirm Change?","","","<Back Select>");
break;
case 210: // 2.Configuration ---> Display ---> ECO Mode
case 210: // 2.Configuration ---> Change Frequency
show_display("LORA__FREQ", ""," Confirm Change?","","","<Back Select>");
break;
case 220: // 2.Configuration ---> Display ---> ECO Mode
show_display("_DISPLAY__", "", "> ECO Mode (" + checkProcessActive(displayEcoMode) + ")"," Brightness (" + checkScreenBrightness(screenBrightness) + ")","",lastLine);
break;
case 211: // 2.Configuration ---> Display ---> Brightness
case 221: // 2.Configuration ---> Display ---> Brightness
show_display("_DISPLAY__", "", " ECO Mode (" + checkProcessActive(displayEcoMode) + ")","> Brightness (" + checkScreenBrightness(screenBrightness) + ")","",lastLine);
break;
case 220:
case 230:
if (bluetoothActive) {
bluetoothActive = false;
show_display("BLUETOOTH", "", " Bluetooth --> OFF", 1000);
@ -219,28 +227,28 @@ namespace MENU_Utils {
bluetoothActive = true;
show_display("BLUETOOTH", "", " Bluetooth --> ON", 1000);
}
menuDisplay = 22;
menuDisplay = 23;
break;
case 230: // 2.Configuration ---> Status
case 240: // 2.Configuration ---> Status
show_display("_STATUS___", "", "> Write"," Select","",lastLine);
break;
case 231: // 2.Configuration ---> Status
case 241: // 2.Configuration ---> Status
show_display("_STATUS___", "", " Write","> Select","",lastLine);
break;
case 240: // 2.Configuration ---> Notifications
case 250: // 2.Configuration ---> Notifications
show_display("_NOTIFIC__", "> Turn Off Sound/Led","","","",lastLine);
break;
case 250: // 2.Configuration ---> Reboot
case 260: // 2.Configuration ---> Reboot
if (keyDetected) {
show_display("_REBOOT?__", "","Confirm Reboot...","","","<Back Enter=Confirm");
} else {
show_display("_REBOOT?__", "no Keyboard Detected"," Use RST Button to","Reboot Tracker","",lastLine);
}
break;
case 260: // 2.Configuration ---> Power Off
case 270: // 2.Configuration ---> Power Off
if (keyDetected) {
show_display("POWER_OFF?", "","Confirm Power Off...","","","<Back Enter=Confirm");
} else {