Skip to content

Commit

Permalink
- Fix screensaver bug for nanosp
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkyaraj-23 committed Feb 27, 2024
1 parent a55fd1f commit 937b59a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
13 changes: 7 additions & 6 deletions src/ui_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
62 changes: 62 additions & 0 deletions src/ui_empty.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifdef HAVE_BAGL
#include "bolos_target.h"

#include "ui.h"

const bagl_element_t empty_screen_elements[] = {
#if (BAGL_WIDTH == 128 && BAGL_HEIGHT == 64)
{{BAGL_RECTANGLE, 0x00, 0, 0, 128, 64, 0, 0, BAGL_FILL, 0x000000, 0xFFFFFF, 0, 0},
.text = NULL},
#elif (BAGL_WIDTH == 128 && BAGL_HEIGHT == 32)
{{BAGL_RECTANGLE, 0x00, 0, 0, 128, 32, 0, 0, BAGL_FILL, 0x000000, 0xFFFFFF, 0, 0},
.text = NULL},
#else
#error "BAGL_WIDTH/BAGL_HEIGHT not defined"
#endif
{{BAGL_LABELINE,
0x10,
6,
12,
116,
32,
0,
0,
0,
0xFFFFFF,
0x000000,
BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER,
0},
.text = NULL}};

typedef struct ux_layout_empty_params_s {
const char *line1;
} 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;
G_ux.stack[stack_slot].screen_before_element_display_callback = ux_layout_strings_prepro;
ux_stack_display(stack_slot);
}

void ux_layout_empty_screen_init(__attribute__((unused)) unsigned int x) {
}

void return_to_idle() {
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() {
ux_flow_init(0, ux_empty_flow, NULL);
}
#else
void ux_empty_screen() {
}
#endif

0 comments on commit 937b59a

Please sign in to comment.