Skip to content

Commit

Permalink
feat: implement NBGL menu and remove unused UI components
Browse files Browse the repository at this point in the history
- Remove commented-out global UI state variables
- Comment out unused UI preprocessing and display functions
- Add NBGL menu implementation with app info and settings
- Update version references in app configuration handler
  • Loading branch information
keiff3r committed Feb 6, 2025
1 parent 2e0c05d commit 813f5d8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "os.h"
#include "ux.h"

ux_state_t G_ux;
bolos_ux_params_t G_ux_params;
// ux_state_t G_ux;
// bolos_ux_params_t G_ux_params;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// display stepped screens
unsigned int ux_step;
Expand Down
8 changes: 5 additions & 3 deletions src/handler/get_app_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ void handleGetAppConfiguration(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint
UNUSED(flags);
VALIDATE(p1 == 0 && p2 == 0 && dataLength == 0, ERR_INVALID_REQUEST);

G_io_apdu_buffer[0] = LEDGER_MAJOR_VERSION;
G_io_apdu_buffer[1] = LEDGER_MINOR_VERSION;
G_io_apdu_buffer[2] = LEDGER_PATCH_VERSION;
G_io_apdu_buffer[0] = MAJOR_VERSION;
G_io_apdu_buffer[1] = MINOR_VERSION;
G_io_apdu_buffer[2] = PATCH_VERSION;
*tx = 3;
THROW(SUCCESS);


}
10 changes: 5 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "menu.h"
#include "apdu_constants.h"

unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
// unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

BocContext_t boc_context;
DataContext_t data_context;
Expand Down Expand Up @@ -164,10 +164,10 @@ void app_main(void) {
return;
}

// override point, but nothing more to do
void io_seproxyhal_display(const bagl_element_t *element) {
io_seproxyhal_display_default((bagl_element_t*)element);
}
// // override point, but nothing more to do
// void io_seproxyhal_display(const bagl_element_t *element) {
// io_seproxyhal_display_default((bagl_element_t*)element);
// }

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

unsigned char io_event(unsigned char channel) {
UNUSED(channel);
Expand Down
34 changes: 34 additions & 0 deletions src/ui/menu_nbgl.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
#ifdef HAVE_NBGL

#include "menu.h"
#include "os.h"

// -----------------------------------------------------------
// --------------------- SETTINGS MENU -----------------------
// -----------------------------------------------------------
#define SETTING_INFO_NB 2
static const char* const INFO_TYPES[SETTING_INFO_NB] = {"Version", "Developer"};
static const char* const INFO_CONTENTS[SETTING_INFO_NB] = {APPVERSION, "Blooo"};
static const nbgl_contentInfoList_t infoList = {
.nbInfos = SETTING_INFO_NB,
.infoTypes = INFO_TYPES,
.infoContents = INFO_CONTENTS,
};

// -----------------------------------------------------------
// ----------------------- HOME PAGE -------------------------
// -----------------------------------------------------------

void ui_main_menu(void) {
tx_state->currentInstruction = -1;

nbgl_useCaseHomeAndSettings(APPNAME,
&C_app_everscale_64px,
NULL,
INIT_HOME_PAGE,
NULL,
&infoList,
NULL,
app_quit);
}

void app_quit(void) {
// exit app here
os_sched_exit(-1);
}

#endif
30 changes: 15 additions & 15 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ void send_response(uint8_t tx, bool approve) {
ui_main_menu();
}

unsigned int ui_prepro(const bagl_element_t *element) {
unsigned int display = 1;
if (element->component.userid > 0) {
display = (ux_step == element->component.userid - 1);
if (display) {
if (element->component.userid == 1) {
UX_CALLBACK_SET_INTERVAL(2000);
}
else {
UX_CALLBACK_SET_INTERVAL(MAX(3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7)));
}
}
}
return display;
}
// unsigned int ui_prepro(const bagl_element_t *element) {
// unsigned int display = 1;
// if (element->component.userid > 0) {
// display = (ux_step == element->component.userid - 1);
// if (display) {
// if (element->component.userid == 1) {
// UX_CALLBACK_SET_INTERVAL(2000);
// }
// else {
// UX_CALLBACK_SET_INTERVAL(MAX(3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7)));
// }
// }
// }
// return display;
// }

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

void writeUint32BE(uint32_t val, uint8_t *bytes) {
bytes[0] = (val >> 24) & 0xFF;
Expand Down
4 changes: 3 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
#include "os.h"
#include "cx.h"
#include "globals.h"
#include "ux.h"

#include <stdint.h>
#include <stdbool.h>

unsigned int ui_prepro(const bagl_element_t *element);
// unsigned int ui_prepro(const bagl_element_t *element);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
void get_public_key(uint32_t accountNumber, uint8_t* publicKeyArray);
void get_private_key(uint32_t accountNumber, cx_ecfp_private_key_t *privateKey);
void send_response(uint8_t tx, bool approve);


void writeUint32BE(uint32_t val, uint8_t *bytes);
void writeUint64BE(uint64_t val, uint8_t *bytes);

Expand Down

0 comments on commit 813f5d8

Please sign in to comment.