Skip to content

Commit

Permalink
wip lns
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Feb 2, 2024
1 parent efc077c commit e671ce6
Show file tree
Hide file tree
Showing 20 changed files with 1,256 additions and 252 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif

DISABLE_UI = 1
include $(BOLOS_SDK)/Makefile.defines

########################################
Expand All @@ -35,6 +35,18 @@ APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
APP_SOURCE_PATH += src sdk
ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += HAVE_NBGL NBGL_USE_CASE NBGL_STEP
DEFINES += TARGET_NANOS=1
DEFINES += HAVE_BAGL
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=32
DISABLE_STANDARD_BAGL_UX_FLOW = 1
SDK_SOURCE_PATH += lib_bagl
APP_SOURCE_PATH += sdk_lib_nbgl/src sdk_lib_ux_stax

INCLUDES_PATH += sdk_lib_nbgl/include sdk_lib_ux_stax
CFLAGS += -Wno-macro-redefined
endif

# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
Expand Down
17 changes: 16 additions & 1 deletion sdk/nbgl_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "os.h"
#include "glyphs.h"


#ifndef TARGET_NANOS
static nbgl_pageInfoLongPress_t infoLongPress;

static const nbgl_layoutTagValueList_t *review_tagValueList;
Expand Down Expand Up @@ -46,6 +46,7 @@ static void tx_review_continue(void) {

nbgl_useCaseStaticReview(review_tagValueList, &infoLongPress, "Reject transaction", tx_review_choice);
}
#endif

