Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
ux_nbgl.h
Go to the documentation of this file.
1
2/*******************************************************************************
3 * Ledger Nano S - Secure firmware
4 * (c) 2022 Ledger
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 ********************************************************************************/
18
19#pragma once
20
21#if defined(HAVE_BOLOS)
22#include "bolos_privileged_ux.h"
23#endif // HAVE_BOLOS
24
25#include "os_math.h"
26#include "os_ux.h"
27#include "os_task.h"
28#include "nbgl_screen.h"
29#include "nbgl_touch.h"
30#include "seproxyhal_protocol.h"
31
32#include <string.h>
33
34#define BUTTON_LEFT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_LEFT
35#define BUTTON_RIGHT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_RIGHT
36
40typedef struct ux_state_s ux_state_t;
41
42struct ux_state_s {
43 bolos_task_status_t exit_code;
44 bool validate_pin_from_dashboard; // set to true when BOLOS_UX_VALIDATE_PIN is received from
45 // Dashboard task
46
47 char string_buffer[128];
48};
49
50extern ux_state_t G_ux;
51extern bolos_ux_params_t G_ux_params;
52
53extern void ux_process_finger_event(uint8_t seph_packet[]);
54extern void ux_process_button_event(uint8_t seph_packet[]);
55extern void ux_process_ticker_event(void);
56extern void ux_process_default_event(void);
57
61#define UX_INIT() nbgl_objInit();
62
68#define UX_WAKE_UP() \
69 G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
70 G_ux_params.len = 0; \
71 os_ux(&G_ux_params); \
72 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
73
78#ifdef HAVE_SE_TOUCH
79#define UX_BUTTON_PUSH_EVENT(seph_packet)
80#else // HAVE_SE_TOUCH
81#define UX_BUTTON_PUSH_EVENT(seph_packet) ux_process_button_event(seph_packet)
82#endif // HAVE_SE_TOUCH
83
88#ifdef HAVE_SE_TOUCH
89#define UX_FINGER_EVENT(seph_packet) ux_process_finger_event(seph_packet)
90#else // HAVE_SE_TOUCH
91#define UX_FINGER_EVENT(seph_packet)
92#endif // HAVE_SE_TOUCH
93
98#define UX_TICKER_EVENT(seph_packet, callback) ux_process_ticker_event()
99
104#define UX_DEFAULT_EVENT() ux_process_default_event()
105
106// discriminated from io to allow for different memory placement
107typedef struct ux_seph_s {
108 unsigned int button_mask;
109 unsigned int button_same_mask_counter;
110#ifdef HAVE_BOLOS
111 unsigned int ux_id;
112 unsigned int ux_status;
113#endif // HAVE_BOLOS
115
116#ifdef HAVE_BACKGROUND_IMG
117SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
118uint8_t *fetch_background_img(bool allow_candidate);
119SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
120bolos_err_t delete_background_img(void);
121#endif
122
124
125#if defined(HAVE_LANGUAGE_PACK)
126const char *get_ux_loc_string(UX_LOC_STRINGS_INDEX index);
127void bolos_ux_select_language(uint16_t language);
128void bolos_ux_refresh_language(void);
129
130typedef struct ux_loc_language_pack_infos {
131 unsigned char available;
132
133} UX_LOC_LANGUAGE_PACK_INFO;
134
135// To populate infos about language packs
136SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) void list_language_packs(
137 UX_LOC_LANGUAGE_PACK_INFO *packs PLENGTH(NB_LANG * sizeof(UX_LOC_LANGUAGE_PACK_INFO)));
138SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) const LANGUAGE_PACK *get_language_pack(
139 unsigned int language);
140#endif // defined(HAVE_LANGUAGE_PACK)
141
142#include "glyphs.h"
#define LANGUAGE_PACK
Definition nbgl_fonts.h:29
API to manage screens.
unsigned int button_mask
Definition ux_bagl.h:558
unsigned int button_same_mask_counter
Definition ux_bagl.h:559
bolos_task_status_t exit_code
Definition ux_bagl.h:298
char string_buffer[128]
Definition ux_nbgl.h:47
bool validate_pin_from_dashboard
Definition ux_nbgl.h:44
BOLOS_UX_LOC_STRINGS UX_LOC_STRINGS_INDEX
void ux_process_default_event(void)
Definition ux.c:147
bolos_ux_params_t G_ux_params
Definition main.c:35
void ux_process_finger_event(uint8_t seph_packet[])
Process finger event.
Definition ux.c:65
struct ux_seph_s ux_seph_os_and_app_t
void ux_process_button_event(uint8_t seph_packet[])
void ux_process_ticker_event(void)
Process the ticker_event to the os ux handler. Ticker event callback is always called whatever the re...
Definition ux.c:111
ux_seph_os_and_app_t G_ux_os
ux_state_t G_ux
Definition main.c:34