From 288cd11b2a671299fe3530ad3530be3e56b1dbff Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 28 Mar 2023 14:40:39 +0200 Subject: [PATCH] refactor(core/bootloader): inline "wait for click" into ui_screen_boot_click --- core/embed/bootloader/bootui.c | 41 ++++++++++++++++++++++++++++++++++ core/embed/bootloader/bootui.h | 2 -- core/embed/bootloader/main.c | 18 --------------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/core/embed/bootloader/bootui.c b/core/embed/bootloader/bootui.c index 1ced805d40..6c36815433 100644 --- a/core/embed/bootloader/bootui.c +++ b/core/embed/bootloader/bootui.c @@ -110,6 +110,46 @@ void ui_screen_boot_wait(int wait_seconds) { display_refresh(); } +#if defined USE_TOUCH +#include "touch/touch.h" + +void ui_click(void) { + // flush touch events if any + while (touch_read()) { + } + // wait for TOUCH_START + while ((touch_read() & TOUCH_START) == 0) { + } + // wait for TOUCH_END + while ((touch_read() & TOUCH_END) == 0) { + } + // flush touch events if any + while (touch_read()) { + } +} + +#elif defined USE_BUTTON +#include "button.h" + +void ui_click(void) { + for (;;) { + button_read(); + if (button_state_left() != 0 && button_state_right() != 0) { + break; + } + } + for (;;) { + button_read(); + if (button_state_left() != 1 && button_state_right() != 1) { + break; + } + } +} + +#else +#error "No input method defined" +#endif + void ui_screen_boot_click(void) { display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background); display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, @@ -117,6 +157,7 @@ void ui_screen_boot_click(void) { boot_background); PIXELDATA_DIRTY(); display_refresh(); + ui_click(); } // welcome UI diff --git a/core/embed/bootloader/bootui.h b/core/embed/bootloader/bootui.h index ccd6fd0a52..0c2d0f8926 100644 --- a/core/embed/bootloader/bootui.h +++ b/core/embed/bootloader/bootui.h @@ -75,6 +75,4 @@ void ui_screen_boot_empty(bool fading); #define INPUT_INFO 0x08 // Info icon // clang-format on -int ui_user_input(int zones); - #endif diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c index 877ba27fd1..21cdba2f0c 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/bootloader/main.c @@ -513,24 +513,6 @@ int bootloader_main(void) { if ((vhdr.vtrust & VTRUST_CLICK) == 0) { ui_screen_boot_click(); -#if defined USE_TOUCH - touch_click(); -#elif defined USE_BUTTON - for (;;) { - button_read(); - if (button_state_left() != 0 && button_state_right() != 0) { - break; - } - } - for (;;) { - button_read(); - if (button_state_left() != 1 && button_state_right() != 1) { - break; - } - } -#else -#error Unknown Trezor model -#endif } ui_fadeout();