Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_step.c
Go to the documentation of this file.
1
6#ifdef NBGL_STEP
7/*********************
8 * INCLUDES
9 *********************/
10#include <string.h>
11#include "nbgl_debug.h"
12#include "nbgl_step.h"
13#include "glyphs.h"
14#include "os_pic.h"
15#include "os_print.h"
16#ifdef BUILD_SCREENSHOTS
17#include "json_scenario.h"
18#endif // BUILD_SCREENSHOTS
19
20/*********************
21 * DEFINES
22 *********************/
23// string to store the title for a multi-pages text+subtext
24#define TMP_STRING_MAX_LEN 24
25
27#define NB_MAX_LAYERS 3
28
29/**********************
30 * TYPEDEFS
31 **********************/
35typedef enum {
36 TEXT_STEP = 0,
37 CENTERED_INFO_STEP,
38 MENU_LIST_STEP
39} StepStype_t;
40
44typedef struct TextContext_s {
45 uint8_t nbPages;
46 uint8_t currentPage;
47 const char *txtStart;
48 const char *nextPageStart;
49 const char *subTxtStart;
50
52 nbgl_stepButtonCallback_t onActionCallback;
54 char tmpString[TMP_STRING_MAX_LEN];
57 style;
58} TextContext_t;
59
63typedef struct MenuListContext_s {
65 selectedCallback;
67 list;
68} MenuListContext_t;
69
70typedef struct StepContext_s {
71 union {
72 TextContext_t textContext;
73 MenuListContext_t menuListContext;
74 };
76 nbgl_layout_t *layout;
77 StepStype_t type;
78 bool modal;
79} StepContext_t;
80
81/**********************
82 * STATIC VARIABLES
83 **********************/
85static StepContext_t contexts[NB_MAX_LAYERS];
86
87/**********************
88 * VARIABLES
89 **********************/
90#ifdef BUILD_SCREENSHOTS
91// Contains the last string index used
92extern UX_LOC_STRINGS_INDEX last_string_id;
93
94// Variables used to store important values (nb lines, bold state etc)
95extern uint16_t last_nb_lines;
96extern uint16_t last_nb_pages;
97extern bool last_bold_state;
98#endif // BUILD_SCREENSHOTS
99
100/**********************
101 * STATIC PROTOTYPES
102 **********************/
103
104static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event);
105static void menuListActionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event);
106
107// returns a non-used step context from the contexts[] array, or NULL if not found
108static StepContext_t *getFreeContext(StepStype_t type, bool modal)
109{
110 StepContext_t *ctx = NULL;
111
112 if (!modal) {
113 // Index 0 is reserved for background
114 ctx = &contexts[0];
115 }
116 else {
117 uint32_t i = 1;
118 while (i < NB_MAX_LAYERS) {
119 if (contexts[i].layout == NULL) {
120 ctx = &contexts[i];
121 break;
122 }
123 i++;
124 }
125 }
126 if (ctx == NULL) {
127 LOG_FATAL(STEP_LOGGER, "getFreeContext(): no available context\n");
128 }
129 else {
130 memset(ctx, 0, sizeof(StepContext_t));
131 ctx->type = type;
132 ctx->modal = modal;
133 }
134 return ctx;
135}
136
137// returns the step context from the contexts[] array matching with the given layout handler, or
138// NULL if not found
139static StepContext_t *getContextFromLayout(nbgl_layout_t layout)
140{
141 StepContext_t *ctx = NULL;
142 uint32_t i = 0;
143 while (i < NB_MAX_LAYERS) {
144 if (contexts[i].layout == layout) {
145 ctx = &contexts[i];
146 break;
147 }
148 i++;
149 }
150 if (ctx == NULL) {
151 LOG_WARN(STEP_LOGGER, "getContextFromLayout(): no matching context\n");
152 }
153 return ctx;
154}
155
156// from the current details context, return a pointer on the details at the given page
157static const char *getTextPageAt(StepContext_t *ctx, uint8_t textPage)
158{
159 uint8_t page = 0;
160 const char *currentChar = ctx->textContext.txtStart;
161 while (page < textPage) {
162 if (page < (ctx->textContext.nbPages - 1)) {
163 uint16_t len;
165 currentChar,
168 &len,
169 true);
170 currentChar = currentChar + len;
171 }
172 page++;
173 }
174 return currentChar;
175}
176
177// from the current details context, return a pointer on the details at the given page, for subText
178static const char *getSubTextPageAt(StepContext_t *ctx, uint8_t textPage)
179{
180 uint8_t page = 0;
181 const char *currentChar = ctx->textContext.subTxtStart;
182 while (page < textPage) {
183 if (page < (ctx->textContext.nbPages - 1)) {
184 uint16_t len;
186 currentChar,
188 NB_MAX_LINES - 1,
189 &len,
190 true);
191 currentChar = currentChar + len;
192 }
193 page++;
194 }
195 return currentChar;
196}
197
198// utility function to compute navigation arrows
199static nbgl_layoutNavIndication_t getNavigationInfo(nbgl_stepPosition_t pos,
200 uint8_t nbPages,
201 uint8_t currentPage)
202{
204
205 if (nbPages > 1) {
206 if (currentPage > 0) {
207 indication |= LEFT_ARROW;
208 }
209 if (currentPage < (nbPages - 1)) {
210 indication |= RIGHT_ARROW;
211 }
212 }
213 if (pos == FIRST_STEP) {
214 indication |= RIGHT_ARROW;
215 }
216 else if (pos == LAST_STEP) {
217 indication |= LEFT_ARROW;
218 }
219 else if (pos == NEITHER_FIRST_NOR_LAST_STEP) {
220 indication |= RIGHT_ARROW | LEFT_ARROW;
221 }
222 return indication;
223}
224
225// function used to display the current page in details review mode
226static void displayTextPage(StepContext_t *ctx, uint8_t textPage)
227{
228 const char *txt;
229 char intermediateString[36]; // a bit bigger but we know that one line cannot contain
230 // more than 23 chars
231
232 // if move backward or first page
233 if (textPage <= ctx->textContext.currentPage) {
234 // recompute current start from beginning
235 if (ctx->textContext.subTxtStart == NULL) {
236 txt = getTextPageAt(ctx, textPage);
237 }
238 else {
239 txt = getSubTextPageAt(ctx, textPage);
240 }
241 }
242 // else move forward
243 else {
244 txt = ctx->textContext.nextPageStart;
245 }
246 ctx->textContext.currentPage = textPage;
247
248 if (ctx->textContext.currentPage < (ctx->textContext.nbPages - 1)) {
249 uint16_t len;
250 uint8_t nbLines
251 = (ctx->textContext.subTxtStart == NULL) ? NB_MAX_LINES : (NB_MAX_LINES - 1);
253 BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp, txt, AVAILABLE_WIDTH, nbLines, &len, true);
254 // memorize next position to save processing
255 ctx->textContext.nextPageStart = txt + len;
256 // if the next char is '\n', skip it to avoid starting with an empty line
257 if (*ctx->textContext.nextPageStart == '\n') {
258 ctx->textContext.nextPageStart++;
259 }
260 }
261 else {
262 ctx->textContext.nextPageStart = NULL;
263 }
264 nbgl_layoutDescription_t layoutDescription;
265 nbgl_layoutNavigation_t navInfo = {
267 };
268
269 layoutDescription.modal = ctx->modal;
270 layoutDescription.onActionCallback = actionCallback;
271 layoutDescription.ticker.tickerCallback = ctx->ticker.tickerCallback;
272 layoutDescription.ticker.tickerIntervale = ctx->ticker.tickerIntervale;
273 layoutDescription.ticker.tickerValue = ctx->ticker.tickerValue;
274 ctx->layout = nbgl_layoutGet(&layoutDescription);
275
276 navInfo.indication = getNavigationInfo(
277 ctx->textContext.pos, ctx->textContext.nbPages, ctx->textContext.currentPage);
278
279 if (ctx->textContext.subTxtStart == NULL) {
280 nbgl_layoutAddText(ctx->layout, txt, NULL, ctx->textContext.style);
281 }
282 else {
283 if (ctx->textContext.nbPages == 1) {
284 // truncate title to fit in one line, if necessary
286 ctx->textContext.txtStart,
288 false)
289 > 1) {
291 ctx->textContext.txtStart,
293 1,
294 ctx->textContext.tmpString,
295 TMP_STRING_MAX_LEN);
296 }
297 else {
298 // simply copy
299 memcpy(
300 ctx->textContext.tmpString, ctx->textContext.txtStart, TMP_STRING_MAX_LEN - 1);
301 ctx->textContext.tmpString[TMP_STRING_MAX_LEN - 1] = 0;
302 }
303 }
304 else {
305 SPRINTF(intermediateString,
306 "%s (%d/%d)",
307 ctx->textContext.txtStart,
308 ctx->textContext.currentPage + 1,
309 ctx->textContext.nbPages);
310 // truncate title to fit in one line, if necessary
312 intermediateString,
314 false)
315 > 1) {
317 intermediateString,
319 1,
320 ctx->textContext.tmpString,
321 TMP_STRING_MAX_LEN);
322 }
323 else {
324 // simply copy
325 memcpy(ctx->textContext.tmpString, intermediateString, TMP_STRING_MAX_LEN - 1);
326 ctx->textContext.tmpString[TMP_STRING_MAX_LEN - 1] = 0;
327 }
328 }
329 nbgl_layoutAddText(ctx->layout, ctx->textContext.tmpString, txt, ctx->textContext.style);
330 }
331 if (navInfo.indication != NO_ARROWS) {
332 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
333 }
334 nbgl_layoutDraw(ctx->layout);
335 nbgl_refresh();
336}
337
338// callback on key touch
339static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
340{
341 StepContext_t *ctx = getContextFromLayout(layout);
342
343 if (!ctx) {
344 return;
345 }
346 if (event == BUTTON_LEFT_PRESSED) {
347 if (ctx->textContext.currentPage > 0) {
348 displayTextPage(ctx, ctx->textContext.currentPage - 1);
349 return;
350 }
351 else if ((ctx->textContext.pos == LAST_STEP)
352 || (ctx->textContext.pos == NEITHER_FIRST_NOR_LAST_STEP)) {
353 if (ctx->textContext.onActionCallback != NULL) {
354 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
355 }
356 }
357 }
358 else if (event == BUTTON_RIGHT_PRESSED) {
359 if (ctx->textContext.currentPage < (ctx->textContext.nbPages - 1)) {
360 displayTextPage(ctx, ctx->textContext.currentPage + 1);
361 return;
362 }
363 else if ((ctx->textContext.pos == FIRST_STEP)
364 || (ctx->textContext.pos == NEITHER_FIRST_NOR_LAST_STEP)) {
365 if (ctx->textContext.onActionCallback != NULL) {
366 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
367 }
368 }
369 }
370 else if (event == BUTTON_BOTH_PRESSED) {
371 if (ctx->textContext.onActionCallback != NULL) {
372 ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
373 }
374 }
375}
376
377static void displayMenuList(StepContext_t *ctx)
378{
379 nbgl_layoutDescription_t layoutDescription
380 = {.modal = ctx->modal, .onActionCallback = menuListActionCallback};
381 nbgl_layoutMenuList_t *list = &ctx->menuListContext.list;
382
383 layoutDescription.ticker.tickerCallback = ctx->ticker.tickerCallback;
384 layoutDescription.ticker.tickerIntervale = ctx->ticker.tickerIntervale;
385 layoutDescription.ticker.tickerValue = ctx->ticker.tickerValue;
386
387 ctx->layout = nbgl_layoutGet(&layoutDescription);
388 nbgl_layoutAddMenuList(ctx->layout, list);
389 if (list->nbChoices > 1) {
391 navInfo.indication = 0;
392 if (list->selectedChoice > 0) {
393 navInfo.indication |= LEFT_ARROW;
394 }
395 if (list->selectedChoice < (list->nbChoices - 1)) {
396 navInfo.indication |= RIGHT_ARROW;
397 }
398
399 if (navInfo.indication != NO_ARROWS) {
400 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
401 }
402 }
403 nbgl_layoutDraw(ctx->layout);
404 nbgl_refresh();
405}
406
407// callback on key touch
408static void menuListActionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
409{
410 StepContext_t *ctx = getContextFromLayout(layout);
411 if (!ctx) {
412 return;
413 }
414
415 if (event == BUTTON_LEFT_PRESSED) {
416 if (ctx->menuListContext.list.selectedChoice > 0) {
417 ctx->menuListContext.list.selectedChoice--;
418 displayMenuList(ctx);
419 }
420 }
421 else if (event == BUTTON_RIGHT_PRESSED) {
422 if (ctx->menuListContext.list.selectedChoice < (ctx->menuListContext.list.nbChoices - 1)) {
423 ctx->menuListContext.list.selectedChoice++;
424 displayMenuList(ctx);
425 }
426 }
427 else if (event == BUTTON_BOTH_PRESSED) {
428 ctx->menuListContext.selectedCallback(ctx->menuListContext.list.selectedChoice);
429 }
430}
431
432/**********************
433 * GLOBAL FUNCTIONS
434 **********************/
435
451 nbgl_stepButtonCallback_t onActionCallback,
453 const char *text,
454 const char *subText,
456 bool modal)
457{
458#ifdef BUILD_SCREENSHOTS
459 // Initialize a default area
460 nbgl_area_t area;
461 area.x0 = area.y0 = 0;
462 area.width = AVAILABLE_WIDTH;
464#endif // BUILD_SCREENSHOTS
465 StepContext_t *ctx = getFreeContext(TEXT_STEP, modal);
466 if (!ctx) {
467 return NULL;
468 }
469 // initialize context (already set to 0 by getFreeContext())
470 ctx->textContext.onActionCallback = onActionCallback;
471 if (ticker) {
472 ctx->ticker.tickerCallback = ticker->tickerCallback;
473 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
474 ctx->ticker.tickerValue = ticker->tickerValue;
475 }
476
477 // if no subText, get the number of pages for main text
478 if (subText == NULL) {
479 ctx->textContext.nbPages = nbgl_getTextNbPagesInWidth(
481#ifdef BUILD_SCREENSHOTS
482 store_string_infos(text,
484 &area,
485 true,
486 last_nb_lines,
487 last_nb_pages,
488 last_bold_state);
489#endif // BUILD_SCREENSHOTS
490 }
491 else {
492#ifdef BUILD_SCREENSHOTS
493 uint16_t nb_lines_title;
494 // Call this function to get correct nb_lines/nb_pages for text field.
497 nb_lines_title = last_nb_lines;
498 // There is a sub text, so no more than 3 lines for title...
499 if (nb_lines_title > 3) {
500 nb_lines_title = 3;
501 }
502 area.height
504 store_string_infos(text,
506 &area,
507 true,
508 last_nb_lines,
509 last_nb_pages,
510 last_bold_state);
511#endif // BUILD_SCREENSHOTS
512 // NB_MAX_LINES-1 because first line is for main text
513 ctx->textContext.nbPages = nbgl_getTextNbPagesInWidth(
515#ifdef BUILD_SCREENSHOTS
516 area.height = (NB_MAX_LINES - nb_lines_title)
518 // If subTxtid is not valid, we'll use txtId for nb_lines/nb_pages values
519 store_string_infos(subText,
521 &area,
522 true,
523 last_nb_lines,
524 last_nb_pages,
525 last_bold_state);
526#endif // BUILD_SCREENSHOTS
527 }
529 "nbgl_stepDrawText: ctx = %p, nbPages = %d, pos = 0x%X\n",
530 ctx,
531 ctx->textContext.nbPages,
532 pos);
533 if (pos & BACKWARD_DIRECTION) {
534 // start with last page
535 ctx->textContext.currentPage = ctx->textContext.nbPages - 1;
536 }
537 ctx->textContext.txtStart = text;
538 ctx->textContext.subTxtStart = subText;
539 // keep only direction part of position
540 ctx->textContext.pos = pos & (RIGHT_ARROW | LEFT_ARROW);
541 ctx->textContext.style = style;
542 displayTextPage(ctx, ctx->textContext.currentPage);
543
544 return (nbgl_step_t) ctx;
545}
546
558 nbgl_stepButtonCallback_t onActionCallback,
561 bool modal)
562{
563 nbgl_layoutDescription_t layoutDescription
564 = {.modal = modal, .onActionCallback = (nbgl_layoutButtonCallback_t) actionCallback};
565 nbgl_layoutNavigation_t navInfo = {
567 };
568 StepContext_t *ctx = getFreeContext(CENTERED_INFO_STEP, modal);
569 if (!ctx) {
570 return NULL;
571 }
572
573 // initialize context (already set to 0 by getFreeContext())
574 ctx->textContext.onActionCallback = onActionCallback;
575 if (ticker) {
576 ctx->ticker.tickerCallback = ticker->tickerCallback;
577 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
578 ctx->ticker.tickerValue = ticker->tickerValue;
579 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
580 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
581 layoutDescription.ticker.tickerValue = ticker->tickerValue;
582 }
583
584 ctx->textContext.nbPages = 1;
585 // keep only direction part of position
586 ctx->textContext.pos = pos & (RIGHT_ARROW | LEFT_ARROW);
587 navInfo.indication = getNavigationInfo(
588 ctx->textContext.pos, ctx->textContext.nbPages, ctx->textContext.currentPage);
589
590 ctx->layout = nbgl_layoutGet(&layoutDescription);
591 nbgl_layoutAddCenteredInfo(ctx->layout, info);
592 if (navInfo.indication != NO_ARROWS) {
593 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
594 }
595 nbgl_layoutDraw(ctx->layout);
596 nbgl_refresh();
597
598 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawCenteredInfo(): step = %p\n", ctx);
599 return (nbgl_step_t) ctx;
600}
601
615 bool modal)
616{
617 StepContext_t *ctx = getFreeContext(MENU_LIST_STEP, modal);
618 if (!ctx) {
619 return NULL;
620 }
621
622 // initialize context (already set to 0 by getFreeContext())
623 if (ticker) {
624 ctx->ticker.tickerCallback = ticker->tickerCallback;
625 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
626 ctx->ticker.tickerValue = ticker->tickerValue;
627 }
628
629 ctx->menuListContext.list.nbChoices = list->nbChoices;
630 ctx->menuListContext.list.selectedChoice = list->selectedChoice;
631 ctx->menuListContext.list.callback = list->callback;
632 ctx->menuListContext.selectedCallback = onActionCallback;
633
634 displayMenuList(ctx);
635
636 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawMenuList(): step = %p\n", ctx);
637
638 return (nbgl_step_t) ctx;
639}
640
648{
649 StepContext_t *ctx = (StepContext_t *) step;
650 if (!ctx) {
651 return 0;
652 }
653 return (ctx->menuListContext.list.selectedChoice);
654}
655
669 nbgl_stepButtonCallback_t onActionCallback,
671 nbgl_layoutSwitch_t *switchInfo,
672 bool modal)
673{
674 nbgl_layoutDescription_t layoutDescription
675 = {.modal = modal, .onActionCallback = (nbgl_layoutButtonCallback_t) actionCallback};
676 nbgl_layoutNavigation_t navInfo = {
678 };
679 StepContext_t *ctx = getFreeContext(CENTERED_INFO_STEP, modal);
680 if (!ctx) {
681 return NULL;
682 }
683
684 // initialize context (already set to 0 by getFreeContext())
685 ctx->textContext.onActionCallback = onActionCallback;
686 if (ticker) {
687 ctx->ticker.tickerCallback = ticker->tickerCallback;
688 ctx->ticker.tickerIntervale = ticker->tickerIntervale;
689 ctx->ticker.tickerValue = ticker->tickerValue;
690 layoutDescription.ticker.tickerCallback = ticker->tickerCallback;
691 layoutDescription.ticker.tickerIntervale = ticker->tickerIntervale;
692 layoutDescription.ticker.tickerValue = ticker->tickerValue;
693 }
694
695 ctx->textContext.nbPages = 1;
696 // keep only direction part of position
697 ctx->textContext.pos = pos & (RIGHT_ARROW | LEFT_ARROW);
698 navInfo.indication = getNavigationInfo(
699 ctx->textContext.pos, ctx->textContext.nbPages, ctx->textContext.currentPage);
700
701 ctx->layout = nbgl_layoutGet(&layoutDescription);
702 nbgl_layoutAddSwitch(ctx->layout, switchInfo);
703 if (navInfo.indication != NO_ARROWS) {
704 nbgl_layoutAddNavigation(ctx->layout, &navInfo);
705 }
706 nbgl_layoutDraw(ctx->layout);
707 nbgl_refresh();
708
709 LOG_DEBUG(STEP_LOGGER, "nbgl_stepDrawSwitch(): ctx = %p\n", ctx);
710 return (nbgl_step_t) ctx;
711}
712
720{
721 StepContext_t *ctx = (StepContext_t *) step;
722 int ret;
723
724 LOG_DEBUG(STEP_LOGGER, "nbgl_stepRelease(): ctx = %p\n", ctx);
725 if (!ctx) {
726 return -1;
727 }
728 ret = nbgl_layoutRelease((nbgl_layout_t *) ctx->layout);
729
730 ctx->layout = NULL;
731
732 return ret;
733}
734
735#endif // NBGL_STEP
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
debug traces management
#define LOG_WARN(__logger,...)
Definition nbgl_debug.h:87
#define LOG_DEBUG(__logger,...)
Definition nbgl_debug.h:86
#define LOG_FATAL(__logger,...)
Definition nbgl_debug.h:88
@ STEP_LOGGER
Definition nbgl_debug.h:40
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
compute the number of pages of nbLinesPerPage lines per page of the given text fitting in the given m...
Definition nbgl_fonts.c:875
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
compute the len of the given text (in bytes) fitting in the given maximum nb lines,...
Definition nbgl_fonts.c:562
@ BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
Definition nbgl_fonts.h:145
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
Definition nbgl_fonts.h:143
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
Create a reduced version of given ASCII text to wrap it on the given max width (in pixels),...
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
compute the number of lines of the given text fitting in the given maxWidth
Definition nbgl_fonts.c:721
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
return the height in pixels of the line of font with the given font ID
Definition nbgl_fonts.c:400
#define NB_MAX_LINES
Definition nbgl_layout.h:88
@ VERTICAL_NAV
'\/' and '/\' are displayed, to navigate in a list (vertical scrolling)
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subText)
Creates an area with given text (in bold) and sub text (in regular)
nbgl_layoutNavIndication_t
possible styles for Navigation arrows (it's a bit field)
@ NO_ARROWS
@ LEFT_ARROW
left arrow is used
@ RIGHT_ARROW
right arrow is used
int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
Creates an area on the center of the main panel, with a possible icon/image, a possible text in black...
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
#define AVAILABLE_WIDTH
Definition nbgl_layout.h:86
void * nbgl_layout_t
type shared externally
int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switchLayout)
Creates a switch with the given text and its state.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
void(* nbgl_layoutButtonCallback_t)(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
void nbgl_refresh(void)
This functions refreshes the actual screen on display with what has changed since the last refresh.
Definition nbgl_obj.c:1650
nbgl_buttonEvent_t
Definition nbgl_obj.h:207
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
Definition nbgl_obj.h:214
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
Definition nbgl_obj.h:208
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
Definition nbgl_obj.h:209
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
Step construction API of NBGL.
void(* nbgl_stepButtonCallback_t)(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
Definition nbgl_step.h:57
uint8_t nbgl_stepGetMenuListCurrent(nbgl_step_t step)
nbgl_step_t nbgl_stepDrawSwitch(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutSwitch_t *switchInfo, bool modal)
void * nbgl_step_t
type shared externally
Definition nbgl_step.h:44
uint8_t nbgl_stepPosition_t
this type contains nbgl_layoutNavIndication_t in its LSBs and direction in its MSB (using FORWARD_DIR...
Definition nbgl_step.h:80
@ NEITHER_FIRST_NOR_LAST_STEP
neither first nor last in a multiple steps flow
Definition nbgl_step.h:67
@ LAST_STEP
last in a multiple steps flow
Definition nbgl_step.h:66
@ FIRST_STEP
first in a multiple steps flow
Definition nbgl_step.h:65
nbgl_step_t nbgl_stepDrawMenuList(nbgl_stepMenuListCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutMenuList_t *list, bool modal)
int nbgl_stepRelease(nbgl_step_t step)
void(* nbgl_stepMenuListCallback_t)(uint8_t choiceIndex)
prototype of chosen menu list item callback
Definition nbgl_step.h:50
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal)
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
#define BACKWARD_DIRECTION
Definition nbgl_step.h:73
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.
This structure contains info to build a centered (vertically and horizontally) area,...
This structure contains info to build a switch (on the right) with a description (on the left),...
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_screenTickerConfiguration_t ticker
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains a list of names to build a menu list on Nanos, with for each item a descripti...
nbgl_menuListCallback_t callback
function to call to retrieve a menu list item text
uint8_t nbChoices
total number of choices in the menu list
uint8_t selectedChoice
index of the selected choice (centered, in bold)
This structure contains info to build a navigation bar at the bottom of the screen.
nbgl_layoutNavDirection_t direction
vertical or horizontal navigation
nbgl_layoutNavIndication_t indication
specifies which arrows to use (left or right)
unsigned short uint16_t
Definition usbd_conf.h:54
unsigned char uint8_t
Definition usbd_conf.h:53
BOLOS_UX_LOC_STRINGS UX_LOC_STRINGS_INDEX