From 221c31dce21f34eaebac4235fab2d6af03519e80 Mon Sep 17 00:00:00 2001 From: Egor Shitikov Date: Tue, 23 Jul 2024 16:51:07 -0700 Subject: [PATCH] Animated Reload --- src/main.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3867690..ba21d84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,11 +49,13 @@ unsigned int median_freqancy = FREQ_BEGIN + range_freqancy / 2; // Prints the scan measurement bins from the SX1262 in hex #define PRINT_SCAN_VALUES #define PRINT_PROFILE_TIME +//Change spectrum plot values at once or by line +#define ANIMATED_RELOAD true // numbers of the spectrum screan lines = width of screan #define STEPS 128 -// Number of samples for each scan. Fewer samples = better temporal resolution. -#define SAMPLES 256 //(scan time = 1294) +// Number of samples for each freqancy scan. Fewer samples = better temporal resolution. +#define SAMPLES 35 //(scan time = 1294) #define MAJOR_TICK_LENGTH 3 #define MINOR_TICK_LENGTH 1 #define X_AXIS_WEIGHT 2 @@ -71,6 +73,7 @@ unsigned short int scan_var = 0; // initialized flag bool initialized = false; bool led_flag = true; +bool first_run = false; // drone tetection flag unsigned short int drone_detected = 0; @@ -82,6 +85,8 @@ uint64_t start = 0; unsigned int x,y = 0; +float freq = 0; + /** * @brief Draws ticks on the display at regular whole intervals. @@ -201,14 +206,22 @@ void loop() { #ifdef PRINT_PROFILE_TIME start = millis(); #endif + + if (!ANIMATED_RELOAD) { // clear the scan plot rectangle - display.setColor(BLACK); - display.fillRect(0, 0, STEPS, HEIGHT); - display.setColor(WHITE); + display.setColor(BLACK); + display.fillRect(0, 0, STEPS, HEIGHT); + display.setColor(WHITE); + } // do the scan for (x = 0; x < STEPS; x++) { - float freq = FREQ_BEGIN + (RANGE * ((float) x / STEPS)); + if (ANIMATED_RELOAD) { + display.setColor(BLACK); + display.drawVerticalLine(x, 0, HEIGHT); + display.setColor(WHITE); + } + freq = FREQ_BEGIN + (RANGE * ((float) x / STEPS)); radio.setFrequency(freq); #ifdef PRINT_SCAN_VALUES Serial.println(); @@ -237,6 +250,9 @@ void loop() { #ifdef PRINT_SCAN_VALUES Serial.println(); #endif + if (first_run || ANIMATED_RELOAD){ + display.display(); + } // wait a little bit before the next scan, otherwise the SX1262 hangs heltec_delay(1); }