Skip to content

Commit

Permalink
nbgl: Implement NBGL for LNS
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Apr 26, 2024
1 parent c78ddfd commit d34d8ea
Show file tree
Hide file tree
Showing 22 changed files with 3,035 additions and 76 deletions.
4 changes: 3 additions & 1 deletion Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#*******************************************************************************

# temporary redef, to ensure wider compliance of the SDK with pre-1.6 apps
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOS TARGET_NANOX TARGET_NANOS2))
ifneq ($(USE_NBGL),1)
SDK_SOURCE_PATH += lib_bagl lib_ux
else
SDK_SOURCE_PATH += lib_nbgl lib_ux_nbgl lib_ux_sync
endif

define uniq =
Expand Down
13 changes: 13 additions & 0 deletions Makefile.standard_app
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ ifneq ($(DISABLE_STANDARD_WEBUSB), 1)
endif

ifneq ($(DISABLE_STANDARD_BAGL_UX_FLOW), 1)
ifneq ($(ENABLE_NBGL), 1)
ifneq ($(TARGET_NAME), TARGET_STAX)
DEFINES += HAVE_UX_FLOW
endif
endif
endif

ifneq ($(DISABLE_STANDARD_SEPROXYHAL), 1)
DEFINES += OS_IO_SEPROXYHAL
Expand All @@ -125,14 +127,25 @@ SDK_SOURCE_PATH += lib_standard_app
endif

ifneq ($(DISABLE_STANDARD_APP_SYNC_RAPDU), 1)
# On LNS only activate it by default if using NBGL.
# This impact stack usage and shouldn't be activated on all apps silently
ifneq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += STANDARD_APP_SYNC_RAPDU
else
ifeq ($(ENABLE_NBGL), 1)
DEFINES += STANDARD_APP_SYNC_RAPDU
endif
endif
endif

#####################################################################
# NBGL #
#####################################################################
ifeq ($(ENABLE_NBGL), 1)
USE_NBGL = 1
DEFINES += HAVE_NBGL NBGL_USE_CASE
endif

ifeq ($(ENABLE_NBGL_QRCODE), 1)
ifeq ($(TARGET_NAME), TARGET_STAX)
DEFINES += NBGL_QRCODE
Expand Down
8 changes: 3 additions & 5 deletions include/ux.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

#pragma once

#ifdef HAVE_BAGL
#include "ux_bagl.h"
#endif

#ifdef HAVE_NBGL
#if defined(HAVE_NBGL)
#include "ux_nbgl.h"
#elif defined(HAVE_BAGL)
#include "ux_bagl.h"
#endif
70 changes: 70 additions & 0 deletions lib_nbgl/include/nbgl_buttons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @file nbgl_buttons.h
* Buttons management of NBGL
*
*/

#ifndef NBGL_BUTTONS_H
#define NBGL_BUTTONS_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
* INCLUDES
*********************/
#include <stdint.h>

/*********************
* DEFINES
*********************/
///< Time after the beginning of continuous press on button(s) after which "continuous press" event
///< start to be sent (in 100ms)
#define CONTINOUS_PRESS_THRESHOLD 8
///< Periodicity of "continuous press" events (in 100ms)
#define CONTINUOUS_PRESS_PERIOD 3

/**********************
* TYPEDEFS
**********************/

/**
* @brief The different pressed buttons
*
*/
#define LEFT_BUTTON 0x01 ///< Left button event
#define RIGHT_BUTTON 0x02 ///< Right button event
#define BOTH_BUTTONS 0x03 ///< Both buttons event
#define RELEASED_MASK 0x80 ///< released (see LSB bits to know what buttons are released)
#define CONTINUOUS_MASK \
0x40 ///< if set, means that the button(s) is continuously pressed (this event is sent every
///< 300ms after the first 800ms)

typedef enum {
BUTTON_LEFT_PRESSED = 0, ///< Sent when Left button is released
BUTTON_RIGHT_PRESSED, ///< Send when Right button is released
BUTTON_LEFT_CONTINUOUS_PRESSED, ///< Send when Left button is continuouly pressed (sent every
///< 300ms after the first 800ms)
BUTTON_RIGHT_CONTINUOUS_PRESSED, ///< Send when Left button is continuouly pressed (sent every
///< 300ms after the first 800ms)
BUTTON_BOTH_PRESSED, ///< Sent when both buttons are released
BUTTON_BOTH_TOUCHED, ///< Sent when both buttons are touched
INVALID_BUTTON_EVENT
} nbgl_buttonEvent_t;

/**********************
* GLOBAL PROTOTYPES
**********************/
void nbgl_buttonsHandler(uint8_t buttonState);
void nbgl_buttonsReset(void);

/**********************
* MACROS
**********************/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* NBGL_BUTTONS_H */
Loading

0 comments on commit d34d8ea

Please sign in to comment.