void nbgl_useCaseTransactionReview(
const nbgl_layoutTagValueList_t *tagValueList,
Expand All @@ -55,6 +56,7 @@ void nbgl_useCaseTransactionReview(
const char *finish_page_text, /*unused on Nano*/
nbgl_choiceCallback_t choice_callback)
{
#ifndef TARGET_NANOS
review_tagValueList = tagValueList;
review_icon = icon;
review_finish_page_text = finish_page_text;
Expand All @@ -66,15 +68,23 @@ void nbgl_useCaseTransactionReview(
"Reject transaction",
tx_review_continue,
tx_ask_transaction_rejection_confirmation);
#else
UNUSED(reviewSubTitle);
UNUSED(finish_page_text);
nbgl_useCaseStaticReview(tagValueList, icon, reviewTitle, "Approve", "Reject", choice_callback);
#endif

}

#ifndef TARGET_NANOS
static void addr_review_continue(void) {
nbgl_useCaseAddressConfirmation(review_address, review_choice_callback);
}

static void addr_review_rejection(void) {
review_choice_callback(false);
}
#endif

void nbgl_useCaseAddressReview(
const char *address,
Expand All @@ -83,6 +93,7 @@ void nbgl_useCaseAddressReview(
const char *reviewSubTitle,
nbgl_choiceCallback_t choice_callback)
{
#ifndef TARGET_NANOS
review_address = address;
review_choice_callback = choice_callback;

Expand All @@ -92,4 +103,8 @@ void nbgl_useCaseAddressReview(
"Cancel",
addr_review_continue,
addr_review_rejection);
#else
UNUSED(reviewSubTitle);
nbgl_useCaseAddressConfirmation(icon, reviewTitle, address, choice_callback);
#endif
}
2 changes: 2 additions & 0 deletions sdk_lib_nbgl/include/nbgl_fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ typedef enum {
BAGL_FONT_INTER_REGULAR_28px_1bpp = 14u,
BAGL_FONT_INTER_SEMIBOLD_28px_1bpp = 15u,
BAGL_FONT_INTER_MEDIUM_36px_1bpp = 16u,
#ifndef TARGET_NANOS
BAGL_FONT_LAST // MUST ALWAYS BE THE LAST, FOR AUTOMATED INVALID VALUE CHECKS
#endif
} nbgl_font_id_e;

typedef struct nbgl_unicode_ctx_s {
Expand Down
19 changes: 18 additions & 1 deletion sdk_lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ typedef void (*nbgl_layoutTouchCallback_t)(int token, uint8_t index);
* @param layout layout concerned by the event
* @param event type of button event
*/
#ifndef TARGET_NANOS
typedef void (*nbgl_layoutButtonCallback_t)(nbgl_layout_t *layout, nbgl_buttonEvent_t event);
#else
typedef void (*nbgl_layoutButtonCallback_t)(nbgl_buttonEvent_t event);
#endif

/**
* @brief This structure contains info to build a navigation bar at the bottom of the screen
Expand Down Expand Up @@ -392,6 +396,7 @@ typedef struct {
/**********************
* GLOBAL PROTOTYPES
**********************/
#ifndef TARGET_NANOS
nbgl_layout_t *nbgl_layoutGet(const nbgl_layoutDescription_t *description);
int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info);
int nbgl_layoutAddProgressBar(nbgl_layout_t *layout, const nbgl_layoutProgressBar_t *barLayout);
Expand Down Expand Up @@ -525,7 +530,19 @@ int nbgl_layoutUpdateHiddenDigits(nbgl_layout_t *layout, uint8_t index, uint8_t
/* generic functions */
int nbgl_layoutDraw(nbgl_layout_t *layout);
int nbgl_layoutRelease(nbgl_layout_t *layout);

#else // TARGET_NANOS
void nbgl_screenHandler(uint32_t intervaleMs);
void nbgl_refresh(void);
void nbgl_layoutGet(const nbgl_layoutDescription_t *description);
void nbgl_layoutAddNavigation(nbgl_layoutNavigation_t *info);
void nbgl_layoutAddText(const char *text,
int line,
bool bold,
bool centered);
void nbgl_layoutAddCenteredInfo(const nbgl_layoutCenteredInfo_t *info);
void nbgl_layoutDraw(void);
void nbgl_layoutRelease(void);
#endif
/**********************
* MACROS
**********************/
Expand Down
2 changes: 2 additions & 0 deletions sdk_lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ extern "C" {

#include "nbgl_types.h"
#include "nbgl_fonts.h"
#ifndef TARGET_NANOS
#include "ux_loc.h"
#endif

/*********************
* INCLUDES
Expand Down
14 changes: 12 additions & 2 deletions sdk_lib_nbgl/include/nbgl_step.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ typedef uint8_t nbgl_stepPosition_t;
/**********************
* GLOBAL PROTOTYPES
**********************/

#ifndef TARGET_NANOS
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t *ticker,
Expand All @@ -103,7 +103,17 @@ nbgl_step_t nbgl_stepDrawMenuList(nbgl_stepMenuListCallback_t onActionCall
bool modal);
uint8_t nbgl_stepGetMenuListCurrent(nbgl_step_t step);
int nbgl_stepRelease(nbgl_step_t step);

#else
void nbgl_screenDraw(nbgl_stepPosition_t pos,
nbgl_stepButtonCallback_t onActionCallback,
nbgl_screenTickerConfiguration_t *ticker,
const char *text,
const char *subText,
const nbgl_icon_details_t *icon, // TODO change for bagl_icon_details_t
bool centered,
bool text_bold,
bool horizontal_nav);
#endif
/**********************
* MACROS
**********************/
Expand Down
5 changes: 5 additions & 0 deletions sdk_lib_nbgl/src/nbgl_buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ void nbgl_buttonsHandler(uint8_t buttonState, uint32_t currentTimeMs)
button_mask &= ~RELEASED_MASK;
}

#ifndef TARGET_NANOS
nbgl_screen_t *topScreen = (nbgl_screen_t *) nbgl_screenGetTop();
if ((topScreen != NULL) && (topScreen->buttonCallback != NULL)) {
nbgl_buttonEvent_t event = maskToEvent(button_mask);
if (event != INVALID_BUTTON_EVENT) {
topScreen->buttonCallback(topScreen, event);
}
}
#else
nbgl_buttonEvent_t event = maskToEvent(button_mask);
layout_buttonCallback(event);

Check warning

Code scanning / CodeQL

Implicit function declaration Warning

Function call implicitly declares 'layout_buttonCallback'.
#endif
}

void nbgl_buttonsReset(void)
Expand Down
Loading

0 comments on commit e671ce6

Please sign in to comment.