Peak view entry menu and functionnalities

This commit is contained in:
GullCode 2023-04-09 14:45:07 +02:00
parent ba3114c0b6
commit cec0fe3288
2 changed files with 85 additions and 26 deletions

View File

@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2020 euquiq * Copyright (C) 2020 euquiq
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -57,7 +58,7 @@ namespace ui
if (pixel_index == 240) // got an entire waterfall line if (pixel_index == 240) // got an entire waterfall line
{ {
if( live_frequency_view ) if( live_frequency_view > 0 )
{ {
constexpr int rssi_sample_range = 256; constexpr int rssi_sample_range = 256;
//constexpr float rssi_voltage_min = 0.4; //constexpr float rssi_voltage_min = 0.4;
@ -69,13 +70,22 @@ namespace ui
constexpr int raw_delta = raw_max - raw_min; constexpr int raw_delta = raw_max - raw_min;
const range_t<int> y_max_range { 0 , 320 - 108 }; const range_t<int> y_max_range { 0 , 320 - 108 };
//drawing //drawing and keeping track of max freq
//display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
for( uint16_t xpos = 0 ; xpos < 240 ; xpos ++ ) for( uint16_t xpos = 0 ; xpos < 240 ; xpos ++ )
{ {
// save max powerwull freq
if( spectrum_data[ xpos ] > max_freq_power )
{
max_freq_power = spectrum_data[ xpos ];
max_freq_hold = ( f_center - LOOKING_GLASS_SLICE_WIDTH/2 ) + xpos * bins_Hz_size ;
}
int16_t point = y_max_range.clip( ( ( spectrum_data[ xpos ] - raw_min ) * ( 320 - 108 ) ) / raw_delta ); int16_t point = y_max_range.clip( ( ( spectrum_data[ xpos ] - raw_min ) * ( 320 - 108 ) ) / raw_delta );
uint8_t color_gradient = (point * 255) / 212 ; uint8_t color_gradient = (point * 255) / 212 ;
// clear if not in peak view
if( live_frequency_view != 2 )
{
display.fill_rectangle( { { xpos , 108 } , { 1 , 320 - point } } , { 0 , 0 , 0 } ); display.fill_rectangle( { { xpos , 108 } , { 1 , 320 - point } } , { 0 , 0 , 0 } );
}
display.fill_rectangle( { { xpos , 320 - point } , { 1 , point } } , { color_gradient , 0 , uint8_t( 255 - color_gradient ) } ); display.fill_rectangle( { { xpos , 320 - point } , { 1 , point } } , { color_gradient , 0 , uint8_t( 255 - color_gradient ) } );
} }
} }
@ -155,6 +165,11 @@ namespace ui
void GlassView::on_range_changed() void GlassView::on_range_changed()
{ {
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
f_min = field_frequency_min.value(); f_min = field_frequency_min.value();
f_max = field_frequency_max.value(); f_max = field_frequency_max.value();
search_span = f_max - f_min; search_span = f_max - f_min;
@ -228,6 +243,11 @@ namespace ui
field_frequency_min.set_step( steps ); field_frequency_min.set_step( steps );
field_frequency_min.on_change = [this](int32_t v) field_frequency_min.on_change = [this](int32_t v)
{ {
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
int32_t steps_ = steps ; int32_t steps_ = steps ;
if( steps_ < 24 ) if( steps_ < 24 )
steps_ = 24 ; steps_ = 24 ;
@ -261,6 +281,11 @@ namespace ui
field_frequency_max.set_step( steps ); field_frequency_max.set_step( steps );
field_frequency_max.on_change = [this](int32_t v) field_frequency_max.on_change = [this](int32_t v)
{ {
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
int32_t steps_ = steps ; int32_t steps_ = steps ;
if( steps_ < 24 ) if( steps_ < 24 )
steps_ = 24 ; steps_ = 24 ;
@ -293,12 +318,22 @@ namespace ui
field_lna.set_value(receiver_model.lna()); field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v) field_lna.on_change = [this](int32_t v)
{ {
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
this->on_lna_changed(v); this->on_lna_changed(v);
}; };
field_vga.set_value(receiver_model.vga()); field_vga.set_value(receiver_model.vga());
field_vga.on_change = [this](int32_t v_db) field_vga.on_change = [this](int32_t v_db)
{ {
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
this->on_vga_changed(v_db); this->on_vga_changed(v_db);
}; };
@ -314,18 +349,26 @@ namespace ui
view_config.on_change = [this](size_t n, OptionsField::value_t v) view_config.on_change = [this](size_t n, OptionsField::value_t v)
{ {
(void)n; (void)n;
live_frequency_view = v ; max_freq_hold = 0 ;
if( v ) if( v == 0 )
{
display.scroll_disable();
level_integration.hidden( false );
}
else
{ {
live_frequency_view = 0 ;
level_integration.hidden( true ); level_integration.hidden( true );
set_dirty(); set_dirty();
display.scroll_set_area(109, 319); // Restart scroll on the correct coordinates display.scroll_set_area(109, 319); // Restart scroll on the correct coordinates
} }
else if( v == 1 )
{
live_frequency_view = 1 ;
display.scroll_disable();
level_integration.hidden( false );
}
else if( v == 2 )
{
live_frequency_view = 2 ;
display.scroll_disable();
level_integration.hidden( false );
}
// clear between changes // clear between changes
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } ); display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}; };
@ -334,6 +377,11 @@ namespace ui
level_integration.on_change = [this](size_t n, OptionsField::value_t v) level_integration.on_change = [this](size_t n, OptionsField::value_t v)
{ {
(void)n; (void)n;
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
live_frequency_integrate = v ; live_frequency_integrate = v ;
}; };
level_integration.set_selected_index(2); //default integration of ( 3 * old value + new_value ) / 4 level_integration.set_selected_index(2); //default integration of ( 3 * old value + new_value ) / 4
@ -341,6 +389,11 @@ namespace ui
filter_config.set_selected_index(0); filter_config.set_selected_index(0);
filter_config.on_change = [this](size_t n, OptionsField::value_t v) { filter_config.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n; (void)n;
max_freq_hold = 0 ;
if( live_frequency_view == 2 )
{
display.fill_rectangle( { { 0 , 108 } , { 240 , 320 - 108 } } , { 0 , 0 , 0 } );
}
min_color_power = v; min_color_power = v;
}; };

View File

@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2020 euquiq * Copyright (C) 2020 euquiq
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -36,7 +37,9 @@
namespace ui namespace ui
{ {
#define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz #define LOOKING_GLASS_SLICE_WIDTH 19999920 // Each slice bandwidth 20 MHz and a multiple of 240
// since we are using LOOKING_GLASS_SLICE_WIDTH/240 as the each_bin_size
// it should also be a multiple of 2 since we are using LOOKING_GLASS_SLICE_WIDTH / 2 as centering freq
#define MHZ_DIV 1000000 #define MHZ_DIV 1000000
#define X2_MHZ_DIV 2000000 #define X2_MHZ_DIV 2000000
@ -93,8 +96,10 @@ namespace ui
ChannelSpectrumFIFO* fifo { nullptr }; ChannelSpectrumFIFO* fifo { nullptr };
uint8_t max_power = 0; uint8_t max_power = 0;
int32_t steps = 250 ; // default of 250 Mhz steps int32_t steps = 250 ; // default of 250 Mhz steps
bool live_frequency_view = false ; uint8_t live_frequency_view = 0 ;
int16_t live_frequency_integrate = 3 ; int16_t live_frequency_integrate = 3 ;
uint64_t max_freq_hold = 0 ;
int16_t max_freq_power = -1000 ;
Labels labels{ Labels labels{
{{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()}, {{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
@ -147,8 +152,9 @@ namespace ui
{ 19 * 8, 4 * 16}, { 19 * 8, 4 * 16},
7, 7,
{ {
{"SPCTR-V", false }, {"SPCTR-V", 0 },
{"LEVEL-V", true }, {"LEVEL-V", 1 },
{"PEAK-V" , 2 },
}}; }};
OptionsField level_integration{ OptionsField level_integration{