From 109b71739f1dd7d65cbc94b21983f4823c17698a Mon Sep 17 00:00:00 2001 From: Egor Shitikov Date: Fri, 13 Sep 2024 16:49:18 -0700 Subject: [PATCH] Fix result index --- platformio.ini | 4 ---- src/main.cpp | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 0b7648d..24ece4d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,7 +25,6 @@ monitor_speed = 115200 board_build.f_cpu = 240000000 lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 build_flags = -DHELTEC_POWER_BUTTON [env:lilygo-T3S3-v1-2] @@ -38,7 +37,6 @@ board_build.f_cpu = 240000000 lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 RadioLib - adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 build_flags = -DLILYGO -DT3_S3_V1_2_SX1262 @@ -61,7 +59,6 @@ board_build.f_cpu = 240000000 board_build.flash_size = 80000000L lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 build_flags = -DLILYGO [env:vision-master-e290] @@ -95,7 +92,6 @@ lib_deps = https://github.com/HelTecAutomation/Heltec_ESP32/ adafruit/Adafruit GFX Library@^1.11.10 ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 [env:vision-master-t190] platform = espressif32 diff --git a/src/main.cpp b/src/main.cpp index acfc13b..cb51aeb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -948,6 +948,11 @@ void loop(void) // I like this formula better result_index = uint8_t(abs(rssi) / 2) - 22; } + if (result_index >= RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE) + { + // Maximum index possible + result_index = RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE - 1; + } #ifdef PRINT_DEBUG Serial.printf("RSSI: %d IDX: %d\n", rssi, result_index);