22 #include "os_helpers.h"
24 #define STEPSPIC(x) ((const ux_flow_step_t *const *) PIC(x))
25 #define STEPPIC(x) ((const ux_flow_step_t *) PIC(x))
26 #define INITPIC(x) ((ux_flow_step_init_t) PIC(x))
27 #define STRPIC(x) ((const char *) PIC(x))
92 #define FLOW_END_STEP ((const ux_flow_step_t *) 0xFFFFFFFFUL)
96 #define FLOW_BARRIER ((const ux_flow_step_t *) 0xFFFFFFFEUL)
101 #define FLOW_LOOP ((const ux_flow_step_t *) 0xFFFFFFFDUL)
114 #define UX_STEP_FLOWS(stepname, layoutkind, preinit, timeout_ms, validate_flow, error_flow, ...) \
115 void stepname##_init(unsigned int stack_slot) \
118 ux_layout_##layoutkind##_init(stack_slot); \
119 ux_layout_set_timeout(stack_slot, timeout_ms); \
121 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
122 const ux_flow_step_t stepname = { \
129 #define UX_STEP(stepname, layoutkind, preinit, timeout_ms, validate_cb, error_flow, ...) \
130 UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
131 void stepname##_init(unsigned int stack_slot) \
134 ux_layout_##layoutkind##_init(stack_slot); \
135 ux_layout_set_timeout(stack_slot, timeout_ms); \
137 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
138 const ux_flow_step_t stepname = { \
141 stepname##_validate, \
148 #define UX_STEP_INIT(stepname, validate_flow, error_flow, ...) \
149 void stepname##_init(unsigned int stack_slot) \
151 UNUSED(stack_slot); \
154 const ux_flow_step_t stepname = { \
161 #define UX_FLOW_DEF_INIT UX_STEP_INIT
166 #define UX_STEP_CB(stepname, layoutkind, validate_cb, ...) \
167 UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
168 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
169 const ux_flow_step_t stepname = { \
170 ux_layout_##layoutkind##_init, \
172 stepname##_validate, \
176 #define UX_FLOW_DEF_VALID UX_STEP_VALID
178 #define UX_STEP_VALID UX_STEP_CB
183 #define UX_STEP_FLOWCB(stepname, layoutkind, validate_flow, error_flow, ...) \
184 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
185 const ux_flow_step_t stepname = { \
186 ux_layout_##layoutkind##_init, \
196 #define UX_STEP_CB_INIT(stepname, layoutkind, preinit, validate_cb, ...) \
197 UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
198 void stepname##_init(unsigned int stack_slot) \
201 ux_layout_##layoutkind##_init(stack_slot); \
203 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
204 const ux_flow_step_t stepname = { \
207 stepname##_validate, \
214 #define UX_STEP_TIMEOUT(stepname, layoutkind, timeout_ms, validate_flow, ...) \
215 void stepname##_init(unsigned int stack_slot) \
217 ux_layout_##layoutkind##_init(stack_slot); \
218 ux_layout_set_timeout(stack_slot, timeout_ms); \
220 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
221 const ux_flow_step_t stepname = { \
231 #define UX_STEP_NOCB(stepname, layoutkind, ...) \
232 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
233 const ux_flow_step_t stepname = { \
234 ux_layout_##layoutkind##_init, \
240 #define UX_FLOW_DEF_NOCB UX_STEP_NOCB
246 #define UX_STEP_NOCB_INIT(stepname, layoutkind, preinit, ...) \
247 void stepname##_init(unsigned int stack_slot) \
250 ux_layout_##layoutkind##_init(stack_slot); \
252 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
253 const ux_flow_step_t stepname = { \
264 #define UX_STEP_NOCB_POSTINIT(stepname, layoutkind, postinit, ...) \
265 void stepname##_init(unsigned int stack_slot) \
267 ux_layout_##layoutkind##_init(stack_slot); \
270 const ux_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
271 const ux_flow_step_t stepname = { \
282 #define UX_FLOW_CALL(flow_name, code) \
283 void flow_name##init(unsigned int stack_slot) \
285 UNUSED(stack_slot); \
288 const ux_flow_step_t flow_name##_step = {flow_name##init, NULL, NULL, NULL}; \
289 const ux_flow_step_t *const flow_name[] = { \
297 #define UX_FLOW(flow_name, ...) \
298 const ux_flow_step_t *const flow_name[] = {__VA_ARGS__, FLOW_END_STEP}
300 #define UX_DEF UX_FLOW
302 #define UX_STEP_AFTER_PIN(stepname, stackslot, callback) \
304 UX_STEP_INIT(stepname##__askpin, NULL, NULL, { \
305 if (os_perso_isonboarded() == BOLOS_UX_OK) { \
307 ux_flow_next_no_display(); \
309 screen_modal_validate_pin_init(); \
316 UX_STEP_INIT(stepname##__pincallback, NULL, NULL, { callback(0); }); \
318 UX_FLOW(stepname##__pinflow, &stepname##__askpin, &stepname##__pincallback); \
320 UX_STEP_INIT(stepname, NULL, NULL, { ux_flow_init(stackslot, stepname##__pinflow, NULL); });
const ux_flow_step_t *const * steps
unsigned short prev_index
const ux_flow_step_t *const * error_flow
const ux_flow_step_t *const * validate_flow
void ux_flow_init(unsigned int stack_slot, const ux_flow_step_t *const *steps, const ux_flow_step_t *const start_step)
@ FLOW_DIRECTION_BACKWARD
ux_flow_direction_t ux_flow_direction(void)
void(* ux_flow_step_init_t)(unsigned int stack_slot)
unsigned int ux_flow_is_first(void)
void ux_flow_error(unsigned int error)
const void * ux_stack_get_step_params(unsigned int stack_slot)
void ux_flow_next_no_display(void)
const ux_flow_step_t * ux_flow_get_current(void)
const void * ux_stack_get_current_step_params(void)
void ux_flow_uninit(unsigned int stack_slot)
unsigned int ux_flow_button_callback(unsigned int button_mask, unsigned int button_mask_counter)
unsigned int ux_flow_is_last(void)
void ux_flow_validate(void)
unsigned int ux_flow_relayout(void)