Merge pull request #834 from gullradriel/recon-update

Recon minor update, RSSI widget get 'on touch'
This commit is contained in:
gullradriel
2023-03-14 00:28:22 +01:00
committed by GitHub
3 changed files with 32 additions and 15 deletions

View File

@@ -266,7 +266,7 @@ namespace ui {
}; };
RSSI rssi { RSSI rssi {
{ 0 * 16, 2 * 16, 15 * 16, 8 }, { 0 * 16, 2 * 16, 240 - 4 * 8 , 16 },
}; };
Text text_cycle { Text text_cycle {
@@ -299,12 +299,12 @@ namespace ui {
}; };
Button button_recon_setup { Button button_recon_setup {
{ 240 - 4 * 8 , 2 * 16 + 8 , 4 * 8, 28 }, { 240 - 4 * 8 , 2 * 16 , 4 * 8, 28 },
"OPT" "OPT"
}; };
Button button_looking_glass { Button button_looking_glass {
{ 240 - 5 * 8 , 6 * 16 , 5 * 8, 28 }, { 240 - 5 * 8 , 6 * 16 - 4 , 5 * 8, 28 },
"GLASS" "GLASS"
}; };
@@ -314,7 +314,7 @@ namespace ui {
}; };
Text file_name { //Show file used Text file_name { //Show file used
{ 0 , 8 * 16 + 4 , 21 * 8, 16 }, { 0 , 8 * 16 + 6 , 21 * 8, 16 },
}; };
ButtonWithEncoder button_manual_start { ButtonWithEncoder button_manual_start {

View File

@@ -32,6 +32,14 @@
namespace ui { namespace ui {
RSSI::RSSI(
Rect parent_rect,
bool instant_exec
) : Widget { parent_rect },
instant_exec_ { instant_exec }
{
}
void RSSI::paint(Painter& painter) { void RSSI::paint(Painter& painter) {
const auto r = screen_rect(); const auto r = screen_rect();
@@ -352,6 +360,9 @@ namespace ui {
if( on_touch_press) { if( on_touch_press) {
on_touch_press(*this); on_touch_press(*this);
} }
if( on_select && instant_exec_ ) {
on_select(*this);
}
return true; return true;
case TouchEvent::Type::End: case TouchEvent::Type::End:
set_highlighted(false); set_highlighted(false);
@@ -359,6 +370,9 @@ namespace ui {
if( on_touch_release) { if( on_touch_release) {
on_touch_release(*this); on_touch_release(*this);
} }
if( on_select && !instant_exec_ ) {
on_select(*this);
}
return true; return true;
default: default:
return false; return false;

View File

@@ -39,12 +39,15 @@ namespace ui {
std::function<bool(RSSI&, KeyEvent)> on_dir { }; std::function<bool(RSSI&, KeyEvent)> on_dir { };
std::function<void(RSSI&)> on_highlight { }; std::function<void(RSSI&)> on_highlight { };
RSSI(Rect parent_rect, bool instant_exec); // instant_exec: Execute on_select when you touching instead of releasing
RSSI( RSSI(
const Rect parent_rect Rect parent_rect
) : Widget { parent_rect }, ) : RSSI { parent_rect, false }
min_ { 0 }, {
avg_ { 0 }, }
max_ { 0 }
RSSI(
) : RSSI { { }, { } }
{ {
} }
@@ -61,9 +64,9 @@ namespace ui {
bool on_touch(const TouchEvent event) override; bool on_touch(const TouchEvent event) override;
private: private:
int32_t min_; int32_t min_ = 0;
int32_t avg_; int32_t avg_ = 0;
int32_t max_; int32_t max_ = 0;
int32_t peak_ = 0 ; int32_t peak_ = 0 ;
size_t peak_duration_ = 0 ; size_t peak_duration_ = 0 ;
bool instant_exec_ { false }; bool instant_exec_ { false };