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#include "os_math.h"
22#include "os_ux.h"
23#include "os_task.h"
24#include "nbgl_screen.h"
25#include "nbgl_touch.h"
26#include "seproxyhal_protocol.h"
27
28#include <string.h>
29
30#define BUTTON_LEFT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_LEFT
31#define BUTTON_RIGHT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_RIGHT
32
36typedef struct ux_state_s ux_state_t;
37
38struct ux_state_s {
39 bolos_task_status_t exit_code;
40 bool validate_pin_from_dashboard; // set to true when BOLOS_UX_VALIDATE_PIN is received from
41 // Dashboard task
42
43 char string_buffer[128];
44};
45
46extern ux_state_t G_ux;
47extern bolos_ux_params_t G_ux_params;
48
49extern void ux_process_finger_event(const uint8_t seph_packet[]);
50extern void ux_process_button_event(const uint8_t seph_packet[]);
51extern void ux_process_ticker_event(void);
52extern void ux_process_default_event(void);
53
57#define UX_INIT() nbgl_objInit();
58
64#define UX_WAKE_UP() \
65 G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
66 G_ux_params.len = 0; \
67 os_ux(&G_ux_params); \
68 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
69
74#ifdef HAVE_SE_TOUCH
75#define UX_BUTTON_PUSH_EVENT(seph_packet)
76#else // HAVE_SE_TOUCH
77#define UX_BUTTON_PUSH_EVENT(seph_packet) ux_process_button_event(seph_packet)
78#endif // HAVE_SE_TOUCH
79
84#ifdef HAVE_SE_TOUCH
85#define UX_FINGER_EVENT(seph_packet) ux_process_finger_event(seph_packet)
86#else // HAVE_SE_TOUCH
87#define UX_FINGER_EVENT(seph_packet)
88#endif // HAVE_SE_TOUCH
89
94#define UX_TICKER_EVENT(seph_packet, callback) ux_process_ticker_event()
95
100#define UX_DEFAULT_EVENT() ux_process_default_event()
101
102// discriminated from io to allow for different memory placement
103typedef struct ux_seph_s {
104 unsigned int button_mask;
105 unsigned int button_same_mask_counter;
106#ifdef HAVE_BOLOS
107 unsigned int ux_id;
108 unsigned int ux_status;
109#endif // HAVE_BOLOS
111
112#ifdef HAVE_BACKGROUND_IMG
113SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
114uint8_t *fetch_background_img(bool allow_candidate);
115SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
116bolos_err_t delete_background_img(void);
117#endif
118
120
121#if defined(HAVE_LANGUAGE_PACK)
122const char *get_ux_loc_string(UX_LOC_STRINGS_INDEX index);
123void bolos_ux_select_language(uint16_t language);
124void bolos_ux_refresh_language(void);
125
126typedef struct ux_loc_language_pack_infos {
127 unsigned char available;
128
129} UX_LOC_LANGUAGE_PACK_INFO;
130
131// To populate infos about language packs
132SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) void list_language_packs(
133 UX_LOC_LANGUAGE_PACK_INFO *packs PLENGTH(NB_LANG * sizeof(UX_LOC_LANGUAGE_PACK_INFO)));
134SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX) const LANGUAGE_PACK *get_language_pack(
135 unsigned int language);
136#endif // defined(HAVE_LANGUAGE_PACK)
137
138#include "glyphs.h"
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:43
bool validate_pin_from_dashboard
Definition ux_nbgl.h:40
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
struct ux_seph_s ux_seph_os_and_app_t
void ux_process_finger_event(const uint8_t seph_packet[])
Process finger event.
Definition ux.c:65
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
void ux_process_button_event(const uint8_t seph_packet[])
ux_seph_os_and_app_t G_ux_os
ux_state_t G_ux
Definition main.c:34