|
23 | 23 | #include "../Radio/Radio.h" |
24 | 24 | #include "../Display/graphics.h" |
25 | 25 | #include "../Mqtt/MQTT_credentials.h" |
| 26 | +#include "../Power/Battery.h" |
26 | 27 | #include "ArduinoJson.h" |
27 | 28 | #if ARDUINOJSON_USE_LONG_LONG == 0 && !PLATFORMIO |
28 | 29 | #error "Using Arduino IDE is not recommended, please follow this guide https://github.com/G4lile0/tinyGS/wiki/Arduino-IDE or edit /ArduinoJson/src/ArduinoJson/Configuration.hpp and amend to #define ARDUINOJSON_USE_LONG_LONG 1 around line 68" |
@@ -53,17 +54,17 @@ ConfigManager::ConfigManager() |
53 | 54 | //OLED_add, OLED_SDA, OLED_SCL, OLED_RST, PROG_BUTTON, BOARD_LED, L_SX127X?, L_NSS, L_DI00, L_DI01, L_BUSSY, L_RST, L_MISO, L_MOSI, L_SCK, L_TCXO_V, RX_EN, TX_EN, ADC_CTL, BAT_AIN, VBAT_SCALE, BOARD |
54 | 55 | #if CONFIG_IDF_TARGET_ESP32S3 |
55 | 56 | { 0x3c, 17, 18, 21, 0, 35, RADIO_SX1262, 8, UNUSED, 14, 13, 12, 11, 10, 9, 1.6f, UNUSED, UNUSED, 37, 1, 0.00405f, "150–960Mhz - HELTEC LORA32 V3 SX1262" }, // SX1262 |
56 | | - { 0x3c, 17, 18, UNUSED, 0, 35, RADIO_SX1278, 8, 6, 14, UNUSED, 12, 11, 10, 9, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "Custom ESP32-S3 433MHz SX1278" }, // SX1278 @g4lile0 |
57 | | - { 0x3c, 17, 18, UNUSED, 0, 3, RADIO_SX1262, 10, UNUSED, 1, 4, 5, 13, 11, 12, 1.6f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433 Mhz TTGO T-Beam Sup SX1262 V1.0" }, // SX1268 @ Stephen |
58 | | - { 0x3c, 17, 18, UNUSED, 0, 37, RADIO_SX1280, 7, UNUSED, 9, UNUSED, 8, 3, 6, 5, 0.0f, 21, 10, UNUSED, UNUSED, UNUSED, "2.4Ghz LILYGO SX1280" }, // SX1280 @ K4KDR |
| 57 | + { 0x3c, 17, 18, UNUSED, 0, 35, RADIO_SX1278, 8, 6, 14, UNUSED, 12, 11, 10, 9, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "Custom ESP32-S3 433MHz SX1278" }, // SX1278 @g4lile0 |
| 58 | + { 0x3c, 17, 18, UNUSED, 0, 3, RADIO_SX1262, 10, UNUSED, 1, 4, 5, 13, 11, 12, 1.6f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433 Mhz TTGO T-Beam Sup SX1262 V1.0" }, // SX1268 @ Stephen |
| 59 | + { 0x3c, 17, 18, UNUSED, 0, 37, RADIO_SX1280, 7, UNUSED, 9, UNUSED, 8, 3, 6, 5, 0.0f, 21, 10, UNUSED, UNUSED, UNUSED, "2.4Ghz LILYGO SX1280" }, // SX1280 @ K4KDR |
59 | 60 | #elif CONFIG_IDF_TARGET_ESP32C3 |
60 | 61 | { 0x3c, 0, 1, UNUSED, 20, 21, RADIO_SX1262, 8, UNUSED, 3, 4, 5, 6, 7, 10, 1.6f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433MHz HELTEC LORA32 HT-CT62 SX1262" }, // SX1262 @gargomoma |
61 | 62 | { 0x3c, 0, 1, UNUSED, 20, 21, RADIO_SX1278, 8, 4, UNUSED, UNUSED, 5, 6, 7, 10, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "Custom ESP32-C3 433MHz SX1278" }, // SX1278 @gargomoma |
62 | 63 | #else |
63 | | - { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1278, 18, 26, 12, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, 36, UNUSED, "433MHz HELTEC WiFi LoRA 32 V1" }, // SX1278 @4m1g0 |
64 | | - { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1276, 18, 26, 12, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, 36, UNUSED, "863-928MHz HELTEC WiFi LoRA 32 V1" }, // SX1276 |
65 | | - { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1278, 18, 26, 35, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, 36, UNUSED, "433MHz HELTEC WiFi LoRA 32 V2" }, // SX1278 @4m1g0 |
66 | | - { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1276, 18, 26, 35, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, 36, UNUSED, "863-928MHz HELTEC WiFi LoRA 32 V2" }, // SX1276 |
| 64 | + { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1278, 18, 26, 12, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433MHz HELTEC WiFi LoRA 32 V1" }, // SX1278 @4m1g0 |
| 65 | + { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1276, 18, 26, 12, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "863-928MHz HELTEC WiFi LoRA 32 V1" }, // SX1276 |
| 66 | + { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1278, 18, 26, 35, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, 21, 37, 0.00283f, "433MHz HELTEC WiFi LoRA 32 V2" }, // SX1278 @4m1g0 |
| 67 | + { 0x3c, 4, 15, 16, 0, 25, RADIO_SX1276, 18, 26, 35, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, 21, 37, 0.00283f, "863-928MHz HELTEC WiFi LoRA 32 V2" }, // SX1276 |
67 | 68 | { 0x3c, 4, 15, 16, 0, 2, RADIO_SX1278, 18, 26, UNUSED, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433Mhz TTGO LoRa 32 v1" }, // SX1278 @g4lile0 |
68 | 69 | { 0x3c, 4, 15, 16, 0, 2, RADIO_SX1276, 18, 26, UNUSED, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "868-915MHz TTGO LoRa 32 v1" }, // SX1276 |
69 | 70 | { 0x3c, 21, 22, UNUSED, 0, 22, RADIO_SX1278, 18, 26, 33, UNUSED, 14, 19, 27, 5, 0.0f, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, "433MHz TTGO LoRA 32 v2" }, // SX1278 @TCRobotics |
@@ -261,7 +262,12 @@ void ConfigManager::handleDashboard() |
261 | 262 | s += "<tr><td>WiFi RSSI </td><td>" + String(WiFi.isConnected() ? "<span class='G'>CONNECTED</span>" : "<span class='R'>NOT CONNECTED</span>") + "</td></tr>"; |
262 | 263 | s += "<tr><td>Radio </td><td>" + String(Radio::getInstance().isReady() ? "<span class='G'>READY</span>" : "<span class='R'>NOT READY</span>") + "</td></tr>"; |
263 | 264 | s += "<tr><td>Noise floor </td><td>" + String(status.modeminfo.currentRssi) + "</td></tr>"; |
264 | | - s += "<tr><td>Battery </td><td>" + String(status.vbat) + "V</td></tr>"; |
| 265 | + if (status.vbat > 0) { |
| 266 | + s += "<tr><td>Battery </td><td>" + String(status.vbat) + "V " + String(getBatteryPercentage()) + "%</td></tr>"; |
| 267 | + } else { |
| 268 | + // Empty if battery monitoring not enabled |
| 269 | + s += "<tr><td></td><td></td></tr>"; |
| 270 | + } |
265 | 271 | s += F("</table></div>"); |
266 | 272 |
|
267 | 273 |
|
@@ -498,7 +504,12 @@ void ConfigManager::handleRefreshWorldmap() |
498 | 504 | if (status.radio_ready) |
499 | 505 | radio.currentRssi (); |
500 | 506 | data_string += String(status.modeminfo.currentRssi) + ","; |
501 | | - data_string += String(status.vbat) + ","; |
| 507 | + if (status.vbat > 0) { |
| 508 | + data_string += String(status.vbat) + "V " + String(getBatteryPercentage()) + "%,"; |
| 509 | + } else { |
| 510 | + // if battery monitoring not enabled |
| 511 | + data_string += "Unknown,"; |
| 512 | + } |
502 | 513 |
|
503 | 514 |
|
504 | 515 | // sat_info |
@@ -744,8 +755,8 @@ void ConfigManager::printConfig() |
744 | 755 | Log::debug(PSTR("tz: %s\nOLED Bright: %u\nTX %s"), getTZ(), getOledBright(), getAllowTx() ? "Enable" : "Disable"); |
745 | 756 | if (getBoardTemplate()[0] != '\0') |
746 | 757 | Log::debug(PSTR("board_template: %s"),getBoardTemplate()); |
747 | | - else |
748 | | - Log::debug(PSTR("board: %u --> %s\n:"),getBoard(), boards[getBoard()].BOARD.c_str()); |
| 758 | + else |
| 759 | + Log::debug(PSTR("board_template: %s"), boardTemplateToJSON(boards[getBoard()]).c_str() ); |
749 | 760 | } |
750 | 761 |
|
751 | 762 | // void ConfigManager::setMqttServer(const char *server) |
@@ -1029,3 +1040,36 @@ bool ConfigManager::parseBoardTemplate(board_t &board) |
1029 | 1040 |
|
1030 | 1041 | return true; |
1031 | 1042 | } |
| 1043 | + |
| 1044 | +String ConfigManager::boardTemplateToJSON(board_t &board) |
| 1045 | +{ |
| 1046 | + size_t size = JSON_OBJECT_SIZE(22) + 256; |
| 1047 | + DynamicJsonDocument doc(size); |
| 1048 | + String output; |
| 1049 | + |
| 1050 | + doc["aADDR"] = board.OLED__address; |
| 1051 | + doc["oSDA"] = board.OLED__SDA; |
| 1052 | + doc["oSCL"] = board.OLED__SCL; |
| 1053 | + doc["oRST"] = board.OLED__RST; |
| 1054 | + doc["pBut"] = board.PROG__BUTTON; |
| 1055 | + doc["led"] = board.BOARD_LED; |
| 1056 | + doc["radio"] = board.L_radio; |
| 1057 | + doc["lNSS"] = board.L_NSS; |
| 1058 | + doc["lDIO0"] = board.L_DI00; |
| 1059 | + doc["lDIO1"] = board.L_DI01; |
| 1060 | + doc["lBUSSY"] = board.L_BUSSY; |
| 1061 | + doc["lRST"] = board.L_RST; |
| 1062 | + doc["lMISO"] = board.L_MISO; |
| 1063 | + doc["lMOSI"] = board.L_MOSI; |
| 1064 | + doc["lSCK"] = board.L_SCK; |
| 1065 | + doc["lTCXOV"] = board.L_TCXO_V; |
| 1066 | + doc["RXEN"] = board.RX_EN; |
| 1067 | + doc["TXEN"] = board.TX_EN; |
| 1068 | + doc["ADC_CTL"] = board.ADC_CTL; |
| 1069 | + doc["VBAT"] = board.VBAT_AIN; |
| 1070 | + doc["VBAT_SCALE"] = board.VBAT_SCALE; |
| 1071 | + doc["name"] = board.BOARD; |
| 1072 | + |
| 1073 | + serializeJson(doc, output); |
| 1074 | + return output; |
| 1075 | +} |
0 commit comments