|
Embedded SDK
Embedded SDK
|
This chapter describes briefly the mid level API of Advanced BOLOS Graphic Library.
This layer offers a simplified view of a screen page, using complex (aggregated) objects, like a radio buttons choice or touchable areas.
A full description of each functions/types can be found in this document
This layer uses the low-level API described in Advanced BOLOS GL API, but all graphic objects are hidden, in favor to abstract complex objects like a radio buttons choice or touchable areas.
Moreover, positions of objects in the page are mostly hidden and automatic.

In this example, 3 "objects" are used and added to the page with dedicated APIs:

In this more complex example, a "tapable" container is used for the whole screen, except the footer area and the progress indicator.
In the "tapable" container, 2 objects are drawn, a single pair of tag/value, and a "more" button to execute an action.
The first operation is always to get a new layout, with the desired parameters:
The function to actually create the layout is nbgl_layoutGet()
For example 1:
For example 2:
Once defined and populated, all objects can be drawn in framebuffer with a simple call to nbgl_layoutDraw().
Once the layout is defined and retrieved with nbgl_layoutGet(), the page can be filled with complex objects.
If a "tapable" container is used, most objects will be added in it, except the ones on top (progress indicator or top-right button) or on bottom (navigation bar or bottom button). Otherwise objects are all added in the whole page.

This object is made of a single round button, on top right of the screen.
The only properties of this object are
The API to insert such an object is nbgl_layoutAddTopRightButton()

This object is made of a single round button, on middle bottom of the screen.
The only properties of this object are:
The API to insert such an object is nbgl_layoutAddBottomButton().
Optionally, a thin horizontal separation can be drawn on top of the button, if separationLine parameter of nbgl_layoutAddBottomButton() is true.

This object acts as a full width text area at the bottom of the screen.
The only properties of this object are:
The API to insert such an object is nbgl_layoutAddFooter().
A thin horizontal separation is drawn on top of the text area.

This object acts as a two horizontally adjacent touchable text areas at the bottom of the screen.
The properties of this object are:
The API to insert such an object is nbgl_layoutAddSplitFooter().
A thin horizontal separation is drawn on top of the text areas. A thin vertical separation is drawn between both text areas.
This object is a richly-configurable footer placed at the very bottom of the screen, outside the main container. It is a superset of nbgl_layoutAddFooter() and nbgl_layoutAddSplitFooter() and covers all nbgl_layoutFooterType_t variants:
The API to insert such an object is nbgl_layoutAddExtendedFooter(), using nbgl_layoutFooter_t structure.
A thin horizontal separation line can optionally be added on top by setting the separationLine field to true.
This object places a control area immediately above the footer (or above the bottom of the main container when no footer is present). It is not part of the main container. It covers all nbgl_layoutUpFooterType_t variants:
The API to insert such an object is nbgl_layoutAddUpFooter(), using nbgl_layoutUpFooter_t structure.
This object places a classic bottom navigation bar at the very bottom of the screen, outside the main container. It provides optional back and forward arrow buttons as well as an optional exit key. It is a convenience wrapper around nbgl_layoutAddExtendedFooter() with type FOOTER_NAV, and is the lower-level alternative to the navigation embedded in nbgl_layoutAddExtendedFooter().
The parameters of nbgl_layoutNavigationBar_t include:
The API to insert such an object is nbgl_layoutAddNavigationBar(), using nbgl_layoutNavigationBar_t structure.

This object is made of:
The whole object is centered horizontally in the page
It can be either centered vertically or put on top of the page.
The API to insert such an object is nbgl_layoutAddCenteredInfo(), using nbgl_layoutCenteredInfo_t structure
The colors and fonts for the texts depends of the style field used in nbgl_layoutCenteredInfo_t.
This object is a richer alternative to the Centered info area area. It uses the nbgl_contentCenter_t structure and supports more illustration types (icon, image, Lottie animation) as well as an optional small title, a description text, and a sub-text.
The fields of nbgl_contentCenter_t include:
The whole object is centered horizontally in the page.
The API to insert such an object is nbgl_layoutAddContentCenter(), using nbgl_contentCenter_t structure.
This object displays a bold title followed by a list of rows, each row made of an icon and a text, all left-aligned.
The fields of nbgl_layoutLeftContent_t include:
The API to insert such an object is nbgl_layoutAddLeftContent(), using nbgl_layoutLeftContent_t structure.


