From fbc20eeb45abffcbc6bb9227c3f9db24b4e3901a Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 8 Jan 2025 16:32:43 -0800 Subject: [PATCH 1/3] Some fixes --- ASCII_SA.py | 6 +++++- lib/comms/comms.h | 1 - lib/comms/radio_comms.cpp | 2 +- lib/config/config.cpp | 2 +- platformio.ini | 1 + src/main.cpp | 4 +++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ASCII_SA.py b/ASCII_SA.py index 1a9299d..c99de89 100644 --- a/ASCII_SA.py +++ b/ASCII_SA.py @@ -140,7 +140,8 @@ def draw_histogram(stdscr, data, histogram_start_row, db_threshold, db_per_hash, # Clear the histogram area clear_histogram_area(stdscr, histogram_start_row, 15, max_width) - baseline_row = histogram_start_row + 12 # Set the baseline for bars + histogram_height = 20 + baseline_row = histogram_start_row + histogram_height # Set the baseline for bars legend_start = baseline_row + 1 # Legends go below the baseline # Calculate maximum bar height @@ -259,6 +260,9 @@ def read_serial_data(stdscr, port, baudrate, resolution_mhz, db_threshold, db_pe use_color, show_debug ) + elif response.startswith("LORA_RSSI"): + stdscr.addstr(0, 0, " ", curses.color_pair(1)) + stdscr.addstr(0, 0, response + "dB", curses.color_pair(1)) else: stdscr.refresh() except serial.SerialException as e: diff --git a/lib/comms/comms.h b/lib/comms/comms.h index 56bdd61..47451ba 100644 --- a/lib/comms/comms.h +++ b/lib/comms/comms.h @@ -83,7 +83,6 @@ struct Endpoint { union { - struct { uint8_t loop : 1, // self diff --git a/lib/comms/radio_comms.cpp b/lib/comms/radio_comms.cpp index b0f0d6e..488e09f 100644 --- a/lib/comms/radio_comms.cpp +++ b/lib/comms/radio_comms.cpp @@ -385,7 +385,7 @@ Message *RadioComms::receive(uint16_t timeout_ms) radio.clearDio1Action(); packetRssi = radio.getRSSI(true); - Serial.println("Lora Last Packet RSSI:" + String(packetRssi)); + Serial.println("LORA_RSSI: " + String(packetRssi)); size_t len = radio.getPacketLength(true); uint8_t *packet = msg; diff --git a/lib/config/config.cpp b/lib/config/config.cpp index b8efae6..469de55 100644 --- a/lib/config/config.cpp +++ b/lib/config/config.cpp @@ -535,7 +535,7 @@ String Config::getConfig(String key) { return listen_on_usb; } - + // Example: SET detection_strategy RSSI_MAX 900000..950000+390 if (key.equalsIgnoreCase("detection_strategy")) { return detectionStrategyToStr(*this); diff --git a/platformio.ini b/platformio.ini index d726ea8..abcfe78 100644 --- a/platformio.ini +++ b/platformio.ini @@ -50,6 +50,7 @@ lib_deps = build_flags = -DHELTEC_POWER_BUTTON -DHELTEC + -DSAMPLES_RSSI=5 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 -DDEFAULT_RX=916 diff --git a/src/main.cpp b/src/main.cpp index 5845bdc..b9401cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -238,6 +238,8 @@ uint64_t drone_detected_frequency_start = 0; uint64_t drone_detected_frequency_end = 0; bool single_page_scan = false; +float vbat = 0; + // #define PRINT_DEBUG #define PRINT_PROFILE_TIME @@ -1133,7 +1135,7 @@ void setup(void) osd.displayString(14, 15, " Lora SA"); osd.displayString(2, 1, " Spectral RF Analyzer"); #endif - float vbat; + float resolution; bt_start = millis(); wf_start = millis(); From c005e97ad909a90a7b4cafe6d31fea01715f407b Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 8 Jan 2025 17:38:38 -0800 Subject: [PATCH 2/3] fix clear display --- ASCII_SA.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ASCII_SA.py b/ASCII_SA.py index c99de89..644d12c 100644 --- a/ASCII_SA.py +++ b/ASCII_SA.py @@ -137,10 +137,10 @@ def draw_histogram(stdscr, data, histogram_start_row, db_threshold, db_per_hash, """ max_height, max_width = stdscr.getmaxyx() - # Clear the histogram area - clear_histogram_area(stdscr, histogram_start_row, 15, max_width) - histogram_height = 20 + # Clear the histogram area + clear_histogram_area(stdscr, histogram_start_row, histogram_height, max_width) + baseline_row = histogram_start_row + histogram_height # Set the baseline for bars legend_start = baseline_row + 1 # Legends go below the baseline From 214aa3d13c1d3cd3c2dd66c9a082dc1485d0019a Mon Sep 17 00:00:00 2001 From: Egor Date: Thu, 9 Jan 2025 12:14:28 -0800 Subject: [PATCH 3/3] 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; }