Merge pull request #849 from gullradriel/level-rssi-minor-fix

Level rssi minor fix
This commit is contained in:
gullradriel 2023-03-23 13:35:04 +01:00 committed by GitHub
commit bb3ba29d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 253 additions and 168 deletions

View File

@ -180,7 +180,7 @@ namespace ui {
};
// default peak value
peak_mode.set_selected_index(3);
peak_mode.set_selected_index(2);
rssi_resolution.set_selected_index(1);
//FILL STEP OPTIONS
freqman_set_modulation_option( field_mode );

View File

@ -147,15 +147,6 @@ namespace ui {
}
};
RSSIGraph rssi_graph { // 240x320 =>
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 216 },
};
RSSI rssi { // 240x320 =>
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 216 },
};
ButtonWithEncoder button_frequency {
{ 0 * 8 , 2 * 16 + 8 , 15 * 8 , 1 * 8 },
""
@ -172,7 +163,6 @@ namespace ui {
}
};
Text text_ctcss {
{ 22 * 8, 3 * 16 + 4 , 14 * 8, 1 * 8 },
""
@ -180,14 +170,14 @@ namespace ui {
// RSSI: XX/XX/XXX,dt: XX
Text freq_stats_rssi {
{ 0 * 8 , 3 * 16 + 4 , 22 * 8, 16 },
{ 0 * 8 , 3 * 16 + 4 , 22 * 8, 14 },
};
// Power: -XXX db
Text freq_stats_db {
{ 0 * 8 , 4 * 16 + 4 , 15 * 8, 16 },
{ 0 * 8 , 4 * 16 + 4 , 14 * 8, 14 },
};
OptionsField peak_mode {
{ 40 + 10 * 8, 4 * 16 + 4 },
10,
@ -213,6 +203,13 @@ namespace ui {
}
};
RSSIGraph rssi_graph { // 240x320 =>
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 320 - ( 5 * 16 + 4 ) },
};
RSSI rssi { // 240x320 =>
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 320 - ( 5 * 16 + 4 ) },
};
void handle_coded_squelch(const uint32_t value);
void on_headphone_volume_changed(int32_t v);

View File

@ -890,7 +890,7 @@ namespace ui {
rssi.set_focusable(true);
rssi.set_peak( true , 1000 );
rssi.set_peak( true , 500 );
rssi.on_select = [this](RSSI&) {
recon_thread->stop();
nav_.pop();

View File

@ -238,9 +238,97 @@ namespace ui {
set_dirty();
}
void RSSIGraph::paint(Painter& painter) {
const auto r = screen_rect();
RSSIGraph_entry& prev_entry = graph_list[0];
int xpos = 0 , prev_xpos = r.width();
for( int n = 1 ; (unsigned)n <= graph_list.size() ; n++ )
{
xpos = ( r.width() * (graph_list.size() - n ) ) / graph_list.size() ;
int size = abs( xpos - prev_xpos );
RSSIGraph_entry& entry = graph_list[ n - 1 ];
// black
const Rect r0{ r.right() - prev_xpos , r.top() , size , r.height() };
painter.fill_rectangle(
r0,
Color::black());
// y_max
int top_y_val = max( entry.rssi_max , prev_entry.rssi_max );
int width_y = abs( entry.rssi_max - prev_entry.rssi_max );
if( width_y == 0 )
width_y = 1 ;
const Point p1v{ r.right() - prev_xpos , r.bottom() - top_y_val };
painter.draw_vline(
p1v,
width_y,
Color::red());
const Point p1h{ r.right() - prev_xpos , r.bottom() - entry.rssi_max };
painter.draw_hline(
p1h,
size,
Color::red());
// y_avg
top_y_val = max( entry.rssi_avg , prev_entry.rssi_avg );
width_y = abs( entry.rssi_avg - prev_entry.rssi_avg );
if( width_y == 0 )
width_y = 1 ;
const Point p2v{ r.right() - prev_xpos , r.bottom() - top_y_val };
painter.draw_vline(
p2v,
width_y,
Color::white());
const Point p2h{ r.right() - prev_xpos , r.bottom() - entry.rssi_avg };
painter.draw_hline(
p2h,
size,
Color::white());
// y_min
top_y_val = max( entry.rssi_min , prev_entry.rssi_min );
width_y = abs( entry.rssi_min - prev_entry.rssi_min );
if( width_y == 0 )
width_y = 1 ;
const Point p3v{ r.right() - prev_xpos , r.bottom() - top_y_val };
painter.draw_vline(
p3v,
width_y,
Color::blue());
const Point p3h{ r.right() - prev_xpos , r.bottom() - entry.rssi_min };
painter.draw_hline(
p3h,
size,
Color::blue());
// hack to display db
top_y_val = max( entry.db , prev_entry.db );
width_y = abs( entry.db - prev_entry.db );
if( width_y == 0 )
width_y = 1 ;
const Point p4v{ r.right() - prev_xpos , r.bottom() - top_y_val };
painter.draw_vline(
p4v,
width_y,
Color::green());
const Point p4h{ r.right() - prev_xpos , r.bottom() - entry.db };
painter.draw_hline(
p4h,
size,
Color::green());
prev_entry = entry ;
prev_xpos = xpos ;
}
}
/*void RSSIGraph::paintOld(Painter& painter) {
const auto r = screen_rect();
int16_t size = r.width() / nb_columns ;
int16_t top_y_val = 0 ;
int16_t width_y = 0 ;
@ -307,7 +395,7 @@ namespace ui {
r5,
Color::black());
}
}
}*/
void RSSIGraph::add_values(int16_t rssi_min, int16_t rssi_avg, int16_t rssi_max, int16_t db )
{