From 39073dd026708cf5d4024e02271260c962ca6a58 Mon Sep 17 00:00:00 2001 From: Sassa NF Date: Sat, 28 Sep 2024 16:58:29 +0100 Subject: [PATCH] Filtered_results is not needed --- lib/scan/scan.cpp | 2 +- src/main.cpp | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/scan/scan.cpp b/lib/scan/scan.cpp index bc58902..5f584b4 100644 --- a/lib/scan/scan.cpp +++ b/lib/scan/scan.cpp @@ -69,7 +69,7 @@ uint16_t Scan::rssiMethod(size_t samples, uint16_t *result, size_t res_size) size_t Scan::detect(uint16_t *result, bool *filtered_result, size_t result_size, int samples) { - size_t max_rssi_x = 999; + size_t max_rssi_x = result_size; for (int y = 0; y < result_size; y++) { diff --git a/src/main.cpp b/src/main.cpp index ed469c1..6fd371a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1060,13 +1060,12 @@ void loop(void) detected_y[display_x] = false; #if FILTER_SPECTRUM_RESULTS - for (int y = 0; y < RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE; y++) + if (detected) { // calculating max window x RSSI after filters x_window = (int)(display_x / WINDOW_SIZE); - int abs_result = abs(result[y]); - if (filtered_result[y] == 1 && result[y] != 0 && result[y] != 1 && - max_x_window[x_window] > abs_result) + int abs_result = abs(result[detected_at]); + if (max_x_window[x_window] > abs_result) { max_x_window[x_window] = abs_result; LOG("MAX x window: %i %i\n", x_window, abs_result); @@ -1147,23 +1146,18 @@ void loop(void) } #endif - for (int y = 0; y < min(RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE, - MAX_POWER_LEVELS - START_LOW); - y++) - { - if (filtered_result[y] == 1) - { - // Set MAIN signal level pixel - display.setPixelColor(display_x, y + START_LOW, WHITE); - } - } + display.setColor(WHITE); + display.drawVerticalLine(display_x, START_LOW + detected_at, + min(RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE, + MAX_POWER_LEVELS - START_LOW) - + detected_at); // ------------------------------------------------------------- // Draw "Detection Level line" every 2 pixel // ------------------------------------------------------------- if (display_x % 2 == 0) { - if (filtered_result[drone_detection_level] == 1) + if (detected_at <= drone_detection_level) { display.setColor(INVERSE); }