diff --git a/firmware/application/apps/ui_dfu_menu.cpp b/firmware/application/apps/ui_dfu_menu.cpp index 69abe02d..85b43a83 100644 --- a/firmware/application/apps/ui_dfu_menu.cpp +++ b/firmware/application/apps/ui_dfu_menu.cpp @@ -26,20 +26,50 @@ namespace ui { DfuMenu::DfuMenu(NavigationView& nav) : nav_ (nav) { add_children({ - &text_info, - &progress, - &dummy, + &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 }); } -void DfuMenu::focus() { - dummy.focus(); -} - void DfuMenu::paint(Painter& painter) { + //update child values + // if (chThdSelf() == chSysGetIdleThread()) { chThdGetTicks(chThdSelf()) } + + auto now = chTimeNow(); + auto idle_ticks = chThdGetTicks(chSysGetIdleThread()); + + static systime_t last_time; + static systime_t last_last_time; + + auto time_elapsed = now - last_time; + auto idle_elapsed = idle_ticks - last_last_time; + + last_time = now; + last_last_time = idle_ticks; + + text_info_line_1.set(to_string_dec_uint(chCoreStatus(), 6)); + text_info_line_2.set(to_string_dec_uint((uint32_t)get_free_stack_space(), 6)); + text_info_line_3.set(to_string_dec_uint((time_elapsed - idle_elapsed) / 10, 6)); + text_info_line_4.set("M4 heap"); + text_info_line_5.set("M4 stack"); + text_info_line_6.set("M4 cpu"); + text_info_line_7.set(to_string_dec_uint(chTimeNow()/1000, 6)); + + auto screen_size = portapack::display.screen_rect().size(); + painter.fill_rectangle( - {{50,50} , {50 , 50}}, - ui::Color::blue() + { + {6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT}, + {screen_size.width() - 12 * CHARACTER_WIDTH, screen_size.height() - 6 * LINE_HEIGHT} + }, + ui::Color::black() ); } diff --git a/firmware/application/apps/ui_dfu_menu.hpp b/firmware/application/apps/ui_dfu_menu.hpp index d184d2cd..54272f03 100644 --- a/firmware/application/apps/ui_dfu_menu.hpp +++ b/firmware/application/apps/ui_dfu_menu.hpp @@ -26,6 +26,11 @@ #include "ui_widget.hpp" #include "event_m0.hpp" +#include "debug.hpp" +#include "string_format.hpp" + +#define LINE_HEIGHT 16 +#define CHARACTER_WIDTH 8 namespace ui { class NavigationView; @@ -35,27 +40,34 @@ public: DfuMenu(NavigationView& nav); ~DfuMenu() = default; - void focus() override; void paint(Painter& painter) override; - std::string title() const override { return "DFU Menu"; }; - private: NavigationView& nav_; - Text text_info { - { 10 * 8, 16 * 8, 10 * 8, 16 }, - "Working..." + Text text_head {{ 6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, "DFU Menu"}; + + Labels labels { + { { 6 * CHARACTER_WIDTH, 5 * LINE_HEIGHT }, "M0 heap:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH, 6 * LINE_HEIGHT }, "M0 stack:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH, 7 * LINE_HEIGHT }, "M0 cpu %:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH, 8 * LINE_HEIGHT }, "M4 heap:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH, 9 * LINE_HEIGHT }, "M4 stack:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH,10 * LINE_HEIGHT }, "M4 cpu %:", Color::light_grey() }, + { { 6 * CHARACTER_WIDTH,11 * LINE_HEIGHT }, "uptime:", Color::light_grey() } }; + + Text text_info_line_1 {{ 16 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_2 {{ 16 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_3 {{ 16 * CHARACTER_WIDTH, 7 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_4 {{ 16 * CHARACTER_WIDTH, 8 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_5 {{ 16 * CHARACTER_WIDTH, 9 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_6 {{ 16 * CHARACTER_WIDTH,10 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; + Text text_info_line_7 {{ 16 * CHARACTER_WIDTH,11 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""}; - ProgressBar progress { - { 2 * 8, 19 * 8, 26 * 8, 24 } - }; - - Button dummy { - { 240, 0, 0, 0 }, - "" - }; + // ProgressBar progress { + // { 6 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 16 * CHARACTER_WIDTH, 24 } + // }; }; } /* namespace ui */ diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index a68e02fe..fc96920a 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -761,7 +761,13 @@ void SystemView::toggle_overlay() { } void SystemView::paint_overlay() { + static bool last_paint_state = false; if (overlay_active){ + // paint background only every other second + if ((((chTimeNow()>>10) & 0x01) == 0x01) == last_paint_state) + return; + + last_paint_state = !last_paint_state; this->overlay.set_dirty(); } }