From f703abce20a7a75cf98e40cc25f0c9cf2bb6136f Mon Sep 17 00:00:00 2001 From: Egor Shitikov Date: Sat, 14 Sep 2024 18:21:22 -0700 Subject: [PATCH 1/3] fix issues described by Olexii --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cb51aeb..3852959 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -960,8 +960,8 @@ void loop(void) // avoid buffer overflow if (result_index < RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE) { - // Saving max value only rss is negative so smaller is bigger - if (result[result_index] > rssi) + // Saving max value of the rssi. + if (result[result_index] < rssi) { result[result_index] = rssi; } @@ -1023,7 +1023,7 @@ void loop(void) { // do not process 'first' and 'last' row to avoid out of index // access. - if ((y > 0) && (y != (RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE - 3))) + if ((y > 0) && (y < (RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE - 3))) { if (((result[y + 1] != 0) && (result[y + 2] != 0)) || (result[y - 1] != 0)) From bd852bda3368b2951d1a4855b8f0634fc99d3851 Mon Sep 17 00:00:00 2001 From: Egor Shitikov Date: Sat, 14 Sep 2024 19:11:46 -0700 Subject: [PATCH 2/3] add some fixes --- src/main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3852959..88f76bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -750,7 +750,7 @@ void check_ranges() single_page_scan = false; } } -// MAX Frequency RSSI value of the samples +// MAX Frequency RSSI BIN value of the samples int max_rssi_x = 999; void loop(void) @@ -960,10 +960,10 @@ void loop(void) // avoid buffer overflow if (result_index < RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE) { - // Saving max value of the rssi. - if (result[result_index] < rssi) + // Saving max value only rss is negative so smaller is bigger + if (result[result_index] == 0 || result[result_index] > abs(rssi)) { - result[result_index] = rssi; + result[result_index] = abs(rssi); } } else @@ -1023,12 +1023,14 @@ void loop(void) { // do not process 'first' and 'last' row to avoid out of index // access. - if ((y > 0) && (y < (RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE - 3))) + if ((y > 0) && (y < (RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE - 1))) { if (((result[y + 1] != 0) && (result[y + 2] != 0)) || (result[y - 1] != 0)) { filtered_result[y] = 1; + // Fill empty pixel + result[y + 1] = 1; } else { @@ -1108,6 +1110,7 @@ void loop(void) #endif if (max_rssi_x > y) { + // MAx bin Value not RSSI max_rssi_x = y; } // Set signal level pixel From 6203bdc33f12a3b469b5107c9a0a788555286ef0 Mon Sep 17 00:00:00 2001 From: Egor Shitikov Date: Sat, 14 Sep 2024 19:30:51 -0700 Subject: [PATCH 3/3] add comment --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 88f76bc..45c1419 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -960,7 +960,8 @@ void loop(void) // avoid buffer overflow if (result_index < RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE) { - // Saving max value only rss is negative so smaller is bigger + // Saving max ABS value of rssi. dB is negative so smaller is + // bigger if (result[result_index] == 0 || result[result_index] > abs(rssi)) { result[result_index] = abs(rssi);