From 3b1f44945ae16143d307f1f049b56f8964bf4d83 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 31 Jul 2019 18:34:33 +0200 Subject: [PATCH] legacy: use fixed font for showing internal entropy --- legacy/firmware/reset.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/legacy/firmware/reset.c b/legacy/firmware/reset.c index d00ec7c9f..6666b2e97 100644 --- a/legacy/firmware/reset.c +++ b/legacy/firmware/reset.c @@ -23,6 +23,7 @@ #include "fsm.h" #include "gettext.h" #include "layout2.h" +#include "oled.h" #include "memzero.h" #include "messages.h" #include "messages.pb.h" @@ -65,20 +66,36 @@ void reset_init(bool display_random, uint32_t _strength, random_buffer(int_entropy, 32); - char ent_str[4][17]; - data2hex(int_entropy, 8, ent_str[0]); - data2hex(int_entropy + 8, 8, ent_str[1]); - data2hex(int_entropy + 16, 8, ent_str[2]); - data2hex(int_entropy + 24, 8, ent_str[3]); - if (display_random) { - layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Continue"), NULL, - _("Internal entropy:"), ent_str[0], ent_str[1], - ent_str[2], ent_str[3], NULL); - if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) { - fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); - layoutHome(); - return; + for (int start = 0; start < 2; start++) { + char ent_str[4][17]; + char desc[] = "Internal entropy _/2:"; + data2hex(int_entropy + start * 16, 4, ent_str[0]); + data2hex(int_entropy + start * 16 + 4, 4, ent_str[1]); + data2hex(int_entropy + start * 16 + 8, 4, ent_str[2]); + data2hex(int_entropy + start * 16 + 12, 4, ent_str[3]); + layoutLast = layoutDialogSwipe; + layoutSwipe(); + desc[17] = '1' + start; + oledDrawStringCenter(OLED_WIDTH / 2, 0, desc, FONT_STANDARD); + oledDrawStringCenter(OLED_WIDTH / 2, 2 + 1 * 9, ent_str[0], FONT_FIXED); + oledDrawStringCenter(OLED_WIDTH / 2, 2 + 2 * 9, ent_str[1], FONT_FIXED); + oledDrawStringCenter(OLED_WIDTH / 2, 2 + 3 * 9, ent_str[2], FONT_FIXED); + oledDrawStringCenter(OLED_WIDTH / 2, 2 + 4 * 9, ent_str[3], FONT_FIXED); + oledHLine(OLED_HEIGHT - 13); + layoutButtonNo(_("Cancel")); + layoutButtonYes(_("Continue")); + // 40 is the maximum pixels used for a row + oledSCA(2 + 1 * 9, 2 + 1 * 9 + 6, 40); + oledSCA(2 + 2 * 9, 2 + 2 * 9 + 6, 40); + oledSCA(2 + 3 * 9, 2 + 3 * 9 + 6, 40); + oledSCA(2 + 4 * 9, 2 + 4 * 9 + 6, 40); + oledRefresh(); + if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) { + fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); + layoutHome(); + return; + } } }