diff --git a/firmware/application/apps/ui_dfu_menu.cpp b/firmware/application/apps/ui_dfu_menu.cpp index 3db7841b..b21198e7 100644 --- a/firmware/application/apps/ui_dfu_menu.cpp +++ b/firmware/application/apps/ui_dfu_menu.cpp @@ -22,6 +22,7 @@ #include "ui_dfu_menu.hpp" #include "portapack_shared_memory.hpp" #include "performance_counter.hpp" +#include "portapack.hpp" namespace ui { @@ -80,4 +81,57 @@ void DfuMenu::paint(Painter& painter) { ui::Color::dark_cyan()); } +DfuMenu2::DfuMenu2(NavigationView& nav) + : nav_(nav) { + add_children({&text_head, + &labels, + &text_info_line_1, + &text_info_line_2, + &text_info_line_3, + &text_info_line_4, + &text_info_line_5, + &text_info_line_6, + &text_info_line_7, + &text_info_line_8}); +} + +void DfuMenu2::paint(Painter& painter) { + text_info_line_1.set(to_string_dec_uint(portapack::receiver_model.target_frequency(), 10)); + text_info_line_2.set(to_string_dec_uint(portapack::receiver_model.baseband_bandwidth(), 10)); + text_info_line_3.set(to_string_dec_uint(portapack::receiver_model.sampling_rate(), 10)); + text_info_line_4.set(to_string_dec_uint((uint32_t)portapack::receiver_model.modulation(), 10)); + text_info_line_5.set(to_string_dec_uint(portapack::receiver_model.am_configuration(), 10)); + text_info_line_6.set(to_string_dec_uint(portapack::receiver_model.nbfm_configuration(), 10)); + text_info_line_7.set(to_string_dec_uint(portapack::receiver_model.wfm_configuration(), 10)); + text_info_line_8.set(""); + + constexpr auto margin = 5; + constexpr auto lines = 8 + 2; + + painter.fill_rectangle( + {{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin}, + {19 * CHARACTER_WIDTH + margin * 2, lines * LINE_HEIGHT + margin * 2}}, + ui::Color::black()); + + painter.fill_rectangle( + {{4 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin}, + {CHARACTER_WIDTH, lines * LINE_HEIGHT + margin * 2}}, + ui::Color::dark_cyan()); + + painter.fill_rectangle( + {{24 * CHARACTER_WIDTH + margin, 3 * LINE_HEIGHT - margin}, + {CHARACTER_WIDTH, lines * LINE_HEIGHT + margin * 2}}, + ui::Color::dark_cyan()); + + painter.fill_rectangle( + {{4 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin - 8}, + {21 * CHARACTER_WIDTH + margin * 2, 8}}, + ui::Color::dark_cyan()); + + painter.fill_rectangle( + {{4 * CHARACTER_WIDTH - margin, (lines + 3) * LINE_HEIGHT + margin}, + {21 * CHARACTER_WIDTH + margin * 2, 8}}, + ui::Color::dark_cyan()); +} + } /* namespace ui */ diff --git a/firmware/application/apps/ui_dfu_menu.hpp b/firmware/application/apps/ui_dfu_menu.hpp index 01f8d7a4..9cba9e72 100644 --- a/firmware/application/apps/ui_dfu_menu.hpp +++ b/firmware/application/apps/ui_dfu_menu.hpp @@ -67,6 +67,38 @@ class DfuMenu : public View { Text text_info_line_8{{15 * CHARACTER_WIDTH, 12 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; }; +class DfuMenu2 : public View { + public: + DfuMenu2(NavigationView& nav); + ~DfuMenu2() = default; + + void paint(Painter& painter) override; + + private: + NavigationView& nav_; + + Text text_head{{6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT, 8 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, "Receiver"}; + + Labels labels{ + {{5 * CHARACTER_WIDTH, 5 * LINE_HEIGHT}, "Tgt freq:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 6 * LINE_HEIGHT}, "Bandwidt:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 7 * LINE_HEIGHT}, "Sampl Rt:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 8 * LINE_HEIGHT}, "Modulatn:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 9 * LINE_HEIGHT}, "AM cfg:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 10 * LINE_HEIGHT}, "NBFM cfg:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 11 * LINE_HEIGHT}, "WFM cfg:", Color::dark_cyan()}, + {{5 * CHARACTER_WIDTH, 12 * LINE_HEIGHT}, "", Color::dark_cyan()}}; + + Text text_info_line_1{{14 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_2{{14 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_3{{14 * CHARACTER_WIDTH, 7 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_4{{14 * CHARACTER_WIDTH, 8 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_5{{14 * CHARACTER_WIDTH, 9 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_6{{14 * CHARACTER_WIDTH, 10 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_7{{14 * CHARACTER_WIDTH, 11 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; + Text text_info_line_8{{14 * CHARACTER_WIDTH, 12 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""}; +}; + } /* namespace ui */ #endif /*__UI_DFU_MENU_H__*/ diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 47d35c87..60c69c53 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -714,20 +714,27 @@ Context& SystemView::context() const { } void SystemView::toggle_overlay() { - if (overlay_active) { - this->remove_child(&this->overlay); - this->set_dirty(); - shared_memory.request_m4_performance_counter = 0; - } else { - this->add_child(&this->overlay); - this->set_dirty(); - shared_memory.request_m4_performance_counter = 1; - shared_memory.m4_cpu_usage = 0; - shared_memory.m4_heap_usage = 0; - shared_memory.m4_stack_usage = 0; + switch (++overlay_active) { + case 1: + this->add_child(&this->overlay); + this->set_dirty(); + shared_memory.request_m4_performance_counter = 1; + shared_memory.m4_cpu_usage = 0; + shared_memory.m4_heap_usage = 0; + shared_memory.m4_stack_usage = 0; + break; + case 2: + this->remove_child(&this->overlay); + this->add_child(&this->overlay2); + this->set_dirty(); + shared_memory.request_m4_performance_counter = 0; + break; + case 3: + this->remove_child(&this->overlay2); + this->set_dirty(); + overlay_active = 0; + break; } - - overlay_active = !overlay_active; } void SystemView::paint_overlay() { @@ -738,7 +745,10 @@ void SystemView::paint_overlay() { return; last_paint_state = !last_paint_state; - this->overlay.set_dirty(); + if (overlay_active == 1) + this->overlay.set_dirty(); + else + this->overlay2.set_dirty(); } } diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index c6d05302..c113b3c8 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -328,11 +328,12 @@ class SystemView : public View { void paint_overlay(); private: - bool overlay_active{false}; + uint8_t overlay_active{0}; SystemStatusView status_view{navigation_view}; InformationView info_view{navigation_view}; DfuMenu overlay{navigation_view}; + DfuMenu2 overlay2{navigation_view}; NavigationView navigation_view{}; Context& context_; };