21 #include "os_io_seproxyhal.h"
27 #define KEY_WIDTH (SCREEN_WIDTH / 3)
28 #define DIGIT_OFFSET_Y (((KEYPAD_KEY_HEIGHT - 48) / 2) & 0xFFC)
30 #define BACKSPACE_KEY_IDX 10
31 #define VALIDATE_KEY_IDX 11
34 #define GET_DIGIT_INDEX(_keypad, _digit) \
35 ((_digit & 1) ? (_keypad->digitIndexes[_digit >> 1] >> 4) \
36 : (_keypad->digitIndexes[_digit >> 1] & 0xF))
37 #define SET_DIGIT_INDEX(_keypad, _digit, _index) \
38 (_keypad->digitIndexes[_digit >> 1] |= (_digit & 1) ? (_index << 4) : _index)
94 rectArea.backgroundColor = keypad->obj.area.backgroundColor;
95 rectArea.x0 = keypad->obj.area.x0;
96 rectArea.y0 = keypad->obj.area.y0;
97 rectArea.width = keypad->obj.area.width;
98 rectArea.height = keypad->obj.area.height;
102 rectArea.backgroundColor = keypad->obj.area.backgroundColor;
103 rectArea.x0 = keypad->obj.area.x0;
104 rectArea.y0 = keypad->obj.area.y0;
105 rectArea.width = keypad->obj.area.width;
116 rectArea.backgroundColor = keypad->borderColor;
117 rectArea.x0 = keypad->obj.area.x0;
118 rectArea.y0 = keypad->obj.area.y0;
134 rectArea.backgroundColor = keypad->obj.area.backgroundColor;
136 if (!keypad->partial) {
140 for (i = 0; i < 3; i++) {
143 rectArea.x0 = keypad->obj.area.x0 + i *
KEY_WIDTH;
146 &rectArea, &key_value, 1, LARGE_MEDIUM_FONT, keypad->enableDigits ?
BLACK :
WHITE);
152 rectArea.x0 = keypad->obj.area.x0 + (i - 3) *
KEY_WIDTH;
155 &rectArea, &key_value, 1, LARGE_MEDIUM_FONT, keypad->enableDigits ?
BLACK :
WHITE);
161 rectArea.x0 = keypad->obj.area.x0 + (i - 6) *
KEY_WIDTH;
164 &rectArea, &key_value, 1, LARGE_MEDIUM_FONT, keypad->enableDigits ?
BLACK :
WHITE);
172 rectArea.x0 = keypad->obj.area.x0 + (
KEY_WIDTH - rectArea.width) / 2;
189 if (!keypad->partial) {
192 rectArea.x0 = keypad->obj.area.x0 +
KEY_WIDTH;
196 &rectArea, &key_value, 1, LARGE_MEDIUM_FONT, keypad->enableDigits ?
BLACK :
WHITE);
200 if (!keypad->enableValidate) {
204 rectArea.x0 = keypad->obj.area.x0 + 2 *
KEY_WIDTH + 1;
206 rectArea.backgroundColor =
WHITE;
209 rectArea.backgroundColor = keypad->obj.area.backgroundColor;
210 rectArea.x0 = keypad->obj.area.x0 + 2 *
KEY_WIDTH;
216 rectArea.backgroundColor = keypad->borderColor;
217 rectArea.x0 = keypad->obj.area.x0 + 2 *
KEY_WIDTH;
225 rectArea.backgroundColor =
BLACK;
226 rectArea.x0 = keypad->obj.area.x0 + 2 *
KEY_WIDTH;
249 if (!keypad->partial) {
251 keypadDrawGrid(keypad);
255 keypadDrawDigits(keypad);
256 keypad->partial =
false;
285 firstIndex = getKeypadIndex(firstPosition->
x - obj->area.x0, firstPosition->
y - obj->area.y0);
289 lastIndex = getKeypadIndex(lastPosition->
x - obj->area.x0, lastPosition->
y - obj->area.y0);
295 if (lastIndex != firstIndex) {
299 if ((firstIndex < 10) && (keypad->enableDigits)) {
306 io_seproxyhal_play_tune(TUNE_TAP_CASUAL);
316 io_seproxyhal_play_tune(TUNE_TAP_CASUAL);
340 if ((index >=
'1') && (index <=
'3')) {
341 *x = kpd->obj.area.x0 + (index -
'1') *
KEY_WIDTH;
342 *y = kpd->obj.area.y0;
344 else if ((index >=
'4') && (index <=
'6')) {
345 *x = kpd->obj.area.x0 + (index -
'4') *
KEY_WIDTH;
348 else if ((index >=
'7') && (index <=
'9')) {
349 *x = kpd->obj.area.x0 + (index -
'7') *
KEY_WIDTH;
353 *x = kpd->obj.area.x0;
356 else if (index ==
'0') {
382 if (kpd->digitIndexes[0] == 0) {
385 uint8_t shuffledDigits[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
388 for (i = 0; i < 9; i++) {
390 uint32_t j = cx_rng_u32_range(i, 10);
391 uint8_t tmp = shuffledDigits[j];
394 shuffledDigits[j] = shuffledDigits[i];
395 shuffledDigits[i] = tmp;
397 for (i = 0; i < 10; i++) {
404 for (i = 0; i < 10; i++) {
Random Number Generation.
#define LOG_DEBUG(__logger,...)
Middle Level API of the new BOLOS Graphical Library.
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
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_frontDrawImageFile(const nbgl_area_t *area, const uint8_t *buffer, nbgl_color_map_t colorMap, const uint8_t *uzlib_chunk_buffer)
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.
struct PACKED__ nbgl_keypad_s nbgl_keypad_t
struct to represent a keypad (KEYPAD type)
#define KEYPAD_KEY_HEIGHT
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
#define GET_DIGIT_INDEX(_keypad, _digit)
void nbgl_objDrawKeypad(nbgl_keypad_t *kpd)
This function draws a keypad object.
#define BACKSPACE_KEY_IDX
#define SET_DIGIT_INDEX(_keypad, _digit, _index)
void nbgl_keypadTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
function to be called when the keypad object is touched
bool nbgl_keypadGetPosition(nbgl_keypad_t *kpd, 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...
uint8_t ramBuffer[GZLIB_UNCOMPRESSED_CHUNK]
bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, nbgl_touchStatePosition_t **firstPos, nbgl_touchStatePosition_t **lastPos)
nbgl_touchType_t
The different types of Touchscreen events.
#define GZLIB_UNCOMPRESSED_CHUNK
size of gzlib uncompression buffer in bytes
#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.
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)