diff --git a/src/apdu_sign.c b/src/apdu_sign.c index 0813e66f..e20d3784 100644 --- a/src/apdu_sign.c +++ b/src/apdu_sign.c @@ -124,6 +124,7 @@ size_t baking_sign_complete(bool const send_hash, volatile uint32_t *flags) { case MAGIC_BYTE_BLOCK: case MAGIC_BYTE_BAKING_OP: guard_baking_authorized(&G.parsed_baking_data, &global.path_with_curve); + ux_empty_screen(); return perform_signature(true, send_hash); break; @@ -285,7 +286,6 @@ size_t handle_apdu_sign_with_hash(uint8_t instruction, volatile uint32_t *flags) int perform_signature(bool const on_hash, bool const send_hash) { write_high_water_mark(&G.parsed_baking_data); - size_t tx = 0; if (send_hash && on_hash) { memcpy(&G_io_apdu_buffer[tx], G.final_hash, sizeof(G.final_hash)); diff --git a/src/globals.h b/src/globals.h index 9fd0e1e8..3cf77eec 100644 --- a/src/globals.h +++ b/src/globals.h @@ -96,6 +96,8 @@ typedef struct { char screen_title[PROMPT_WIDTH + 1]; // Value to be displayed on the screen. char screen_value[VALUE_WIDTH + 1]; + // Screensaver is on/off. + bool is_blank_screen; } dynamic_display; void *stack_root; diff --git a/src/ui.h b/src/ui.h index e52c3cef..ca565078 100644 --- a/src/ui.h +++ b/src/ui.h @@ -17,6 +17,7 @@ void ux_confirm_screen(ui_callback_t ok_c, ui_callback_t cxl_c); void ux_idle_screen(ui_callback_t ok_c, ui_callback_t cxl_c); +void ux_empty_screen(void); /* Initializes the formatter stack. Should be called once before calling `push_ui_callback()`. */ void init_screen_stack(); /* User MUST call `init_screen_stack()` before calling this function for the first time. */ diff --git a/src/ui_bagl.c b/src/ui_bagl.c index b63ca280..e70c5b0b 100644 --- a/src/ui_bagl.c +++ b/src/ui_bagl.c @@ -64,12 +64,13 @@ UX_STEP_NOCB(ux_variable_display, }); UX_STEP_INIT(ux_init_lower_border, NULL, NULL, { display_next_state(false); }); -UX_STEP_NOCB(ux_app_is_ready_step, - nn, - { - "Application", - "is ready", - }); +UX_STEP_CB(ux_app_is_ready_step, + nn, + ux_empty_screen(), + { + "Application", + "is ready", + }); UX_STEP_CB(ux_idle_quit_step, pb, diff --git a/src/ui_empty.c b/src/ui_empty.c new file mode 100644 index 00000000..3d2c948a --- /dev/null +++ b/src/ui_empty.c @@ -0,0 +1,55 @@ +#ifdef HAVE_BAGL +#include "bolos_target.h" +#include "globals.h" +#include "ui.h" + +const bagl_element_t empty_screen_elements[] = {{{BAGL_RECTANGLE, + BAGL_NONE, + 0, + 0, + BAGL_WIDTH, + BAGL_HEIGHT, + 0, + 0, + BAGL_FILL, + 0x000000, + 0xFFFFFF, + 0, + 0}, + .text = NULL}, + {}}; + +typedef struct ux_layout_empty_params_s { +} ux_layout_empty_params_t; + +void ux_layout_empty_init(unsigned int stack_slot) { + ux_stack_init(stack_slot); + G_ux.stack[stack_slot].element_arrays[0].element_array = empty_screen_elements; + G_ux.stack[stack_slot].element_arrays[0].element_array_count = ARRAYLEN(empty_screen_elements); + G_ux.stack[stack_slot].element_arrays_count = 1; + G_ux.stack[stack_slot].button_push_callback = ux_flow_button_callback; + ux_stack_display(stack_slot); +} + +void ux_layout_empty_screen_init(__attribute__((unused)) unsigned int x) { +} + +void return_to_idle() { + global.dynamic_display.is_blank_screen = false; + ux_idle_screen(NULL, NULL); +} + +UX_STEP_CB(empty_screen_step, empty, return_to_idle(), {}); +UX_STEP_INIT(empty_screen_border, NULL, NULL, { return_to_idle(); }); +UX_FLOW(ux_empty_flow, &empty_screen_step, &empty_screen_border, FLOW_LOOP); + +void ux_empty_screen() { + if (global.dynamic_display.is_blank_screen == false) { + global.dynamic_display.is_blank_screen = true; + ux_flow_init(0, ux_empty_flow, NULL); + } +} +#else +void ux_empty_screen() { +} +#endif