28#define BACKSPACE_KEY_INDEX      26 
   29#define VALIDATE_INDEX           27 
   30#define SHIFT_KEY_INDEX          28 
   31#define LETTER_TO_DIGITS_OFFSET  (sizeof(keysByMode[DIGITS_AND_SPECIALS]) - 29) 
   32#define GET_CHAR(mode, char_idx) ((const char *) PIC(screen_keyboard_keys_by_mode[mode]))[char_idx] 
   50const char *
const keysByMode[] = {
 
   52    "abcdefghijklmnopqrstuvwxyz\b\n\r",
 
   53    "ABCDEFGHIJKLMNOPQRSTUVWXYZ\b\n\r",
 
   54    "0123456789 '\"`&/?!:;.,~*$=+-[](){}^<>\\_#@|%\b\n\r",
 
   65    &C_icon_lowercase_invert,
 
   66    &C_icon_uppercase_invert,
 
   67    &C_icon_digits_invert,
 
   68    &C_icon_backspace_invert,
 
   69    &C_icon_validate_invert,
 
   70    &C_icon_classes_invert,
 
   87static void keyboardDrawIcon(int16_t x0, int8_t y0, 
bool inverted, 
const nbgl_icon_details_t *icon)
 
   91    rectArea.backgroundColor = inverted ? 
WHITE : 
BLACK;
 
   92    rectArea.width           = icon->width;
 
   93    rectArea.height          = icon->height;
 
   96    rectArea.x0 = x0 + (KEYBOARD_KEY_WIDTH - icon->width) / 2;
 
   97    rectArea.y0 = y0 + (KEYBOARD_KEY_HEIGHT - icon->height) / 2;
 
  101static void keyboardDrawChar(int16_t x0, int8_t y0, 
bool inverted, 
const char *charPtr)
 
  105    rectArea.backgroundColor = inverted ? 
WHITE : 
BLACK;
 
  107    rectArea.height          = 12;
 
  110    rectArea.x0 = x0 + (KEYBOARD_KEY_WIDTH - rectArea.width) / 2;
 
  111    rectArea.y0 = y0 + (KEYBOARD_KEY_HEIGHT - rectArea.height) / 2 - 3;
 
  121    rectArea.backgroundColor = 
BLACK;
 
  122    rectArea.x0              = keyboard->obj.area.x0;
 
  123    rectArea.y0              = keyboard->obj.area.y0;
 
  124    rectArea.width           = keyboard->obj.area.width;
 
  125    rectArea.height          = keyboard->obj.area.height;
 
  129    rectArea.x0     = keyboard->obj.area.x0 + 2 * KEYBOARD_KEY_WIDTH;
 
  130    rectArea.y0     = keyboard->obj.area.y0;
 
  131    rectArea.width  = KEYBOARD_KEY_WIDTH;
 
  132    rectArea.height = keyboard->obj.area.height;
 
  136    rectArea.backgroundColor = 
WHITE;
 
  137    rectArea.x0              = keyboard->obj.area.x0 + KEYBOARD_KEY_WIDTH + 5;
 
  138    rectArea.y0              = keyboard->obj.area.y0 + 6;
 
  142    rectArea.x0 = keyboard->obj.area.x0 + 3 * KEYBOARD_KEY_WIDTH + 5;
 
  150    const char *keys = keysByMode[keyboard->mode];
 
  152    if (keyboard->keyMask == 0x07FFFFFF) {
 
  156    keyboardDrawCommon(keyboard);
 
  159    while (keyboard->keyMask & (1 << keyboard->selectedCharIndex)) {
 
  161            keyboard->selectedCharIndex++;
 
  164            keyboard->selectedCharIndex = 0;
 
  170    i         = keyboard->selectedCharIndex;
 
  173        if ((keyboard->keyMask & (1 << i)) == 0) {
 
  175                keyboardDrawIcon(keyboard->obj.area.x0 + 2 * j * KEYBOARD_KEY_WIDTH,
 
  176                                 keyboard->obj.area.y0,
 
  181                keyboardDrawChar(keyboard->obj.area.x0 + 2 * j * KEYBOARD_KEY_WIDTH,
 
  182                                 keyboard->obj.area.y0,
 
  191        if (i == keyboard->selectedCharIndex) {
 
  196    i = (keyboard->selectedCharIndex + 26) % 27;
 
  198        if ((keyboard->keyMask & (1 << i)) == 0) {
 
  201                    keyboard->obj.area.x0, keyboard->obj.area.y0, 
false, &C_icon_backspace);
 
  204                keyboardDrawChar(keyboard->obj.area.x0, keyboard->obj.area.y0, 
false, &keys[i]);
 
  215        if (i == (keyboard->selectedCharIndex + 26) % 27) {
 
  226    keyboardDrawCommon(keyboard);
 
  230    if (keyboard->mode == MODE_NONE) {
 
  231        for (i = 0; i < 3; i++) {
 
  232            uint8_t charIndex = (keyboard->selectedCharIndex + 2 + i) % 3;
 
  233            keyboardDrawIcon(keyboard->obj.area.x0 + 2 * i * KEYBOARD_KEY_WIDTH,
 
  234                             keyboard->obj.area.y0,
 
  236                             modeIcons[charIndex]);
 
  242    if ((keyboard->keyMask & 0x1FFFFFFF) == 0x1FFFFFFF) {
 
  246    const char *keys          = keysByMode[keyboard->mode];
 
  247    uint8_t     maxLen        = strlen(keys);
 
  248    char        keysToDraw[3] = {0};
 
  252    uint8_t charIndex = keyboard->selectedCharIndex;
 
  253    for (i = 1; i < 3; i++) {
 
  254        while (keyboard->keyMask & (1 << charIndex)) {
 
  258        keysToDraw[i] = keys[charIndex];
 
  263    charIndex = (keyboard->selectedCharIndex + maxLen - 1) % maxLen;
 
  264    while (keyboard->keyMask & (1 << charIndex)) {
 
  269            charIndex = maxLen - 1;
 
  272    keysToDraw[0] = keys[charIndex];
 
  275    for (i = 0; i < 3; i++) {
 
  276        if (keysToDraw[i] == 
'\r') {
 
  277            keyboardDrawIcon(keyboard->obj.area.x0 + 2 * i * KEYBOARD_KEY_WIDTH,
 
  278                             keyboard->obj.area.y0,
 
  282        else if (keysToDraw[i] == 
'\n') {
 
  283            keyboardDrawIcon(keyboard->obj.area.x0 + 2 * i * KEYBOARD_KEY_WIDTH,
 
  284                             keyboard->obj.area.y0,
 
  286                             &C_icon_validate_10);
 
  288        else if (keysToDraw[i] == 
'\b') {
 
  289            keyboardDrawIcon(keyboard->obj.area.x0 + 2 * i * KEYBOARD_KEY_WIDTH,
 
  290                             keyboard->obj.area.y0,
 
  294        else if (keysToDraw[i] != 0) {
 
  295            keyboardDrawChar(keyboard->obj.area.x0 + 2 * i * KEYBOARD_KEY_WIDTH,
 
  296                             keyboard->obj.area.y0,
 
  321    if (keyboard->mode == MODE_NONE) {
 
  325        if (keyboard->lettersOnly) {
 
  329            nbMax = strlen(keysByMode[keyboard->mode]) - 1;
 
  333        if (keyboard->mode == MODE_NONE) {
 
  335            keyboard->mode = keyboard->selectedCharIndex;
 
  337            keyboard->selectedCharIndex = 0;
 
  340            if (keyboard->lettersOnly) {
 
  341                if ((keyboard->selectedCharIndex < 26)
 
  342                    && ((keyboard->keyMask & (1 << keyboard->selectedCharIndex)) == 0)) {
 
  343                    const char *keys = keysByMode[keyboard->mode];
 
  344                    keyboard->callback(keys[keyboard->selectedCharIndex]);
 
  351                char key = keysByMode[keyboard->mode][keyboard->selectedCharIndex];
 
  354                    keyboard->mode = MODE_NONE;
 
  356                    keyboard->selectedCharIndex = 0;
 
  360                else if (key == 
'\n') {
 
  363                else if (key == 
'\b') {
 
  367                    keyboard->callback(key);
 
  375            if (keyboard->selectedCharIndex > 0) {
 
  376                keyboard->selectedCharIndex--;
 
  379                keyboard->selectedCharIndex = nbMax;
 
  381        } 
while ((keyboard->mode != MODE_NONE)
 
  382                 && (keyboard->keyMask & (1 << keyboard->selectedCharIndex)));
 
  386            if (keyboard->selectedCharIndex < nbMax) {
 
  387                keyboard->selectedCharIndex++;
 
  390                keyboard->selectedCharIndex = 0;
 
  392        } 
while ((keyboard->mode != MODE_NONE)
 
  393                 && (keyboard->keyMask & (1 << keyboard->selectedCharIndex)));
 
  409    if (kbd->lettersOnly) {
 
  410        keyboardDrawLettersOnly(kbd);
 
  413        keyboardDrawRegular(kbd);
 
#define LOG_DEBUG(__logger,...)
 
Middle Level API of the new BOLOS Graphical Library.
 
void nbgl_drawIcon(nbgl_area_t *area, nbgl_transformation_t transformation, nbgl_color_map_t color_map, const nbgl_icon_details_t *icon)
Helper function to render an icon directly from its nbgl_icon_details_t structure.
 
nbgl_font_id_e nbgl_drawText(const nbgl_area_t *area, const char *text, uint16_t textLen, nbgl_font_id_e fontId, color_t fontColor)
This function draws the given single-line text, with the given parameters.
 
void nbgl_drawRoundedRect(const nbgl_area_t *area, nbgl_radius_t radius, color_t innerColor)
This functions draws a rounded corners rectangle (without border), with the given parameters.
 
uint8_t nbgl_getCharWidth(nbgl_font_id_e fontId, const char *text)
return the width in pixels of the given UTF-8 character
 
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
 
Font screen low-Level driver API, to draw elementary forms.
 
void nbgl_frontDrawRect(const nbgl_area_t *area)
 
API to draw all basic graphic objects.
 
#define BACKSPACE_KEY_INDEX
 
void nbgl_objDraw(nbgl_obj_t *obj)
This function draws or redraws the given object and its children (recursive version)
 
void nbgl_refresh(void)
This functions refreshes the actual screen on display with what has changed since the last refresh.
 
struct PACKED__ nbgl_keyboard_s nbgl_keyboard_t
struct to represent a keyboard (KEYBOARD type)
 
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
 
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
 
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
 
void nbgl_objDrawKeyboard(nbgl_keyboard_t *kbd)
This function draws a keyboard object.
 
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
 
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
 
#define NO_TRANSFORMATION
 
@ NBGL_BPP_1
1 bit per pixel
 
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.