Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_types.h
Go to the documentation of this file.
1
7#ifndef NBGL_TYPES_H
8#define NBGL_TYPES_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/*********************
15 * INCLUDES
16 *********************/
17#include <stddef.h>
18#include <stdint.h>
19#include <stdbool.h>
20#include "app_config.h"
21#include "bolos_target.h"
22
23/*********************
24 * DEFINES
25 *********************/
29#ifdef SCREEN_SIZE_WALLET
30#if defined(TARGET_STAX)
31#define SCREEN_WIDTH 400
32#define SCREEN_HEIGHT 672
33#define SMALL_ICON_SIZE 32
34#define LARGE_ICON_SIZE 64
35// height of the smallest used font
36#define SMALL_FONT_HEIGHT 24
37// radius of circle used for controls (buttons)
38#define COMMON_RADIUS 40
39// radius for small buttons
40#define SMALL_BUTTON_RADIUS 32
41// HW vertical alignment
42#define VERTICAL_ALIGNMENT 4
43// Number of color bits
44#define NB_COLOR_BITS 4
45#elif defined(TARGET_FLEX)
46#define SCREEN_WIDTH 480
47#define SCREEN_HEIGHT 600
48#define SMALL_ICON_SIZE 40
49#define LARGE_ICON_SIZE 64
50// height of the smallest used font
51#define SMALL_FONT_HEIGHT 28
52// radius of circle used for controls (buttons)
53#define COMMON_RADIUS 44
54// radius for small buttons
55#define SMALL_BUTTON_RADIUS 32
56// HW vertical alignment
57#define VERTICAL_ALIGNMENT 4
58// Number of color bits
59#define NB_COLOR_BITS 4
60#elif defined(TARGET_APEX)
61#define SCREEN_WIDTH 300
62#define SCREEN_HEIGHT 400
63#define SMALL_ICON_SIZE 24
64#define LARGE_ICON_SIZE 48
65// height of the smallest used font
66#define SMALL_FONT_HEIGHT 18
67// radius of corners used for controls (buttons)
68#define COMMON_RADIUS 28
69// radius for small buttons
70#define SMALL_BUTTON_RADIUS 20
71// HW vertical alignment
72#define VERTICAL_ALIGNMENT 8
73// Number of color bits
74#define NB_COLOR_BITS 1
75#endif // TARGETS
76#else // SCREEN_SIZE_WALLET
77#define SCREEN_WIDTH 128
78#define SCREEN_HEIGHT 64
79// height of the smallest used font
80#define SMALL_FONT_HEIGHT 11
81// HW vertical alignment
82#define VERTICAL_ALIGNMENT 1
83// Number of color bits
84#define NB_COLOR_BITS 1
85#endif // SCREEN_SIZE_WALLET
86
91#define NO_TRANSFORMATION 0
92
97#define VERTICAL_MIRROR 0x2
98
103#define ROTATE_90_CLOCKWISE 0x4
104
109#define INVALID_COLOR_MAP 0x0
110
111#define NBGL_LOWER_ALIGN(__y) ((__y) & ~(VERTICAL_ALIGNMENT - 1))
112#define NBGL_UPPER_ALIGN(__y) (((__y) + VERTICAL_ALIGNMENT - 1) & ~(VERTICAL_ALIGNMENT - 1))
113
114/**********************
115 * TYPEDEFS
116 **********************/
117#ifndef MIN
118#define MIN(x, y) ((x) < (y) ? (x) : (y))
119#endif
120#ifndef MAX
121#define MAX(x, y) ((x) > (y) ? (x) : (y))
122#endif
123
124#ifdef LINUX_SIMU
125#define PACKED__
126#else // LINUX_SIMU
127#define PACKED__ __attribute__((packed))
128#endif // LINUX_SIMU
129#ifdef BICOLOR_MODE
130
131typedef enum {
132 BLACK = 0,
133 DARK_GRAY = 0,
134 LIGHT_GRAY = 0,
135 WHITE = 3
136} color_t;
137
138#else
139
147
148#endif
149
174
195
203
212
217typedef enum {
219#ifdef SCREEN_SIZE_NANO
220 INVERTED_COLORS
221#endif // SCREEN_SIZE_NANO
223
234
243
254
278
289
300
305#define GZLIB_UNCOMPRESSED_CHUNK 2049
306
321
335
358
363typedef enum {
364#ifdef SCREEN_SIZE_WALLET
371#else // SCREEN_SIZE_WALLET
372 RADIUS_1_PIXEL = 0,
373 RADIUS_3_PIXELS,
374 RADIUS_MAX = RADIUS_3_PIXELS,
375#endif // SCREEN_SIZE_WALLET
378
383typedef uint8_t nbgl_transformation_t;
384
390typedef uint8_t nbgl_color_map_t;
391
403
412
417typedef struct nbgl_animation_s {
419 uint8_t nbIcons;
420 nbgl_parsingType_t parsing; // type of parsing of icons
421 uint16_t delayMs;
423
424#ifdef __cplusplus
425} /* extern "C" */
426#endif
427
428#endif /* NBGL_TYPES_H */
color_t
Definition nbgl_types.h:140
@ NB_NBGL_COLOR
Definition nbgl_types.h:145
@ WHITE
Definition nbgl_types.h:144
@ DARK_GRAY
Definition nbgl_types.h:142
@ LIGHT_GRAY
Definition nbgl_types.h:143
@ BLACK
Definition nbgl_types.h:141
uint8_t nbgl_transformation_t
Represents the transformation to be applied on the bitmap before rendering This is a bitfield using m...
Definition nbgl_types.h:383
nbgl_state_t
to represent a boolean state.
Definition nbgl_types.h:199
@ ON_STATE
Definition nbgl_types.h:201
@ OFF_STATE
Definition nbgl_types.h:200
nbgl_post_refresh_t
Post refresh modes.
Definition nbgl_types.h:352
@ POST_REFRESH_KEEP_POWER_STATE
Keep state after refresh.
Definition nbgl_types.h:356
@ POST_REFRESH_FORCE_POWER_OFF
Force screen power off after refresh.
Definition nbgl_types.h:353
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
Definition nbgl_types.h:354
@ POST_REFRESH_FORCE_POWER_ON_WITH_PIPELINE
Force screen power on and enable pipeline.
Definition nbgl_types.h:355
uint8_t nbgl_color_map_t
Represents the color_map to be used for 2BPP image, or the foreground color for 1BPP image.
Definition nbgl_types.h:390
nbgl_radius_t
possible radius indexes for objects
Definition nbgl_types.h:363
@ RADIUS_MAX
Definition nbgl_types.h:370
@ RADIUS_0_PIXELS
no radius (square angle)
Definition nbgl_types.h:376
@ RADIUS_28_PIXELS
Definition nbgl_types.h:366
@ RADIUS_32_PIXELS
Definition nbgl_types.h:367
@ RADIUS_44_PIXELS
Definition nbgl_types.h:369
@ RADIUS_20_PIXELS
Definition nbgl_types.h:365
@ RADIUS_40_PIXELS
Definition nbgl_types.h:368
struct nbgl_animation_s nbgl_animation_t
Represents all information about an animation (succession of icons)
nbgl_touchType_t
The different types of Touchscreen events.
Definition nbgl_types.h:259
@ SWIPED_LEFT
Definition nbgl_types.h:275
@ LONG_TOUCHED
Definition nbgl_types.h:262
@ SWIPED_UP
Definition nbgl_types.h:272
@ SWIPED_DOWN
Definition nbgl_types.h:273
@ SWIPED_RIGHT
Definition nbgl_types.h:274
@ VALUE_CHANGED
corresponding to a change of state of the object (indirect event)
Definition nbgl_types.h:271
@ NB_TOUCH_TYPES
Definition nbgl_types.h:276
@ TOUCH_RELEASED
Definition nbgl_types.h:269
@ TOUCHED
Definition nbgl_types.h:260
@ TOUCHING
corresponding to an object that is currently touched
Definition nbgl_types.h:264
@ TOUCH_PRESSED
Definition nbgl_types.h:267
@ OUT_OF_TOUCH
Definition nbgl_types.h:265
nbgl_qrcode_version_t
possible modes for QR Code
Definition nbgl_types.h:229
@ QRCODE_V10
QRCode V10, can encode text len up to 1500 chars, display size = 228*228.
Definition nbgl_types.h:231
@ QRCODE_V4_SMALL
QRCode V4, can encode text len up to 1500 chars, display size = 132*132.
Definition nbgl_types.h:232
@ QRCODE_V4
QRCode V4, can encode text len up to 62 chars, display size = 264*264.
Definition nbgl_types.h:230
nbgl_direction_t
Directions for layout or lines.
Definition nbgl_types.h:208
@ VERTICAL
from top to bottom
Definition nbgl_types.h:209
@ HORIZONTAL
from left to right
Definition nbgl_types.h:210
nbgl_parsingType_t
possible parsings of icons to create animation
Definition nbgl_types.h:408
@ BACK_AND_FORTH_PARSING
0, 1, 2, 1, 2, 0, ...
Definition nbgl_types.h:410
@ LOOP_PARSING
0, 1, 2, 0, 1, 2, ...
Definition nbgl_types.h:409
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
nbgl_aligment_t
All types of alignments.
Definition nbgl_types.h:179
@ TOP_MIDDLE
Definition nbgl_types.h:182
@ CENTER
Definition nbgl_types.h:185
@ BOTTOM_RIGHT
Definition nbgl_types.h:189
@ TOP_LEFT
Definition nbgl_types.h:181
@ NO_ALIGNMENT
used when parent container layout is used
Definition nbgl_types.h:180
@ BOTTOM_LEFT
Definition nbgl_types.h:187
@ LEFT_TOP
on outside left
Definition nbgl_types.h:190
@ LEFT_BOTTOM
on outside left
Definition nbgl_types.h:191
@ MID_RIGHT
Definition nbgl_types.h:186
@ RIGHT_TOP
on outside right
Definition nbgl_types.h:192
@ TOP_RIGHT
Definition nbgl_types.h:183
@ MID_LEFT
Definition nbgl_types.h:184
@ BOTTOM_MIDDLE
Definition nbgl_types.h:188
@ RIGHT_BOTTOM
on outside right
Definition nbgl_types.h:193
nbgl_hardwareSwipe_t
Hardware powered detected swipe states.
Definition nbgl_types.h:247
@ HARDWARE_SWIPE_RIGHT
Definition nbgl_types.h:250
@ NO_HARDWARE_SWIPE
Definition nbgl_types.h:252
@ HARDWARE_SWIPE_LEFT
Definition nbgl_types.h:251
@ HARDWARE_SWIPE_DOWN
Definition nbgl_types.h:249
@ HARDWARE_SWIPE_UP
Definition nbgl_types.h:248
nbgl_obj_type_t
All types of graphical objects.
Definition nbgl_types.h:154
@ KEYPAD
Keypad.
Definition nbgl_types.h:167
@ IMAGE
Bitmap (y and height must be multiple of 4 on Stax)
Definition nbgl_types.h:157
@ IMAGE_FILE
Image file (with Ledger compression)
Definition nbgl_types.h:169
@ TEXT_ENTRY
area for entered text, only for Nanos
Definition nbgl_types.h:170
@ NB_OBJ_TYPES
Definition nbgl_types.h:172
@ SWITCH
Switch to turn on/off something.
Definition nbgl_types.h:161
@ RADIO_BUTTON
Indicator to inform whether something is on or off.
Definition nbgl_types.h:164
@ SPINNER
Spinner.
Definition nbgl_types.h:168
@ BUTTON
Rounded rectangle button with icon and/or text.
Definition nbgl_types.h:160
@ PROGRESS_BAR
horizontal bar to indicate progression of something (between 0% and 100%)
Definition nbgl_types.h:163
@ QR_CODE
QR Code.
Definition nbgl_types.h:165
@ PAGE_INDICATOR
horizontal bar to indicate position within pages
Definition nbgl_types.h:162
@ LINE
Vertical or Horizontal line.
Definition nbgl_types.h:158
@ KEYBOARD
Keyboard.
Definition nbgl_types.h:166
@ MASK_CONTROL
OS-specific object to enable/disable masked area.
Definition nbgl_types.h:171
@ CONTAINER
Empty container.
Definition nbgl_types.h:156
@ TEXT_AREA
Area to contain text line(s)
Definition nbgl_types.h:159
@ SCREEN
Main screen.
Definition nbgl_types.h:155
nbgl_touchState_t
the 2 possible states of a finger on the Touchscreen
Definition nbgl_types.h:239
@ PRESSED
the finger is currently pressing the screen
Definition nbgl_types.h:241
@ RELEASED
the finger has been released from the screen
Definition nbgl_types.h:240
nbgl_bpp_t
Enum to represent the number of bits per pixel (BPP)
Definition nbgl_types.h:283
@ NB_NBGL_BPP
Number of NBGL_BPP enums.
Definition nbgl_types.h:287
@ NBGL_BPP_1
1 bit per pixel
Definition nbgl_types.h:284
@ NBGL_BPP_4
4 bits per pixel
Definition nbgl_types.h:286
@ NBGL_BPP_2
2 bits per pixel
Definition nbgl_types.h:285
nbgl_style_t
possible styles for text area border
Definition nbgl_types.h:217
@ NO_STYLE
no border
Definition nbgl_types.h:218
#define PACKED__
Definition nbgl_types.h:127
struct PACKED__ nbgl_area_s nbgl_area_t
Represents a rectangle area of the screen.
nbgl_compression_t
Enum to represent the compression.
Definition nbgl_types.h:294
@ NBGL_GZLIB_COMPRESSION
gzlib compression
Definition nbgl_types.h:296
@ NBGL_NO_COMPRESSION
no compression, raw data
Definition nbgl_types.h:295
@ NBGL_RLE_COMPRESSION
RLE compression.
Definition nbgl_types.h:297
@ NB_NBGL_COMPRESSION
Number of NBGL_COMPRESSION enums.
Definition nbgl_types.h:298
nbgl_refresh_mode_t
different modes of refresh for nbgl_refreshSpecial()
Definition nbgl_types.h:326
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
Definition nbgl_types.h:330
@ FULL_COLOR_CLEAN_REFRESH
to be used for lock screen display (cleaner but longer refresh)
Definition nbgl_types.h:329
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
Definition nbgl_types.h:331
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
Definition nbgl_types.h:328
@ INIT_REFRESH
to be used to fully clear the screen in white
Definition nbgl_types.h:332
@ NB_REFRESH_MODES
Definition nbgl_types.h:333
@ FULL_COLOR_REFRESH
to be used for normal refresh
Definition nbgl_types.h:327
Represents all information about an animation (succession of icons)
Definition nbgl_types.h:417
uint16_t delayMs
delay between 2 drawings
Definition nbgl_types.h:421
uint8_t nbIcons
number of icons in icons array
Definition nbgl_types.h:419
const nbgl_icon_details_t ** icons
array of nbIcons pointers on icons
Definition nbgl_types.h:418
nbgl_parsingType_t parsing
Definition nbgl_types.h:420
Represents a rectangle area of the screen.
Definition nbgl_types.h:311
color_t backgroundColor
color (usually background) to be applied
Definition nbgl_types.h:318
uint16_t width
width of the area, in pixels
Definition nbgl_types.h:316
int16_t y0
Definition nbgl_types.h:314
int16_t x0
Definition nbgl_types.h:312
nbgl_bpp_t bpp
bits per pixel for this area
Definition nbgl_types.h:319
uint16_t height
height of the area, in pixels
Definition nbgl_types.h:317
Represents all information about an icon.
Definition nbgl_types.h:396
bool isFile
if true, the bitmap buffer contains an image file
Definition nbgl_types.h:400
uint16_t width
width of the icon, in pixels
Definition nbgl_types.h:397
const uint8_t * bitmap
buffer containing pixel values
Definition nbgl_types.h:401
nbgl_bpp_t bpp
bits per pixel for this area
Definition nbgl_types.h:399
uint16_t height
height of the icon, in pixels
Definition nbgl_types.h:398