From c3971cae322fa6c2d04401075c77f4983625b3c3 Mon Sep 17 00:00:00 2001 From: GullCode Date: Fri, 7 Apr 2023 01:57:42 +0200 Subject: [PATCH] Added live frequency view mode --- .../application/apps/ui_looking_glass_app.cpp | 35 ++++++++++++++++--- .../application/apps/ui_looking_glass_app.hpp | 4 ++- hackrf | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index ed5a20cf..18e8cab6 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -49,12 +49,39 @@ namespace ui receiver_model.set_vga(v_db); } - void GlassView::add_spectrum_pixel(Color color) + void GlassView::add_spectrum_pixel(int16_t color) { - spectrum_row[pixel_index++] = color; + spectrum_row[pixel_index] = spectrum_rgb3_lut[color] ; + spectrum_data[pixel_index] = ( 3 * spectrum_data[pixel_index] + color ) / 4 ; + pixel_index ++ ; + if (pixel_index == 240) // got an entire waterfall line { - display.draw_pixels({{0, display.scroll(1)}, {240, 1}}, spectrum_row); // new line at top, one less var, speedier + if( live_frequency_view ) + { + constexpr int rssi_sample_range = 256; + constexpr float rssi_voltage_min = 0.4; + constexpr float rssi_voltage_max = 2.2; + constexpr float adc_voltage_max = 3.3; + constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max; + //constexpr int raw_min = 0 ; + constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max; + constexpr int raw_delta = raw_max - raw_min; + const range_t y_max_range { 0 , 320 - 108 }; + + //drawing + //display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } ); + for( uint16_t xpos = 0 ; xpos < 240 ; xpos ++ ) + { + int16_t point = y_max_range.clip( ( ( spectrum_data[ xpos ] - raw_min ) * ( 320 - 108 ) ) / raw_delta ); + display.fill_rectangle( { { xpos , 108 } , { 1 , 320 - point } } , { 0 , 0 , 0 } ); + display.fill_rectangle( { { xpos , 320 - point } , { 1 , point } } , { 0 , 0 , 255 } ); + } + } + else + { + display.draw_pixels({{0, display.scroll(1)}, {240, 1}}, spectrum_row); // new line at top, one less var, speedier + } pixel_index = 0; // Start New cascade line } } @@ -86,7 +113,7 @@ namespace ui if (bins_Hz_size >= marker_pixel_step) // new pixel fullfilled { if (min_color_power < max_power) - add_spectrum_pixel(spectrum_rgb3_lut[max_power]); // Pixel will represent max_power + add_spectrum_pixel(max_power); // Pixel will represent max_power else add_spectrum_pixel(0); // Filtered out, show black diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index 7d292b02..02c8b087 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -72,7 +72,7 @@ namespace ui void on_range_changed(); void on_lna_changed(int32_t v_db); void on_vga_changed(int32_t v_db); - void add_spectrum_pixel(Color color); + void add_spectrum_pixel(int16_t color); void PlotMarker(rf::Frequency pos); void load_Presets(); void txtline_process(std::string& line); @@ -89,9 +89,11 @@ namespace ui uint8_t min_color_power { 0 }; uint32_t pixel_index { 0 }; std::array spectrum_row = { 0 }; + std::array spectrum_data = { 0 }; ChannelSpectrumFIFO* fifo { nullptr }; uint8_t max_power = 0; int32_t steps = 250 ; // default of 250 Mhz steps + bool live_frequency_view = true ; Labels labels{ {{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()}, diff --git a/hackrf b/hackrf index ae71cb5b..ebe1ca00 160000 --- a/hackrf +++ b/hackrf @@ -1 +1 @@ -Subproject commit ae71cb5b7ae29eb9bddf359896a66aaa88b9dfac +Subproject commit ebe1ca003a4a04ead06407a4bca6a4f7e6b6c1f3