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
31#include <string.h>
32
33#define BUTTON_LEFT 1
34#define BUTTON_RIGHT 2
35
36typedef void (*asynchmodal_end_callback_t)(unsigned int ux_status);
37
41typedef struct ux_state_s ux_state_t;
42
43struct ux_state_s {
44 bolos_task_status_t exit_code;
45 bool validate_pin_from_dashboard; // set to true when BOLOS_UX_VALIDATE_PIN is received from
46 // Dashboard task
47
49
50 char string_buffer[128];
51};
52
53extern ux_state_t G_ux;
54extern bolos_ux_params_t G_ux_params;
55
56extern void ux_process_finger_event(uint8_t seph_packet[]);
57extern void ux_process_button_event(uint8_t seph_packet[]);
58extern void ux_process_ticker_event(void);
59extern void ux_process_default_event(void);
60
64#define UX_INIT() nbgl_objInit();
65
66#ifdef HAVE_BOLOS
67// to be used only by hal_io.c in BOLOS, for compatibility
68#define UX_FORWARD_EVENT_REDRAWCB(bypasspincheck, \
69 ux_params, \
70 ux, \
71 os_ux, \
72 os_sched_last_status, \
73 callback, \
74 redraw_cb, \
75 ignoring_app_if_ux_busy) \
76 ux_params.ux_id = BOLOS_UX_EVENT; \
77 ux_params.len = 0; \
78 os_ux(&ux_params); \
79 ux_params.len = os_sched_last_status(TASK_BOLOS_UX); \
80 if (ux.asynchmodal_end_callback \
81 && os_ux_get_status(BOLOS_UX_ASYNCHMODAL_PAIRING_REQUEST) != 0) { \
82 asynchmodal_end_callback_t cb = ux.asynchmodal_end_callback; \
83 ux.asynchmodal_end_callback = NULL; \
84 cb(os_ux_get_status(BOLOS_UX_ASYNCHMODAL_PAIRING_REQUEST)); \
85 }
86#endif // HAVE_BOLOS
87
93#define UX_WAKE_UP() \
94 G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
95 G_ux_params.len = 0; \
96 os_ux(&G_ux_params); \
97 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
98
103#ifdef HAVE_SE_TOUCH
104#define UX_BUTTON_PUSH_EVENT(seph_packet)
105#else // HAVE_SE_TOUCH
106#define UX_BUTTON_PUSH_EVENT(seph_packet) ux_process_button_event(seph_packet)
107#endif // HAVE_SE_TOUCH
108
113#ifdef HAVE_SE_TOUCH
114#define UX_FINGER_EVENT(seph_packet) ux_process_finger_event(seph_packet)
115#else // HAVE_SE_TOUCH
116#define UX_FINGER_EVENT(seph_packet)
117#endif // HAVE_SE_TOUCH
118
123#define UX_TICKER_EVENT(seph_packet, callback) ux_process_ticker_event()
124
129#define UX_DEFAULT_EVENT() ux_process_default_event()
130
131// discriminated from io to allow for different memory placement
132typedef struct ux_seph_s {
133 unsigned int button_mask;
134 unsigned int button_same_mask_counter;
135#ifdef HAVE_BOLOS
136 unsigned int ux_id;
137 unsigned int ux_status;
138#endif // HAVE_BOLOS
140
141#ifdef HAVE_BACKGROUND_IMG
142SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
143uint8_t *fetch_background_img(bool allow_candidate);
144SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
145bolos_err_t delete_background_img(void);
146#endif
147
149
151void io_seproxyhal_power_off(bool criticalBattery);
152
153#if defined(HAVE_LANGUAGE_PACK)
154const char *get_ux_loc_string(UX_LOC_STRINGS_INDEX index);
155void bolos_ux_select_language(uint16_t language);
156void bolos_ux_refresh_language(void);
157
158typedef struct ux_loc_language_pack_infos {
159 unsigned char available;
160
161} UX_LOC_LANGUAGE_PACK_INFO;
162
163// To populate infos about language packs
164SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) void list_language_packs(
165 UX_LOC_LANGUAGE_PACK_INFO *packs PLENGTH(NB_LANG * sizeof(UX_LOC_LANGUAGE_PACK_INFO)));
166SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) const LANGUAGE_PACK *get_language_pack(
167 unsigned int language);
168#endif // defined(HAVE_LANGUAGE_PACK)
169
170#include "glyphs.h"
#define LANGUAGE_PACK
Definition nbgl_fonts.h:29
const char * get_ux_loc_string(uint32_t index)
API to manage screens.
unsigned int button_mask
Definition ux_bagl.h:704
unsigned int button_same_mask_counter
Definition ux_bagl.h:705
asynchmodal_end_callback_t asynchmodal_end_callback
Definition ux_nbgl.h:48
bolos_task_status_t exit_code
Definition ux_bagl.h:301
char string_buffer[128]
Definition ux_nbgl.h:50
bool validate_pin_from_dashboard
Definition ux_nbgl.h:45
unsigned short uint16_t
Definition usbd_conf.h:54
unsigned char uint8_t
Definition usbd_conf.h:53
BOLOS_UX_LOC_STRINGS UX_LOC_STRINGS_INDEX
void ux_process_default_event(void)
Definition ux.c:146
bolos_ux_params_t G_ux_params
Definition main.c:35
void(* asynchmodal_end_callback_t)(unsigned int ux_status)
Definition ux_nbgl.h:36
void ux_process_finger_event(uint8_t seph_packet[])
Process finger event.
Definition ux.c:64
struct ux_seph_s ux_seph_os_and_app_t
void io_seproxyhal_power_off(bool criticalBattery)
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:110
ux_seph_os_and_app_t G_ux_os
ux_state_t G_ux
Definition main.c:34
void io_seproxyhal_request_mcu_status(void)