From 214aa3d13c1d3cd3c2dd66c9a082dc1485d0019a Mon Sep 17 00:00:00 2001 From: Egor Date: Thu, 9 Jan 2025 12:14:28 -0800 Subject: [PATCH] OSD improvement --- platformio.ini | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/main.cpp | 22 +++++++++++++----- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index abcfe78..89a06cb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -76,9 +76,39 @@ build_flags = -DHELTEC -DOSD_ENABLED -DOSD_SIDE_BAR + -DSAMPLES_RSSI=5 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 -DOSD_DOT_DISPLAY + -DSIDEBAR_START_ROW=3 + -DOSD_CHART_START_ROW=14 + +[env:heltec_wifi_lora_32_V3-OSD-LORA] +platform = espressif32 +board = heltec_wifi_lora_32_V3 +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +board_build.filesystem = littlefs +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + bblanchon/ArduinoJson@^7.2.0 + ESP Async WebServer +build_flags = + -DHELTEC_POWER_BUTTON + -DHELTEC + -DOSD_ENABLED + -DOSD_SIDE_BAR + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_MODE=1 + -DOSD_DOT_DISPLAY + -DDEFAULT_RX=916 + -DDEFAULT_TX=915 + -DDEFAULT_LORA_ENABLED=true + -DDEFAULT_LORA_TX_POWER=22 + -DDEFAULT_LORA_SF=12 + -DOSD_BAR_CHAR="\"\.\"" [env:heltec_wifi_lora_32_V3_433] platform = espressif32 @@ -157,7 +187,7 @@ build_flags = -DDISPLAY_RAW_SCAN=1 -DDEFAULT_LORA_SF=12 -[env:lilygo-T3S3-v1-2-lr1121] +[env:lilygo-T3S3-v1-2-lr1121-2400] platform = espressif32 board = t3_s3_v1_x framework = arduino @@ -174,7 +204,6 @@ lib_deps = build_flags = -DLILYGO -DT3_S3_V1_2_LR1121 - -DT3_V1_3_SX1262 -DARDUINO_LILYGO_T3S3_LR1121 -DESP32 -DSAMPLES_RSSI=5 @@ -187,6 +216,34 @@ build_flags = -DARDUINO_LILYGO_T3_S3_V1_X -DARDUINO_USB_MODE=1 +[env:lilygo-T3S3-v1-2-lr1121-900] +platform = espressif32 +board = t3_s3_v1_x +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +board_build.filesystem = littlefs +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + RadioLib + U8g2 + XPowersLib + ESP Async WebServer +build_flags = + -DLILYGO + -DT3_S3_V1_2_LR1121 + -DARDUINO_LILYGO_T3S3_LR1121 + -DESP32 + -DSAMPLES_RSSI=5 + -DUSING_LR1121 + -DFREQ_BEGIN=860 + -DFREQ_END=900 + -DFREQ_RX=2440 + -DARDUINO_ARCH_ESP32 + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_LILYGO_T3_S3_V1_X + -DARDUINO_USB_MODE=1 [env:lilygo-T3S3-v1-2-sx1280] platform = espressif32 diff --git a/src/main.cpp b/src/main.cpp index b9401cf..6877de7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,8 +97,15 @@ unsigned int osdCyclesCount = 0; #define OSD_MAX_CLEAR_CYCLES 10 #ifdef OSD_ENABLED #include "DFRobot_OSD.h" +#ifndef SIDEBAR_START_ROW #define SIDEBAR_START_ROW 1 +#endif +#ifndef SIDEBAR_END_ROW #define SIDEBAR_END_ROW 10 +#endif +#ifndef OSD_CHART_START_ROW +#define OSD_CHART_START_ROW 14 +#endif // Set SIDEBAR_POSITION to 1 to right side #define SIDEBAR_POSITION OSD_WIDTH - 7 // #define SIDEBAR_ACCENT_ONLY 1 @@ -333,14 +340,18 @@ void osdPrintSignalLevelChart(int col, int signal_value) { if (i < (drone_detection_level - signal_value) / dbPerChar) { - osd.displayString(15 - i, col, OSD_BAR_CHAR); + if (i == 0) + { + osd.displayString(OSD_CHART_START_ROW - i, col, ":"); + } + osd.displayString(OSD_CHART_START_ROW - i, col, OSD_BAR_CHAR); // osd.displayString(5, col, "s:" + String(signal_value)); // osd.displayString( // 6, col, String((drone_detection_level - signal_value) / dbPerChar)); } else { - osd.displayString(15 - i, col, " "); + osd.displayString(OSD_CHART_START_ROW - i, col, " "); // osd.displayString(15 - i - 1, col, " "); // break; } @@ -351,7 +362,7 @@ void osdPrintSignalLevelChart(int col, int signal_value) for (int i = 0; i <= barSize; i++) { // Clear bar - osd.displayString(15 - i, col, " "); + osd.displayString(OSD_CHART_START_ROW - i, col, " "); } } @@ -571,6 +582,7 @@ float getRSSI(void *param) // Try getRssiInst float rssi; radio.getRssiInst(&rssi); + Serial.println("RSSI: " + String(rssi)); // pass the replies return rssi; #else @@ -613,7 +625,7 @@ int16_t initForScan(float freq) #if defined(USING_SX1280PA) state = radio.beginGFSK(freq); #elif defined(USING_LR1121) - state = radio.beginGFSK(freq, 4.8F, 5.0F, 156.2F, 10, 16U, 1.7F); + state = radio.beginGFSK(freq, 4.8F, 5.0F, 156.2F, 10, 16U, 1.6F); #else state = radio.beginFSK(freq); #endif @@ -1588,7 +1600,6 @@ std::unordered_map findMaxRssi(int16_t *rssis, uint32_t *freqs_khz void dumpHashMap(const std::unordered_map &map) { - for (const auto &entry : map) { Serial.println("Key: " + String(entry.first) + @@ -1665,7 +1676,6 @@ void display_raw_scan(ScanTaskResult &dump) if (ly > 55) { ly = 0; - // go to next column lx = lx + 45; }