This object is made of 2 buttons, aligned vertically, each containing a text.
They are put at the bottom of the main container, on top of a potential navigation bar or bottom button.
Regarding colors, Top-button (index 0 in callback) is painted in BLACK and is on top of Bottom-buttom (index 1 in callback)
If the style field is ROUNDED_AND_FOOTER_STYLE, Bottom-button is painted in WHITE, without border.
If the style field is BOTH_ROUNDED_STYLE, Bottom-button is painted in WHITE, with border.
The API to insert such an object is nbgl_layoutAddChoiceButtons(), with nbgl_layoutChoiceButtons_t structure

This object is made of a single button, in BLACK. The text and optional icon are in WHITE
This button occupies the full width of the screen, except if fittingContent field of nbgl_layoutButton_t is true, and is put at the bottom of the main container, on top of a potential navigation bar or bottom button.
The API to insert such an object is nbgl_layoutAddButton(), with nbgl_layoutButton_t structure.

This object is made of an area containing a progress-bar (empty at the initialization), a text describing the action, and a fake round BLACK button
The whole area is touchable and as long as touched, the progress-bar will be automatically updated. After 3s, the long-press button is considered as "touched", and the action callback is called with the given token.
This button occupies the full width of the screen and is put at the bottom of the main container, on top of a potential navigation bar or bottom button.
The API to insert such an object is nbgl_layoutAddLongPressButton(), with the button text and token as parameters.
This object places a small round icon-only button on the left and a full text button on the right, both on the same horizontal line. It is implemented internally via nbgl_layoutAddUpFooter() with type UP_FOOTER_HORIZONTAL_BUTTONS.
The fields of nbgl_layoutHorizontalButtons_t include:
The API to insert such an object is nbgl_layoutAddHorizontalButtons(), using nbgl_layoutHorizontalButtons_t structure.

A touchable icon can also be added on right of value:

The parameters to draw such an item are:
This area is displayed in the main container, under the previously inserted complex object.
The API to insert such an object is nbgl_layoutAddTagValueList(), with nbgl_layoutTagValueList_t structure
This object adds a text area with an optional sub-text below it. Both texts are left-aligned and auto-wrap. The main text uses a small bold font; the sub-text uses a small regular font.
The API to insert such an object is nbgl_layoutAddText(), which takes the main text and an optional subText as parameters.
This object is similar to the Text block but adds a small chevron icon (>) on the right of the main text, making the entire row touchable. When touched, the provided token is reported to the action callback together with the given index.
The API to insert such an object is nbgl_layoutAddTextWithAlias().
This object adds a single multi-line text displayed in a large (32 px) font, left-aligned and auto-wrapping. The text is rendered in BLACK by default; if the grayedOut parameter is true, it is rendered in light gray instead.
The API to insert such an object is nbgl_layoutAddLargeCaseText().
This object adds a composite block that can contain up to three layers of text, all left-aligned:
The fields of nbgl_layoutTextContent_t include:
The API to insert such an object is nbgl_layoutAddTextContent(), using nbgl_layoutTextContent_t structure.
This object adds a thin horizontal line directly below the previously inserted object in the main container. It can be used to visually separate groups of items.
The API to insert such an object is nbgl_layoutAddSeparationLine().

This horizontal bar object is made of:
Some extra fields in nbgl_layoutBar_t, enable to:
This area is displayed in the main container, under the previously inserted complex object.
If leftIcon and rightIcon fields are NULL, the bar is considered as a title.
When touched, if not inactivated, the token provided in nbgl_layoutBar_t is used with the action callback. index parameter is not relevant.
The API to insert such an object is nbgl_layoutAddTouchableBar(), with nbgl_layoutBar_t structure

This object is made of:
This area is displayed in the main container, under the previously inserted complex object.
When touched, if not inactivated, the token provided in nbgl_layoutSwitch_t is used with the action callback. index parameter meaning is 0 for inactive, 1 for active.
The API to insert such an object is nbgl_layoutAddSwitch(), with nbgl_layoutSwitch_t structure

This object is made of a vertical list of nbChoices items made of:
One and only one button is active at the same time in a single object.
Each line of choice is separated from the previous one by a thin horizontal sepatation line.
The active button at start-up is given in initChoice field of nbgl_layoutRadioChoice_t.
This area is displayed in the main container, under the previously inserted complex object.
The API to insert such an object is nbgl_layoutAddRadioChoice(), with nbgl_layoutRadioChoice_t structure

This object is a simple centered "Ledger" logo in LIGHT_GRAY, with one of the corner in BLACK, to emulate a spinner, with an explanation text under the spinner
The spinner "rotating" corner will automatically be updated every 800 ms.
The API to insert such an object is nbgl_layoutAddSpinner().

