Skip to content

Commit

Permalink
Disable Back button during Touch Calibration (#2115)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotherNgineer committed Apr 21, 2024
1 parent e735956 commit 282e4da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions firmware/application/apps/ui_touch_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "portapack_persistent_memory.hpp"
using namespace portapack;

extern ui::SystemView* system_view_ptr;

namespace ui {

TouchCalibrationView::TouchCalibrationView(
Expand All @@ -40,6 +42,7 @@ TouchCalibrationView::TouchCalibrationView(
&image_verify_1,
&image_verify_2,
&label_calibrate,
&label_calibrate_2,
&label_verify,
&label_success,
&label_failure,
Expand All @@ -51,6 +54,12 @@ TouchCalibrationView::TouchCalibrationView(
button_ok.on_select = [this](Button&) { this->on_ok(); };

set_phase(Phase::Calibrate0);

system_view_ptr->get_status_view()->set_back_hidden(true);
}

TouchCalibrationView::~TouchCalibrationView() {
system_view_ptr->get_status_view()->set_back_hidden(false);
}

void TouchCalibrationView::focus() {
Expand All @@ -70,6 +79,7 @@ void TouchCalibrationView::update_target() {
image_verify_2.hidden(phase != Phase::Verify2);

label_calibrate.hidden(!phase_calibrate);
label_calibrate_2.hidden(!phase_calibrate && !phase_verify);
label_verify.hidden(!phase_verify);
label_success.hidden(phase != Phase::Success);
label_failure.hidden(phase != Phase::Failure);
Expand Down
7 changes: 6 additions & 1 deletion firmware/application/apps/ui_touch_calibration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace ui {
class TouchCalibrationView : public View {
public:
TouchCalibrationView(NavigationView& nav);
~TouchCalibrationView();

void focus() override;

Expand Down Expand Up @@ -110,9 +111,13 @@ class TouchCalibrationView : public View {
Color::black()};

Text label_calibrate{
{16, 5 * 16, 26 * 8, 1 * 16},
{2 * 8, 5 * 16, 26 * 8, 1 * 16},
"Touch targets to calibrate"};

Text label_calibrate_2{
{1 * 8, 6 * 16, 28 * 8, 1 * 16},
"(hold position using stylus)"};

Text label_verify{
{28, 5 * 16, 23 * 8, 1 * 16},
"Touch targets to verify"};
Expand Down
3 changes: 3 additions & 0 deletions firmware/application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ Continuous (Fox-oring)

#include "rffc507x.hpp" /* c/m, avoiding initial short ON Ant_DC_Bias pulse, from cold reset */
rffc507x::RFFC507x first_if;
ui::SystemView* system_view_ptr;

static void event_loop() {
static ui::Context context;
static ui::SystemView system_view{
context,
portapack::display.screen_rect()};

system_view_ptr = &system_view;

EventDispatcher event_dispatcher{&system_view, context};
static MessageHandlerRegistration message_handler_display_sleep{
Message::ID::DisplaySleep,
Expand Down
7 changes: 7 additions & 0 deletions firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ void SystemStatusView::set_back_enabled(bool new_value) {
}
}

void SystemStatusView::set_back_hidden(bool new_value) {
button_back.hidden(new_value);
}

void SystemStatusView::set_title_image_enabled(bool new_value) {
if (new_value) {
add_child(&button_title);
Expand Down Expand Up @@ -896,6 +900,9 @@ Context& SystemView::context() const {
NavigationView* SystemView::get_navigation_view() {
return &navigation_view;
}
SystemStatusView* SystemView::get_status_view() {
return &status_view;
}

void SystemView::toggle_overlay() {
static uint8_t last_perf_counter_status = shared_memory.request_m4_performance_counter;
Expand Down
2 changes: 2 additions & 0 deletions firmware/application/ui_navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class SystemStatusView : public View {
SystemStatusView(NavigationView& nav);

void set_back_enabled(bool new_value);
void set_back_hidden(bool new_value);
void set_title_image_enabled(bool new_value);
void set_title(const std::string new_value);

Expand Down Expand Up @@ -378,6 +379,7 @@ class SystemView : public View {
void paint_overlay();

NavigationView* get_navigation_view();
SystemStatusView* get_status_view();

private:
uint8_t overlay_active{0};
Expand Down

0 comments on commit 282e4da

Please sign in to comment.