mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-03 10:00:12 -05:00
Merge pull request #849 from gullradriel/level-rssi-minor-fix
Level rssi minor fix
This commit is contained in:
commit
bb3ba29d22
@ -180,7 +180,7 @@ namespace ui {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// default peak value
|
// default peak value
|
||||||
peak_mode.set_selected_index(3);
|
peak_mode.set_selected_index(2);
|
||||||
rssi_resolution.set_selected_index(1);
|
rssi_resolution.set_selected_index(1);
|
||||||
//FILL STEP OPTIONS
|
//FILL STEP OPTIONS
|
||||||
freqman_set_modulation_option( field_mode );
|
freqman_set_modulation_option( field_mode );
|
||||||
|
@ -41,200 +41,197 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
class LevelView : public View {
|
class LevelView : public View {
|
||||||
public:
|
public:
|
||||||
LevelView(NavigationView& nav);
|
LevelView(NavigationView& nav);
|
||||||
~LevelView();
|
~LevelView();
|
||||||
|
|
||||||
void focus() override;
|
void focus() override;
|
||||||
|
|
||||||
void big_display_freq( int64_t f );
|
void big_display_freq( int64_t f );
|
||||||
|
|
||||||
const Style style_grey { // level
|
const Style style_grey { // level
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::grey(),
|
.foreground = Color::grey(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Style style_white { // level
|
const Style style_white { // level
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::white(),
|
.foreground = Color::white(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Style style_yellow { //Found signal
|
const Style style_yellow { //Found signal
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::yellow(),
|
.foreground = Color::yellow(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Style style_green { //Found signal
|
const Style style_green { //Found signal
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::green(),
|
.foreground = Color::green(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Style style_red { //erasing freq
|
const Style style_red { //erasing freq
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::red(),
|
.foreground = Color::red(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Style style_blue { // quick level, wait == 0
|
const Style style_blue { // quick level, wait == 0
|
||||||
.font = font::fixed_8x16,
|
.font = font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::blue(),
|
.foreground = Color::blue(),
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string title() const override { return "Level"; };
|
std::string title() const override { return "Level"; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
size_t change_mode( freqman_index_t mod_type);
|
size_t change_mode( freqman_index_t mod_type);
|
||||||
void on_statistics_update(const ChannelStatistics& statistics);
|
void on_statistics_update(const ChannelStatistics& statistics);
|
||||||
void set_display_freq( int64_t freq );
|
void set_display_freq( int64_t freq );
|
||||||
bool check_sd_card();
|
bool check_sd_card();
|
||||||
|
|
||||||
int32_t db { 0 };
|
int32_t db { 0 };
|
||||||
long long int MAX_UFREQ = { 7200000000 }; // maximum usable freq
|
long long int MAX_UFREQ = { 7200000000 }; // maximum usable freq
|
||||||
bool sd_card_mounted = false ;
|
bool sd_card_mounted = false ;
|
||||||
rf::Frequency freq = { 0 } ;
|
rf::Frequency freq = { 0 } ;
|
||||||
|
|
||||||
Labels labels
|
Labels labels
|
||||||
{
|
{
|
||||||
{ { 0 * 8 , 0 * 16 }, "LNA: VGA: AMP: VOL: ", Color::light_grey() },
|
{ { 0 * 8 , 0 * 16 }, "LNA: VGA: AMP: VOL: ", Color::light_grey() },
|
||||||
{ { 0 * 8 , 1 * 16 }, "BW: MODE: S: ", Color::light_grey() },
|
{ { 0 * 8 , 1 * 16 }, "BW: MODE: S: ", Color::light_grey() },
|
||||||
};
|
};
|
||||||
|
|
||||||
LNAGainField field_lna {
|
LNAGainField field_lna {
|
||||||
{ 4 * 8, 0 * 16 }
|
{ 4 * 8, 0 * 16 }
|
||||||
};
|
};
|
||||||
|
|
||||||
VGAGainField field_vga {
|
VGAGainField field_vga {
|
||||||
{ 11 * 8, 0 * 16 }
|
{ 11 * 8, 0 * 16 }
|
||||||
};
|
};
|
||||||
|
|
||||||
RFAmpField field_rf_amp {
|
RFAmpField field_rf_amp {
|
||||||
{ 18 * 8, 0 * 16 }
|
{ 18 * 8, 0 * 16 }
|
||||||
};
|
};
|
||||||
|
|
||||||
NumberField field_volume {
|
NumberField field_volume {
|
||||||
{ 24 * 8, 0 * 16 },
|
{ 24 * 8, 0 * 16 },
|
||||||
2,
|
2,
|
||||||
{ 0, 99 },
|
{ 0, 99 },
|
||||||
1,
|
1,
|
||||||
' ',
|
' ',
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField field_bw {
|
OptionsField field_bw {
|
||||||
{ 3 * 8, 1 * 16 },
|
{ 3 * 8, 1 * 16 },
|
||||||
6,
|
6,
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField field_mode {
|
OptionsField field_mode {
|
||||||
{ 15 * 8, 1 * 16 },
|
{ 15 * 8, 1 * 16 },
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField step_mode {
|
OptionsField step_mode {
|
||||||
{ 16 * 8, 2 * 16 + 4 },
|
{ 16 * 8, 2 * 16 + 4 },
|
||||||
12,
|
12,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RSSIGraph rssi_graph { // 240x320 =>
|
ButtonWithEncoder button_frequency {
|
||||||
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 216 },
|
{ 0 * 8 , 2 * 16 + 8 , 15 * 8 , 1 * 8 },
|
||||||
};
|
""
|
||||||
|
};
|
||||||
|
|
||||||
RSSI rssi { // 240x320 =>
|
OptionsField audio_mode {
|
||||||
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 216 },
|
{ 21 * 8, 1 * 16 },
|
||||||
};
|
9,
|
||||||
|
{
|
||||||
|
{"audio off", 0},
|
||||||
|
{"audio on",1}
|
||||||
|
//{"tone on", 2},
|
||||||
|
//{"tone off", 2},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Text text_ctcss {
|
||||||
|
{ 22 * 8, 3 * 16 + 4 , 14 * 8, 1 * 8 },
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
ButtonWithEncoder button_frequency {
|
// RSSI: XX/XX/XXX,dt: XX
|
||||||
{ 0 * 8 , 2 * 16 + 8 , 15 * 8 , 1 * 8 },
|
Text freq_stats_rssi {
|
||||||
""
|
{ 0 * 8 , 3 * 16 + 4 , 22 * 8, 14 },
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField audio_mode {
|
// Power: -XXX db
|
||||||
{ 21 * 8, 1 * 16 },
|
Text freq_stats_db {
|
||||||
9,
|
{ 0 * 8 , 4 * 16 + 4 , 14 * 8, 14 },
|
||||||
{
|
};
|
||||||
{"audio off", 0},
|
|
||||||
{"audio on",1}
|
|
||||||
//{"tone on", 2},
|
|
||||||
//{"tone off", 2},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
OptionsField peak_mode {
|
||||||
|
{ 40 + 10 * 8, 4 * 16 + 4 },
|
||||||
|
10,
|
||||||
|
{
|
||||||
|
{"peak:none", 0},
|
||||||
|
{"peak:0.25s",250},
|
||||||
|
{"peak:0.5s",500},
|
||||||
|
{"peak:1s",1000},
|
||||||
|
{"peak:3s",3000},
|
||||||
|
{"peak:5s",5000},
|
||||||
|
{"peak:10s",10000},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OptionsField rssi_resolution {
|
||||||
|
{ 44 + 20 * 8, 4 * 16 + 4},
|
||||||
|
4,
|
||||||
|
{
|
||||||
|
{"16x", 16},
|
||||||
|
{"32x", 32},
|
||||||
|
{"64x", 64},
|
||||||
|
{"128x", 128},
|
||||||
|
{"240x", 240},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Text text_ctcss {
|
RSSIGraph rssi_graph { // 240x320 =>
|
||||||
{ 22 * 8, 3 * 16 + 4 , 14 * 8, 1 * 8 },
|
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 320 - ( 5 * 16 + 4 ) },
|
||||||
""
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// RSSI: XX/XX/XXX,dt: XX
|
RSSI rssi { // 240x320 =>
|
||||||
Text freq_stats_rssi {
|
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 320 - ( 5 * 16 + 4 ) },
|
||||||
{ 0 * 8 , 3 * 16 + 4 , 22 * 8, 16 },
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Text freq_stats_db {
|
void handle_coded_squelch(const uint32_t value);
|
||||||
{ 0 * 8 , 4 * 16 + 4 , 15 * 8, 16 },
|
void on_headphone_volume_changed(int32_t v);
|
||||||
};
|
|
||||||
|
|
||||||
|
MessageHandlerRegistration message_handler_coded_squelch {
|
||||||
|
Message::ID::CodedSquelch,
|
||||||
|
[this](const Message* const p) {
|
||||||
|
const auto message = *reinterpret_cast<const CodedSquelchMessage*>(p);
|
||||||
|
this->handle_coded_squelch(message.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
OptionsField peak_mode {
|
MessageHandlerRegistration message_handler_stats {
|
||||||
{ 40 + 10 * 8, 4 * 16 + 4 },
|
Message::ID::ChannelStatistics,
|
||||||
10,
|
[this](const Message* const p) {
|
||||||
{
|
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
||||||
{"peak:none", 0},
|
}
|
||||||
{"peak:0.25s",250},
|
};
|
||||||
{"peak:0.5s",500},
|
// app save settings
|
||||||
{"peak:1s",1000},
|
std::app_settings settings { };
|
||||||
{"peak:3s",3000},
|
std::app_settings::AppSettings app_settings { };
|
||||||
{"peak:5s",5000},
|
};
|
||||||
{"peak:10s",10000},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
OptionsField rssi_resolution {
|
|
||||||
{ 44 + 20 * 8, 4 * 16 + 4},
|
|
||||||
4,
|
|
||||||
{
|
|
||||||
{"16x", 16},
|
|
||||||
{"32x", 32},
|
|
||||||
{"64x", 64},
|
|
||||||
{"128x", 128},
|
|
||||||
{"240x", 240},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void handle_coded_squelch(const uint32_t value);
|
|
||||||
void on_headphone_volume_changed(int32_t v);
|
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_coded_squelch {
|
|
||||||
Message::ID::CodedSquelch,
|
|
||||||
[this](const Message* const p) {
|
|
||||||
const auto message = *reinterpret_cast<const CodedSquelchMessage*>(p);
|
|
||||||
this->handle_coded_squelch(message.value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_stats {
|
|
||||||
Message::ID::ChannelStatistics,
|
|
||||||
[this](const Message* const p) {
|
|
||||||
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// app save settings
|
|
||||||
std::app_settings settings { };
|
|
||||||
std::app_settings::AppSettings app_settings { };
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ namespace ui {
|
|||||||
|
|
||||||
|
|
||||||
rssi.set_focusable(true);
|
rssi.set_focusable(true);
|
||||||
rssi.set_peak( true , 1000 );
|
rssi.set_peak( true , 500 );
|
||||||
rssi.on_select = [this](RSSI&) {
|
rssi.on_select = [this](RSSI&) {
|
||||||
recon_thread->stop();
|
recon_thread->stop();
|
||||||
nav_.pop();
|
nav_.pop();
|
||||||
|
@ -238,8 +238,96 @@ namespace ui {
|
|||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSSIGraph::paint(Painter& painter) {
|
||||||
|
const auto r = screen_rect();
|
||||||
|
|
||||||
void RSSIGraph::paint(Painter& painter) {
|
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();
|
const auto r = screen_rect();
|
||||||
int16_t size = r.width() / nb_columns ;
|
int16_t size = r.width() / nb_columns ;
|
||||||
int16_t top_y_val = 0 ;
|
int16_t top_y_val = 0 ;
|
||||||
@ -307,7 +395,7 @@ namespace ui {
|
|||||||
r5,
|
r5,
|
||||||
Color::black());
|
Color::black());
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void RSSIGraph::add_values(int16_t rssi_min, int16_t rssi_avg, int16_t rssi_max, int16_t db )
|
void RSSIGraph::add_values(int16_t rssi_min, int16_t rssi_avg, int16_t rssi_max, int16_t db )
|
||||||
{
|
{
|
||||||
@ -340,7 +428,7 @@ namespace ui {
|
|||||||
{
|
{
|
||||||
graph_list.erase( graph_list.begin() );
|
graph_list.erase( graph_list.begin() );
|
||||||
}
|
}
|
||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSIGraph::set_nb_columns( int16_t nb )
|
void RSSIGraph::set_nb_columns( int16_t nb )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user