Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
lib_ux_nbgl
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
#ifndef NBGL_USE_CASE_ONLY
25
#include "
nbgl_screen.h
"
26
#include "
nbgl_touch.h
"
27
#endif
28
#include "seproxyhal_protocol.h"
29
30
#include <
string.h
>
31
32
#define BUTTON_LEFT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_LEFT
33
#define BUTTON_RIGHT SEPROXYHAL_TAG_BUTTON_PUSH_EVENT_RIGHT
34
39
typedef
struct
ux_state_s
ux_state_t
;
40
49
struct
ux_state_s
{
50
bolos_task_status_t
exit_code
;
51
bool
validate_pin_from_dashboard
;
// set to true when BOLOS_UX_VALIDATE_PIN is received from
52
// Dashboard task
53
54
char
string_buffer
[128];
55
};
56
58
extern
ux_state_t
G_ux
;
60
extern
bolos_ux_params_t
G_ux_params
;
61
62
extern
void
ux_process_finger_event
(
const
uint8_t seph_packet[]);
63
extern
void
ux_process_button_event
(
const
uint8_t seph_packet[]);
64
extern
void
ux_process_ticker_event
(
void
);
65
extern
void
ux_process_default_event
(
void
);
66
70
#ifdef NBGL_USE_CASE_ONLY
71
// low-level NBGL is not available to apollo apps: lib_standard_app main() initializes it
72
#define UX_INIT() \
73
_Static_assert(0, "UX_INIT() is forbidden on apollo: use the lib_standard_app main()")
74
#else
75
#define UX_INIT() nbgl_objInit();
76
#endif
77
83
#define UX_WAKE_UP() \
84
G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
85
G_ux_params.len = 0; \
86
os_ux(&G_ux_params); \
87
G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
88
93
#ifdef HAVE_SE_TOUCH
94
#define UX_BUTTON_PUSH_EVENT(seph_packet)
95
#else
// HAVE_SE_TOUCH
96
#define UX_BUTTON_PUSH_EVENT(seph_packet) ux_process_button_event(seph_packet)
97
#endif
// HAVE_SE_TOUCH
98
103
#ifdef HAVE_SE_TOUCH
104
#define UX_FINGER_EVENT(seph_packet) ux_process_finger_event(seph_packet)
105
#else
// HAVE_SE_TOUCH
106
#define UX_FINGER_EVENT(seph_packet)
107
#endif
// HAVE_SE_TOUCH
108
113
#define UX_TICKER_EVENT(seph_packet, callback) ux_process_ticker_event()
114
119
#define UX_DEFAULT_EVENT() ux_process_default_event()
120
121
// discriminated from io to allow for different memory placement
122
typedef
struct
ux_seph_s
{
123
unsigned
int
button_mask
;
124
unsigned
int
button_same_mask_counter
;
125
#ifdef HAVE_BOLOS
126
unsigned
int
ux_id;
127
unsigned
int
ux_status;
128
#endif
// HAVE_BOLOS
129
}
ux_seph_os_and_app_t
;
130
131
extern
ux_seph_os_and_app_t
G_ux_os
;
132
133
#include "glyphs.h"
G_ux_params
bolos_ux_params_t G_ux_params
UX command parameters passed to the OS via os_ux().
Definition
main.c:35
G_ux
ux_state_t G_ux
Global UX state instance — see ux_state_s.
Definition
main.c:34
nbgl_screen.h
API to manage screens.
nbgl_touch.h
string.h
ux_seph_s
Definition
ux_nbgl.h:122
ux_seph_s::button_mask
unsigned int button_mask
Definition
ux_nbgl.h:123
ux_seph_s::button_same_mask_counter
unsigned int button_same_mask_counter
Definition
ux_nbgl.h:124
ux_state_s
Global UX state shared between the application and the UX event handlers.
Definition
ux_nbgl.h:49
ux_state_s::exit_code
bolos_task_status_t exit_code
Definition
ux_nbgl.h:50
ux_state_s::string_buffer
char string_buffer[128]
Definition
ux_nbgl.h:54
ux_state_s::validate_pin_from_dashboard
bool validate_pin_from_dashboard
Definition
ux_nbgl.h:51
ux_process_default_event
void ux_process_default_event(void)
Definition
ux.c:147
ux_seph_os_and_app_t
struct ux_seph_s ux_seph_os_and_app_t
ux_process_finger_event
void ux_process_finger_event(const uint8_t seph_packet[])
Process finger event.
Definition
ux.c:65
ux_process_ticker_event
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_process_button_event
void ux_process_button_event(const uint8_t seph_packet[])
G_ux_os
ux_seph_os_and_app_t G_ux_os
ux_state_t
struct ux_state_s ux_state_t
Application UX state (touch-based devices).
Definition
ux_nbgl.h:39
Generated by
1.15.0