diff --git a/firmware/application/apps/ui_debug.cpp b/firmware/application/apps/ui_debug.cpp index 7b417c7ec..8465bfe31 100644 --- a/firmware/application/apps/ui_debug.cpp +++ b/firmware/application/apps/ui_debug.cpp @@ -403,9 +403,10 @@ DebugMenuView::DebugMenuView(NavigationView& nav) { {"Peripherals", ui::Color::dark_cyan(), &bitmap_icon_peripherals, [&nav]() { nav.push(); }}, {"Temperature", ui::Color::dark_cyan(), &bitmap_icon_temperature, [&nav]() { nav.push(); }}, {"Buttons Test", ui::Color::dark_cyan(), &bitmap_icon_controls, [&nav]() { nav.push(); }}, + {"Touch Test", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push(); }}, {"P.Memory", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push(); }}, - {"Fonts Viewer", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push(); }}, {"Debug Dump", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { portapack::persistent_memory::debug_dump(); }}, + {"Fonts Viewer", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push(); }}, }); set_max_rows(2); // allow wider buttons } @@ -501,6 +502,56 @@ DebugFontsView::DebugFontsView(NavigationView& nav) set_focusable(true); } +/* DebugScreenTest ****************************************************/ + +DebugScreenTest::DebugScreenTest(NavigationView& nav) + : nav_{nav} { + set_focusable(true); +} + +bool DebugScreenTest::on_key(const KeyEvent key) { + Painter painter; + switch (key) { + case KeyEvent::Select: + nav_.pop(); + break; + case KeyEvent::Down: + painter.fill_rectangle({0, 0, screen_width, screen_height}, semirand()); + break; + case KeyEvent::Left: + pen_color = semirand(); + break; + default: + break; + } + return true; +} + +bool DebugScreenTest::on_encoder(EncoderEvent delta) { + pen_size = clip(pen_size + delta, 1, screen_width); + return true; +} + +bool DebugScreenTest::on_touch(const TouchEvent event) { + Painter painter; + pen_pos = event.point; + painter.fill_rectangle({pen_pos.x() - pen_size / 2, pen_pos.y() - pen_size / 2, pen_size, pen_size}, pen_color); + return true; +} + +uint16_t DebugScreenTest::semirand() { + static uint64_t seed{0x31415926DEADBEEF}; + seed = seed * 137; + seed = (seed >> 1) | ((seed & 0x01) << 63); + return (uint16_t)seed; +} + +void DebugScreenTest::paint(Painter& painter) { + painter.fill_rectangle({0, 0, screen_width, screen_height}, Color::white()); + painter.draw_string({10 * 8, screen_height / 2}, Styles::white, "Use Stylus"); + pen_color = semirand(); +} + /* DebugLCRView *******************************************************/ /*DebugLCRView::DebugLCRView(NavigationView& nav, std::string lcr_string) { diff --git a/firmware/application/apps/ui_debug.hpp b/firmware/application/apps/ui_debug.hpp index 6f14143ab..00efe62a4 100644 --- a/firmware/application/apps/ui_debug.hpp +++ b/firmware/application/apps/ui_debug.hpp @@ -321,6 +321,22 @@ class DebugFontsView : public View { NavigationView& nav_; }; +class DebugScreenTest : public View { + public: + DebugScreenTest(NavigationView& nav); + bool on_key(KeyEvent key) override; + bool on_encoder(EncoderEvent delta) override; + bool on_touch(TouchEvent event) override; + uint16_t semirand(); + void paint(Painter& painter) override; + + private: + NavigationView& nav_; + Point pen_pos{}; + Color pen_color{0}; + int16_t pen_size{10}; +}; + /*class DebugLCRView : public View { public: DebugLCRView(NavigationView& nav, std::string lcrstring);