From c3971cae322fa6c2d04401075c77f4983625b3c3 Mon Sep 17 00:00:00 2001 From: GullCode Date: Fri, 7 Apr 2023 01:57:42 +0200 Subject: [PATCH 1/2] 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 From 12cfbf70f09775c69b7b39257bfba59abc54d6ff Mon Sep 17 00:00:00 2001 From: GullCode Date: Fri, 7 Apr 2023 11:30:28 +0200 Subject: [PATCH 2/2] added option button for view_config, default to SPCTR (spectrum), clear screen between changes, color gradient --- .../application/apps/ui_looking_glass_app.cpp | 30 +++++++++++++++---- .../application/apps/ui_looking_glass_app.hpp | 15 +++++++--- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index 18e8cab6..aa5f2acb 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -52,7 +52,7 @@ namespace ui void GlassView::add_spectrum_pixel(int16_t color) { spectrum_row[pixel_index] = spectrum_rgb3_lut[color] ; - spectrum_data[pixel_index] = ( 3 * spectrum_data[pixel_index] + color ) / 4 ; + spectrum_data[pixel_index] = ( 3 * spectrum_data[pixel_index] + color ) / 4 ; // smoothing pixel_index ++ ; if (pixel_index == 240) // got an entire waterfall line @@ -60,11 +60,11 @@ namespace ui if( live_frequency_view ) { constexpr int rssi_sample_range = 256; - constexpr float rssi_voltage_min = 0.4; + //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_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 }; @@ -74,8 +74,9 @@ namespace ui for( uint16_t xpos = 0 ; xpos < 240 ; xpos ++ ) { int16_t point = y_max_range.clip( ( ( spectrum_data[ xpos ] - raw_min ) * ( 320 - 108 ) ) / raw_delta ); + uint8_t color_gradient = (point * 255) / 212 ; display.fill_rectangle( { { xpos , 108 } , { 1 , 320 - point } } , { 0 , 0 , 0 } ); - display.fill_rectangle( { { xpos , 320 - point } , { 1 , point } } , { 0 , 0 , 255 } ); + display.fill_rectangle( { { xpos , 320 - point } , { 1 , point } } , { color_gradient , 0 , uint8_t( 255 - color_gradient ) } ); } } else @@ -212,6 +213,7 @@ namespace ui &field_vga, &text_range, &steps_config, + &view_config, &filter_config, &field_rf_amp, &range_presets, @@ -308,6 +310,24 @@ namespace ui steps = v ; }; + view_config.set_selected_index(0); //default spectrum + view_config.on_change = [this](size_t n, OptionsField::value_t v) + { + (void)n; + live_frequency_view = v ; + if( v ) + { + display.scroll_disable(); + } + else + { + display.scroll_set_area(109, 319); // Restart scroll on the correct coordinates + } + // clear between changes + display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } ); + }; + + range_presets.on_change = [this](size_t n, OptionsField::value_t v) { (void)n; diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index 02c8b087..48aca7ad 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -93,14 +93,14 @@ namespace ui ChannelSpectrumFIFO* fifo { nullptr }; uint8_t max_power = 0; int32_t steps = 250 ; // default of 250 Mhz steps - bool live_frequency_view = true ; + bool live_frequency_view = false ; Labels labels{ {{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()}, {{0, 1 * 16}, " RANGE: FILTER: AMP:", Color::light_grey()}, {{0, 2 * 16}, "PRESET:", Color::light_grey()}, {{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()}, - {{0, 4 * 16}, "RESOLUTION: STEPS:", Color::light_grey()} + {{0, 4 * 16}, "RESOLUTION: STEPS:", Color::light_grey()} }; NumberField field_frequency_min { @@ -132,7 +132,7 @@ namespace ui ""}; OptionsField steps_config{ - { 22 * 8, 4 * 16}, + { 21 * 8, 4 * 16}, 4, { {"1", 1}, @@ -140,7 +140,14 @@ namespace ui {"100", 100}, {"250", 250}, {"500", 500}, - {"1000", 1000}, + }}; + + OptionsField view_config{ + {25 * 8, 4 * 16}, + 5, + { + {"SPCTR", false }, + {"LVL-V", true }, }}; OptionsField filter_config{