|
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 centered info or a set of navigation arrows.
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 centered info or a set of navigation arrows.
Moreover, positions of objects in the page are mostly hidden and automatic.

In this example, 2 "objects" are used and added to the page with dedicated APIs:
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:
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.

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 fonts for the texts depends of the style field used in nbgl_layoutCenteredInfo_t.

or

This object is made of:
The arrows are centered vertically in the page
There are two styles for the arrows:
The API to insert such an object is nbgl_layoutAddNavigation(), using nbgl_layoutNavigation_t structure
The "direction" and the number of arrows (left, right or both) to use are set in nbgl_layoutNavigation_t.

On screen, the visible part of his object is made of up to 5 menu item elements (single line, centered horizontally)
The first and last of the 5 lines are only partially visible (horizontal cut)
The API to insert such an object is nbgl_layoutAddMenuList(), using nbgl_layoutMenuList_t structure, which enables to configure:
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).
Here is an 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, in the center of screen (with a margin), proposes a rotating keyboard, displaying 3 letters at max, (from 'a' to 'z' in letters-only).
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 an existing keyboard.
This object, displayed under the keyboard consists in a set of 9 placeholders representing the text entered with the keyboard.
If text is too long to be displayed (more than 8 characters), the beginning is replaced by ".."
The only parameter to configure this object is:
The API to insert such an object is nbgl_layoutAddEnteredText().
This function returns a positive integer (if successful) to be used as an index in nbgl_layoutUpdateEnteredText() function, used to modify the text.
Here is the source code to display the example:
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 is made of an area at the bottom of the screen, presenting the 10 digits, a backspace and a validate keys, that can be navigated with left and right buttons and selected with both buttons. And a title at the top of the screen.
The only parameters to configure this object (at creation time) 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 active keys of an existing keypad (backspace and validate keys).
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 can be interacted with thanks to the buttons.
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.