21 #include "os_io_seproxyhal.h"
28 #define DIGIT_HEIGHT 12
29 #define DIGIT_OFFSET_X 13
30 #define DIGIT_OFFSET_Y ((KEYPAD_HEIGHT - DIGIT_HEIGHT) / 2)
31 #define INIT_DIGIT_VALUE 5
57 static char positionToChar(
uint8_t pos)
66 return 0x30 + (pos - 1);
76 rectArea.backgroundColor =
BLACK;
77 rectArea.x0 = keypad->obj.area.x0;
78 rectArea.y0 = keypad->obj.area.y0;
79 rectArea.width = keypad->obj.area.width;
80 rectArea.height = keypad->obj.area.height;
83 rectArea.backgroundColor =
BLACK;
87 for (i = 0; i < 10; i++) {
88 rectArea.width = digits_icons[i]->width;
89 rectArea.height = digits_icons[i]->height;
91 rectArea.x0 = keypad->obj.area.x0 + DIGIT_OFFSET_X + i *
KEY_WIDTH;
95 if (keypad->enableBackspace) {
96 rectArea.width = C_icon_backspace.width;
97 rectArea.height = C_icon_backspace.height;
98 rectArea.x0 = keypad->obj.area.x0;
99 rectArea.y0 = keypad->obj.area.y0 + ((KEYPAD_HEIGHT - C_icon_backspace.height) / 2);
104 if (keypad->enableValidate) {
105 rectArea.width = C_digit_validate_bold.width;
106 rectArea.height = C_digit_validate_bold.height;
107 rectArea.x0 = keypad->obj.area.x0 + KEYPAD_WIDTH - C_digit_validate_bold.width;
108 rectArea.y0 = keypad->obj.area.y0 + ((KEYPAD_HEIGHT - C_digit_validate_bold.height) / 2);
117 rectArea.backgroundColor =
WHITE;
119 if (keypad->selectedKey == 0) {
120 rectArea.x0 = keypad->obj.area.x0;
122 else if (keypad->selectedKey < 11) {
123 rectArea.x0 = keypad->obj.area.x0 + DIGIT_OFFSET_X + (keypad->selectedKey - 1) *
KEY_WIDTH;
125 else if (keypad->selectedKey == 11) {
126 rectArea.x0 = keypad->obj.area.x0 + KEYPAD_WIDTH - C_digit_validate_bold.width;
131 rectArea.y0 = keypad->obj.area.y0 + keypad->obj.area.height - 2;
141 rectArea.backgroundColor =
WHITE;
143 if (keypad->selectedKey == 0) {
144 rectArea.x0 = keypad->obj.area.x0;
146 else if (keypad->selectedKey < 11) {
147 rectArea.x0 = keypad->obj.area.x0 + DIGIT_OFFSET_X + (keypad->selectedKey - 1) *
KEY_WIDTH;
149 else if (keypad->selectedKey == 11) {
150 rectArea.x0 = keypad->obj.area.x0 + KEYPAD_WIDTH - C_digit_validate_bold.width;
155 rectArea.y0 = keypad->obj.area.y0;
164 if (!keypad->shuffled) {
165 keypad->selectedKey = 1 + INIT_DIGIT_VALUE;
170 if (keypad->enableBackspace) {
173 if (keypad->enableValidate) {
176 random = cx_rng_u32_range(0, nbChoices);
178 keypad->selectedKey = 1 + random;
180 else if (random == 10) {
181 keypad->selectedKey = 0;
183 else if (random == 11) {
184 keypad->selectedKey = 11;
208 keypadDrawSelectedTouched(keypad);
211 keypad->callback(positionToChar(keypad->selectedKey));
215 switch (keypad->selectedKey) {
217 if (keypad->enableBackspace) {
218 keypad->selectedKey = 0;
221 keypad->selectedKey = 10;
225 if (keypad->enableValidate) {
226 keypad->selectedKey = 11;
229 keypad->selectedKey = 10;
233 keypad->selectedKey--;
240 switch (keypad->selectedKey) {
242 if (keypad->enableValidate) {
243 keypad->selectedKey = 11;
245 else if (keypad->enableBackspace) {
246 keypad->selectedKey = 0;
249 keypad->selectedKey = 1;
253 keypad->selectedKey = 0;
256 keypad->selectedKey++;
273 keypadDrawDigits(keypad);
274 if (keypad->selectedKey == 0xFF) {
275 keypadInitSelected(keypad);
277 keypadDrawSelected(keypad);
Random Number Generation.
#define LOG_DEBUG(__logger,...)
Middle Level API of the new BOLOS Graphical Library.
Font screen low-Level driver API, to draw elementary forms.
void nbgl_frontDrawImage(const nbgl_area_t *area, const uint8_t *buffer, nbgl_transformation_t transformation, nbgl_color_map_t colorMap)
void nbgl_frontRefreshArea(const nbgl_area_t *area, nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
void nbgl_frontDrawRect(const nbgl_area_t *area)
API to draw all basic graphic objects.
struct PACKED__ nbgl_keypad_s nbgl_keypad_t
struct to represent a keypad (KEYPAD type)
@ BUTTON_BOTH_TOUCHED
Sent when both buttons are touched.
@ BUTTON_LEFT_CONTINUOUS_PRESSED
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
@ BUTTON_RIGHT_CONTINUOUS_PRESSED
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
void nbgl_objDrawKeypad(nbgl_keypad_t *kbd)
This function draws a keypad object.
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
void nbgl_screenRedraw(void)
This function redraws the whole screen on top of stack and its children.
@ POST_REFRESH_KEEP_POWER_STATE
Keep state after refresh.
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.
@ FULL_COLOR_CLEAN_REFRESH
to be used for lock screen display (cleaner but longer refresh)