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
37typedef struct ux_state_s ux_state_t;
38
47struct ux_state_s {
48 bolos_task_status_t exit_code;
49 bool validate_pin_from_dashboard; // set to true when BOLOS_UX_VALIDATE_PIN is received from
50 // Dashboard task
51
52 char string_buffer[128];
53};
54
56extern ux_state_t G_ux;
58extern bolos_ux_params_t G_ux_params;
59
60extern void ux_process_finger_event(const uint8_t seph_packet[]);
61extern void ux_process_button_event(const uint8_t seph_packet[]);
62extern void ux_process_ticker_event(void);
63extern void ux_process_default_event(void);
64
68#define UX_INIT() nbgl_objInit();
69
75#define UX_WAKE_UP() \
76 G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
77 G_ux_params.len = 0; \
78 os_ux(&G_ux_params); \
79 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
80
85#ifdef HAVE_SE_TOUCH
86#define UX_BUTTON_PUSH_EVENT(seph_packet)
87#else // HAVE_SE_TOUCH
88#define UX_BUTTON_PUSH_EVENT(seph_packet) ux_process_button_event(seph_packet)
89#endif // HAVE_SE_TOUCH
90
95#ifdef HAVE_SE_TOUCH
96#define UX_FINGER_EVENT(seph_packet) ux_process_finger_event(seph_packet)
97#else // HAVE_SE_TOUCH
98#define UX_FINGER_EVENT(seph_packet)
99#endif // HAVE_SE_TOUCH
100
105#define UX_TICKER_EVENT(seph_packet, callback) ux_process_ticker_event()
106
111#define UX_DEFAULT_EVENT() ux_process_default_event()
112
113// discriminated from io to allow for different memory placement
114typedef struct ux_seph_s {
115 unsigned int button_mask;
117#ifdef HAVE_BOLOS
118 unsigned int ux_id;
119 unsigned int ux_status;
120#endif // HAVE_BOLOS
122
124
125#include "glyphs.h"
API to manage screens.
unsigned int button_mask
Definition ux_nbgl.h:115
unsigned int button_same_mask_counter
Definition ux_nbgl.h:116
Global UX state shared between the application and the UX event handlers.
Definition ux_nbgl.h:47
bolos_task_status_t exit_code
Definition ux_nbgl.h:48
char string_buffer[128]
Definition ux_nbgl.h:52
bool validate_pin_from_dashboard
Definition ux_nbgl.h:49
void ux_process_default_event(void)
Definition ux.c:147
bolos_ux_params_t G_ux_params
UX command parameters passed to the OS via os_ux()
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
Global UX state instance — see ux_state_s.
Definition main.c:34