27 #define FIRST_LINE_CHAR_COUNT 10
28 #define SECOND_LINE_CHAR_COUNT 9
30 #if (SCREEN_WIDTH == 400)
31 #define NORMAL_KEY_WIDTH 40
32 #define LETTER_OFFSET_Y (((KEYBOARD_KEY_HEIGHT - 32) / 2) & 0xFFC)
34 #define NORMAL_KEY_WIDTH 48
35 #define LETTER_OFFSET_Y (((KEYBOARD_KEY_HEIGHT - 36) / 2) & 0xFFC)
37 #define SHIFT_KEY_WIDTH (NORMAL_KEY_WIDTH + SECOND_LINE_OFFSET)
38 #define SECOND_LINE_OFFSET ((SCREEN_WIDTH - (SECOND_LINE_CHAR_COUNT * NORMAL_KEY_WIDTH)) / 2)
40 #define SPACE_KEY_WIDTH 276
42 #define SPACE_KEY_WIDTH 336
44 #define SWITCH_KEY_WIDTH (SCREEN_WIDTH - SPACE_KEY_WIDTH)
45 #define SPECIAL_CHARS_KEY_WIDTH (NORMAL_KEY_WIDTH * 2 + SECOND_LINE_OFFSET)
46 #define BACKSPACE_KEY_WIDTH_FULL SHIFT_KEY_WIDTH
47 #define BACKSPACE_KEY_WIDTH_DIGITS SPECIAL_CHARS_KEY_WIDTH
48 #define BACKSPACE_KEY_WIDTH_LETTERS_ONLY (SCREEN_WIDTH - 7 * NORMAL_KEY_WIDTH)
50 #define IS_KEY_MASKED(_index) (keyboard->keyMask & (1 << _index))
63 static const char kbd_chars[] =
"qwertyuiopasdfghjklzxcvbnm";
64 static const char kbd_chars_upper[] =
"QWERTYUIOPASDFGHJKLZXCVBNM";
66 static const char kbd_specials[] =
"[]{}#%^*+=_\\|~<>$`\".,?!\'";
94 if (!keyboard->lettersOnly) {
147 rectArea.backgroundColor = keyboard->obj.area.backgroundColor;
148 rectArea.x0 = keyboard->obj.area.x0;
149 rectArea.y0 = keyboard->obj.area.y0;
150 rectArea.width = keyboard->obj.area.width;
151 rectArea.height = keyboard->obj.area.height;
155 rectArea.backgroundColor = keyboard->obj.area.backgroundColor;
156 rectArea.x0 = keyboard->obj.area.x0;
157 rectArea.y0 = keyboard->obj.area.y0;
158 rectArea.width = keyboard->obj.area.width;
166 if ((keyboard->obj.alignmentMarginY > 0) || (!keyboard->lettersOnly)) {
171 if ((keyboard->obj.alignmentMarginY > 0) && (!keyboard->lettersOnly)) {
176 rectArea.backgroundColor = keyboard->borderColor;
177 rectArea.x0 = keyboard->obj.area.x0;
178 rectArea.y0 = keyboard->obj.area.y0;
181 if (!keyboard->lettersOnly) {
194 keyboardDrawCommonLines(keyboard);
197 rectArea.backgroundColor = keyboard->borderColor;
198 rectArea.x0 = keyboard->obj.area.x0;
199 rectArea.y0 = keyboard->obj.area.y0;
203 for (i = 0; i < 9; i++) {
212 for (i = 10; i < 19; i++) {
219 if (!keyboard->lettersOnly) {
225 for (i = 0; i < 6; i++) {
229 if (!keyboard->lettersOnly) {
236 if (!keyboard->lettersOnly) {
250 keyboardDrawCommonLines(keyboard);
253 rectArea.backgroundColor = keyboard->borderColor;
254 rectArea.x0 = keyboard->obj.area.x0;
255 rectArea.y0 = keyboard->obj.area.y0;
259 for (i = 0; i < 9; i++) {
268 for (i = 10; i < 19; i++) {
276 for (i = 0; i < 5; i++) {
295 keys = kbd_chars_upper;
301 rectArea.backgroundColor = keyboard->obj.area.backgroundColor;
305 rectArea.x0 = keyboard->obj.area.x0;
308 for (i = 0; i < 10; i++) {
318 for (i = 10; i < 19; i++) {
328 if (!keyboard->lettersOnly) {
353 rectArea.backgroundColor =
WHITE;
363 rectArea.backgroundColor =
WHITE;
371 for (i = 19; i < 26; i++) {
386 if (!keyboard->lettersOnly) {
398 if (!keyboard->lettersOnly) {
404 SMALL_REGULAR_1BPP_FONT,
429 rectArea.backgroundColor = keyboard->obj.area.backgroundColor;
433 rectArea.x0 = keyboard->obj.area.x0;
436 for (i = 0; i < 10; i++) {
445 for (i = 10; i < 19; i++) {
468 for (i = 19; i < 24; i++) {
501 keyboardDrawLetterGrid(keyboard);
504 keyboardDrawLetters(keyboard);
508 keyboardDrawDigitsGrid(keyboard);
511 keyboardDrawDigits(keyboard);
540 firstPosition->
x -= obj->area.x0;
541 firstPosition->
y -= obj->area.y0;
542 lastPosition->
x -= obj->area.x0;
543 lastPosition->
y -= obj->area.y0;
545 firstIndex = getKeyboardIndex(keyboard, firstPosition);
549 lastIndex = getKeyboardIndex(keyboard, lastPosition);
554 if (lastIndex != firstIndex) {
566 keyboard->needsRefresh =
true;
568 if ((firstIndex < 26) && ((
IS_KEY_MASKED(firstIndex)) == 0)) {
569 keyboard->callback((cur_casing !=
LOWER_CASE) ? kbd_chars_upper[firstIndex]
570 : kbd_chars[firstIndex]);
573 switch (keyboard->casing) {
595 if (firstIndex < 26) {
611 if (firstIndex < 26) {
612 keyboard->callback(kbd_specials[firstIndex]);
630 keyboard->callback(
' ');
648 while (charIndex < 26) {
649 if (index == kbd_chars[charIndex]) {
658 *y = kbd->obj.area.y0;
665 else if (charIndex <
sizeof(kbd_chars)) {
667 *x = kbd->obj.area.x0
670 if (!kbd->lettersOnly) {
675 *x = kbd->obj.area.x0
694 kbd->obj.touchMask = (1 <<
TOUCHED);
696 kbd->needsRefresh =
false;
703 touch_exclude_borders(0);
#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.
uint8_t nbgl_getCharWidth(nbgl_font_id_e fontId, const char *text)
return the width in pixels of the given UTF-8 character
uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text)
return the max width in pixels of the given text (can be multiline)
Font screen low-Level driver API, to draw elementary forms.
void nbgl_frontDrawHorizontalLine(const nbgl_area_t *area, uint8_t mask, color_t lineColor)
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)
#define SHIFT_LOCKED_ICON
keyboardCase_t
Letters casing in which to open/set the keyboard.
@ LOCKED_UPPER_CASE
locked upper case mode
@ LOWER_CASE
lower case mode
@ UPPER_CASE
upper case mode for one character
struct PACKED__ nbgl_keyboard_s nbgl_keyboard_t
struct to represent a keyboard (KEYBOARD type)
#define DIGITS_SWITCH_KEY_INDEX
@ MODE_SPECIAL
extended special characters mode
@ MODE_DIGITS
digits and some special characters mode
@ MODE_LETTERS
letters mode
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
#define KEYBOARD_KEY_HEIGHT
#define SPECIAL_KEYS_INDEX
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
#define BACKSPACE_KEY_WIDTH_LETTERS_ONLY
void nbgl_keyboardTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
function to be called when the keyboard object is touched
#define BACKSPACE_KEY_WIDTH_DIGITS
bool nbgl_keyboardGetPosition(nbgl_keyboard_t *kbd, char index, uint16_t *x, uint16_t *y)
This function gets the position (top-left corner) of the key at the given index. (to be used for Test...
#define SECOND_LINE_OFFSET
void nbgl_objDrawKeyboard(nbgl_keyboard_t *kbd)
This function draws a keyboard object.
#define SPECIAL_CHARS_KEY_WIDTH
#define FIRST_LINE_CHAR_COUNT
#define BACKSPACE_KEY_WIDTH_FULL
#define SECOND_LINE_CHAR_COUNT
#define IS_KEY_MASKED(_index)
bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, nbgl_touchStatePosition_t **firstPos, nbgl_touchStatePosition_t **lastPos)
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
nbgl_touchType_t
The different types of Touchscreen events.
#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.
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ FULL_COLOR_REFRESH
to be used for normal refresh
The low level Touchscreen event, coming from driver.
int16_t y
vertical position of the touch (or for a RELEASED the last touched point)
int16_t x
horizontal position of the touch (or for a RELEASED the last touched point)