From 72b5d0b80d38d80dfa4cab8ca2146d30d657c74c Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 27 Sep 2024 00:57:26 -0700 Subject: [PATCH] fix Heltec boards --- lib/loraboards/LoRaBoards.cpp | 3 +++ lib/loraboards/utilities.h | 2 ++ lib/scan/scan.h | 3 +++ platformio.ini | 13 ++++++++++--- src/main.cpp | 20 ++++++++++++++------ src/ui.cpp | 2 +- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/loraboards/LoRaBoards.cpp b/lib/loraboards/LoRaBoards.cpp index 04c93a6..0331489 100644 --- a/lib/loraboards/LoRaBoards.cpp +++ b/lib/loraboards/LoRaBoards.cpp @@ -8,6 +8,8 @@ * */ +#ifdef LILYGO + #include "LoRaBoards.h" #if defined(HAS_SDCARD) @@ -927,3 +929,4 @@ bool beginGPS() return result; } #endif +#endif // #ifdef LILYGO diff --git a/lib/loraboards/utilities.h b/lib/loraboards/utilities.h index 1d1b3ef..32a804b 100644 --- a/lib/loraboards/utilities.h +++ b/lib/loraboards/utilities.h @@ -486,6 +486,8 @@ #define USING_DIO2_AS_RF_SWITCH +#elif defined(HELTEC) +// just to prevent error #elif defined(T_BEAM_S3_BPF) #ifndef USING_SX1278 diff --git a/lib/scan/scan.h b/lib/scan/scan.h index bfbdcf8..f5af2c6 100644 --- a/lib/scan/scan.h +++ b/lib/scan/scan.h @@ -27,6 +27,9 @@ constexpr float LO_RSSI_THRESHOLD = HI_RSSI_THRESHOLD - 66; // number of samples for RSSI method #define SAMPLES_RSSI 12 // 21 // +#ifdef USING_SX1280PA +#define SAMPLES_RSSI 20 +#endif struct Scan { diff --git a/platformio.ini b/platformio.ini index 997258b..84a0e9e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,7 +28,10 @@ monitor_speed = 115200 board_build.f_cpu = 240000000 lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 -build_flags = -DHELTEC_POWER_BUTTON +build_flags = + -DHELTEC_POWER_BUTTON + -DHELTEC + [env:lilygo-T3S3-v1-2-sx1262] platform = espressif32 @@ -88,7 +91,9 @@ board_build.f_cpu = 240000000 board_build.flash_size = 80000000L lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 -build_flags = -DLILYGO +build_flags = + -DHELTEC + -DHELTEC_POWER_BUTTON [env:vision-master-e290] platform = espressif32 @@ -97,7 +102,8 @@ framework = arduino monitor_speed = 115200 monitor_filters = esp32_exception_decoder board_upload.use_1200bps_touch = true -build_flags = +build_flags = + -DHELTEC -DHELTEC_BOARD=37 -DSLOW_CLK_TPYE=1 -DARDUINO_USB_CDC_ON_BOOT=1 @@ -130,6 +136,7 @@ monitor_speed = 115200 monitor_filters = esp32_exception_decoder board_upload.use_1200bps_touch = true build_flags = + -DHELTEC -DHELTEC_BOARD=38 -DSLOW_CLK_TPYE=1 -DARDUINO_USB_CDC_ON_BOOT=1 diff --git a/src/main.cpp b/src/main.cpp index fdcd374..dd891aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,22 +36,24 @@ // library internals. #define RADIOLIB_GODMODE (1) -#include #include #ifndef LILYGO #include // This file contains a binary patch for the SX1262 #include "modules/SX126x/patches/SX126x_patch_scan.h" -#endif // end LILYGO +#endif // end ifndef LILYGO + #if defined(LILYGO) // LiLyGO device does not support the auto download mode, you need to get into the // download mode manually. To do so, press and hold the BOOT button and then press the // RESET button once. After that release the BOOT button. Or OFF->ON together with BOOT // Default LilyGO code -#include "utilities.h" -// Our Code +#include + +// #include "utilities.h" +// Our Code #include "LiLyGo.h" #endif // end LILYGO @@ -134,6 +136,10 @@ uint64_t RANGE_PER_PAGE = FREQ_END - FREQ_BEGIN; // FREQ_END - FREQ_BEGIN // multiplies STEPS * N to increase scan resolution. #define SCAN_RBW_FACTOR 2 +#ifdef USING_SX1280PA +#define SCAN_RBW_FACTOR 2 +#endif + constexpr int OSD_PIXELS_PER_CHAR = (STEPS * SCAN_RBW_FACTOR) / OSD_CHART_WIDTH; #define DEFAULT_RANGE_PER_PAGE 50 @@ -423,9 +429,11 @@ void init_radio() void setup(void) { +#ifdef LILYGO setupBoards(); - delay(5000); - Serial.println("setup is done"); + delay(3000); + Serial.println("setup LiLyGO board is done"); +#endif // LED brightness heltec_led(25); diff --git a/src/ui.cpp b/src/ui.cpp index 94342b7..ee8bc92 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -223,7 +223,7 @@ void UI_displayDecorate(int begin = 0, int end = 0, bool redraw = false) display_instance->setTextAlignment(TEXT_ALIGN_CENTER); // clear status line clearStatus(); - display_instance->drawString(start_scan_text, ROW_STATUS_TEXT, + display_instance->drawString(start_scan_text + 2, ROW_STATUS_TEXT, String(drone_detected_frequency_start) + ">RF<" + String(drone_detected_frequency_end)); }