Skip to content

Commit 9a82671

Browse files
authored
Merge pull request #44 from Zondax/add_init_menu
Add init menu
2 parents 5008bbb + 563818b commit 9a82671

7 files changed

Lines changed: 59 additions & 3 deletions

File tree

app/common/view.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ void h_error_accept(__Z_UNUSED unsigned int _) {
6565
}
6666

6767
void h_initialize(__Z_UNUSED unsigned int _) {
68+
ZEMU_LOGF(50, "Initialize function\n")
69+
if (viewdata.viewfuncInitialize != NULL) {
70+
viewdata.viewfuncInitialize();
71+
}
72+
6873
view_idle_show(0, NULL);
6974
UX_WAIT();
7075
}
@@ -365,6 +370,10 @@ void view_init(void) {
365370
#endif
366371
}
367372

373+
void view_initialize_show(uint8_t item_idx, char *statusString) {
374+
view_initialize_show_impl(item_idx, statusString);
375+
}
376+
368377
void view_idle_show(uint8_t item_idx, char *statusString) {
369378
view_idle_show_impl(item_idx, statusString);
370379
}
@@ -381,6 +390,10 @@ void view_review_init(viewfunc_getItem_t viewfuncGetItem,
381390
viewdata.viewfuncAccept = viewfuncAccept;
382391
}
383392

393+
void view_initialize_init(viewfunc_initialize_t viewFuncInit) {
394+
viewdata.viewfuncInitialize = viewFuncInit;
395+
}
396+
384397
void view_review_show(unsigned int requireReply) {
385398
// Set > 0 to reply apdu message
386399
view_review_show_impl(requireReply);

app/common/view.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ typedef zxerr_t (*viewfunc_getItem_t)(int8_t displayIdx,
3737

3838
typedef void (*viewfunc_accept_t)();
3939

40+
typedef zxerr_t (*viewfunc_initialize_t)();
41+
4042
#ifdef APP_SECRET_MODE_ENABLED
4143
zxerr_t secret_enabled();
4244
#endif
@@ -45,6 +47,7 @@ zxerr_t secret_enabled();
4547
void view_init();
4648

4749
/// view_initialize_show (idle view - main menu + status)
50+
void view_initialize_init(viewfunc_initialize_t viewFuncInit);
4851
void view_initialize_show(uint8_t item_idx, char *statusString);
4952

5053
/// view_idle_show (idle view - main menu + status)

app/common/view_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef struct {
102102
viewfunc_getItem_t viewfuncGetItem;
103103
viewfunc_getNumItems_t viewfuncGetNumItems;
104104
viewfunc_accept_t viewfuncAccept;
105+
viewfunc_initialize_t viewfuncInitialize;
105106

106107
#ifdef APP_SECRET_MODE_ENABLED
107108
uint8_t secret_click_count;

app/common/view_s.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ const ux_menu_entry_t menu_main[] = {
104104
};
105105

106106
const ux_menu_entry_t menu_initialize[] = {
107-
{NULL, NULL, 0, &C_icon_app, MENU_MAIN_APP_LINE1, viewdata.key, 33, 12},
107+
{NULL, NULL, 0, &C_icon_app, MENU_MAIN_APP_LINE1, "Not Ready", 33, 12},
108108
{NULL, h_initialize, 0, &C_icon_app, "Click to", "Initialize", 33, 12},
109-
{NULL, h_expert_toggle, 0, &C_icon_app, "Expert mode:", viewdata.value, 33, 12},
110109
{NULL, NULL, 0, &C_icon_app, APPVERSION_LINE1, APPVERSION_LINE2, 33, 12},
111110
{NULL, NULL, 0, &C_icon_app, "Developed by:", "Zondax.ch", 33, 12},
112111
{NULL, NULL, 0, &C_icon_app, "License: ", "Apache 2.0", 33, 12},

app/common/view_x.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
void account_enabled();
4040
void shortcut_enabled();
4141

42+
void h_initialize();
4243
static void h_expert_toggle();
4344
static void h_expert_update();
4445
static void h_review_loop_start();
@@ -108,6 +109,21 @@ const ux_flow_step_t *const ux_idle_flow [] = {
108109
FLOW_END_STEP,
109110
};
110111

112+
///////////
113+
UX_STEP_CB_INIT(ux_menu_init_flow_2_step, bn, NULL, h_initialize(), { "Click to", "Initialize", });
114+
UX_STEP_NOCB(ux_menu_init_flow_4_step, bn, { "Developed by:", "Zondax.ch", });
115+
116+
const ux_flow_step_t *const ux_menu_initialize [] = {
117+
&ux_idle_flow_1_step,
118+
&ux_menu_init_flow_2_step,
119+
&ux_idle_flow_3_step,
120+
&ux_menu_init_flow_4_step,
121+
&ux_idle_flow_5_step,
122+
&ux_idle_flow_6_step,
123+
124+
FLOW_END_STEP,
125+
};
126+
111127
///////////
112128

113129
UX_STEP_NOCB(ux_message_flow_1_step, pbb, { &C_icon_app, viewdata.key, viewdata.value,});
@@ -330,6 +346,19 @@ void view_idle_show_impl(__Z_UNUSED uint8_t item_idx, char *statusString) {
330346
ux_flow_init(0, ux_idle_flow, NULL);
331347
}
332348

349+
void view_initialize_show_impl(__Z_UNUSED uint8_t item_idx, char *statusString) {
350+
if (statusString == NULL ) {
351+
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", "Not Ready");
352+
} else {
353+
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", statusString);
354+
}
355+
356+
if(G_ux.stack_count == 0) {
357+
ux_stack_push();
358+
}
359+
ux_flow_init(0, ux_menu_initialize, NULL);
360+
}
361+
333362
void view_review_show_impl(unsigned int requireReply){
334363
review_type = requireReply;
335364
h_paging_init();

include/zxversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
#define ZXLIB_MAJOR 14
1919
#define ZXLIB_MINOR 1
20-
#define ZXLIB_PATCH 6
20+
#define ZXLIB_PATCH 7

scripts/getSize.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
3+
from ledgerblue.hexParser import IntelHexParser
4+
from math import ceil
5+
import sys
6+
7+
block_size = 2 if sys.argv[1] == "s" else 4
8+
parser = IntelHexParser("app/bin/app.hex")
9+
bytes = parser.maxAddr() - parser.minAddr()
10+
size = ceil(bytes / (block_size * 1024)) * block_size
11+
print(size)

0 commit comments

Comments
 (0)