This object, drawned in top of the screen, is essentially made of a discrete page progress bar (slashes or digits). An optional "back" button, symbolized with a left arrow, can also be drawned on the left of the page progress.
The parameters to build this object are:
Digits are represented instead of slashes if the number of pages exceeds 10. In this case, instead of marking the active page as a slash in BLACK, the page indicator will indicate *"<current_page> of <total_nb_pages>"*
The API to insert such an object is nbgl_layoutAddProgressIndicator().
This object adds a centered progress bar with a percentage completion, a title text above it, and an optional sub-text below it. It is distinct from the deprecated Progress indicator.
The parameters of nbgl_layoutAddProgressBar() are:
The API to insert such an object is nbgl_layoutAddProgressBar().

This object, centered in the main container, is made of a dynamically drawned QR Code (not a picture) and description texts under it.
The parameters to build this object are:
The API to insert such an object is nbgl_layoutAddQRCode(), with nbgl_layoutQRCode_t structure as parameter.
This object registers a swipe gesture on the main container. When the user swipes in one of the enabled directions (described by the swipesMask bitmask), the action callback is called with the given token.
An optional gray label text can be displayed at the bottom of the container (e.g. "Swipe to continue") by providing a non-NULL text parameter.
The parameters of nbgl_layoutAddSwipe() are:
The API to register such a gesture is nbgl_layoutAddSwipe().
This utility inverts the page background from white to black (dark mode). Any "Tap to continue" text in the up-footer area is also adjusted for contrast.
The API to apply this inversion is nbgl_layoutInvertBackground().
Some rare screens require displaying a keyboard at the bottom of the page, to enter text.
The text to enter may be a generic string or a word (for example BIP39). In the first case, a simple confirmation button is also displayed in the screen. In the second case, usually suggestion buttons are displayed to avoid issues with unknown words and save time.
Here are some example of these pages in Bolos UX:

To build such screens, some dedicated APIs are necessary, which will be detailed in the sub-chapters.
This object, at the bottom of the main container (with a margin), proposes a Qwerty keyboard.
The parameters to configure this object are:
The API to insert such an object is nbgl_layoutAddKeyboard(), with nbgl_layoutKbd_t structure as parameter.
This function returns a positive integer (if successful) to be used as an index in nbgl_layoutUpdateKeyboard() function, used to modify the mask of an existing keyboard.
This container object, which is a complement to a keyboard consists in:
The buttons are all with black background and white text.
The parameters to configure this object (nbgl_layoutKeyboardContent_t structure) are:
The API to insert such an object is nbgl_layoutAddKeyboardContent().
This function returns a positive integer if successful. This object can be modified with nbgl_layoutUpdateKeyboardContent()

Here is the source code to display this first example:

Here is the source code to display this second example (with simulated transitions):
Some rare screens require displaying a keypad at the bottom of the page, to enter digits.
The digits to enter are usually a PIN code, to enter or to confirm.
Here are some example of these pages in Bolos UX:

To build such screens, some dedicated APIs are necessary, which will be detailed in the sub-chapters.
This object, at the bottom of the main container (with a margin), proposes a regular keypad, with 10 digits, a backspace and a validate keys.
The only parameters to configure this object are:
The API to insert such an object is nbgl_layoutAddKeypad().
This function returns a positive integer (if successful) to be used as an index in nbgl_layoutUpdateKeypad() function, used to modify the mask (active keys) of an existing keypad.
This object consists in:
The parameters to configure this object are:
The API to insert such an object is nbgl_layoutAddKeypadContent().
This function returns a positive integer (if successful).
The nbgl_layoutUpdateKeypadContent() function can be used to modify the number of entered digits or the digits.
After having drawn graphic objects in framebuffer, it is necessary to transfer the content of the framebuffer on display. This operation is called a refresh.
The API to do that is nbgl_refresh() (in nbgl_obj.h)
It will only refresh the rectangle part of the screen having changed (with objects redrawn) since the last refresh.
Some controls, like a touchable bar, or a choice by radio buttons, can be interacted with thanks to the Touchscreen.
The developer can subscribe to these events by providing an action callback in nbgl_layoutGet(), with nbgl_layoutTouchCallback_t prototype.
The first parameter (token) of this function is a token provided along with the definition of the complex object.
The second parameter (index) is only used for some types of complex objects:
Before leaving a screen built with a layout, it must be released with a call to nbgl_layoutRelease(). It will free the potentially allocated objects.