From ee98d0b398886cd14011f81b32b1e69404d97375 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 9 Nov 2019 16:12:36 +0000 Subject: [PATCH] legacy/layout: use bmp_btn_confirm, bmp_btn_cancel --- legacy/firmware/layout2.c | 10 ++++---- legacy/firmware/reset.c | 4 ++-- legacy/firmware/stellar.c | 17 ++----------- legacy/gen/bitmaps.c | 4 ++++ legacy/gen/bitmaps.h | 2 ++ legacy/gen/bitmaps/btn_cancel.png | Bin 0 -> 877 bytes legacy/gen/bitmaps/btn_confirm.png | Bin 0 -> 844 bytes legacy/layout.c | 37 ++++++++++++++++------------- legacy/layout.h | 4 ++-- 9 files changed, 38 insertions(+), 40 deletions(-) create mode 100644 legacy/gen/bitmaps/btn_cancel.png create mode 100644 legacy/gen/bitmaps/btn_confirm.png diff --git a/legacy/firmware/layout2.c b/legacy/firmware/layout2.c index e482a80e3..799794b1a 100644 --- a/legacy/firmware/layout2.c +++ b/legacy/firmware/layout2.c @@ -339,8 +339,8 @@ static void render_address_dialog(const CoinInfo *coin, const char *address, oledHLine(OLED_HEIGHT - 13); } } - layoutButtonNo(_("Cancel")); - layoutButtonYes(_("Confirm")); + layoutButtonNo(_("Cancel"), &bmp_btn_cancel); + layoutButtonYes(_("Confirm"), &bmp_btn_confirm); oledRefresh(); } @@ -555,7 +555,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) { // 30 is the maximum pixels used for a pixel row in the BIP39 word "abstract" oledSCA(4 * 9 - 3 - 2, 4 * 9 - 3 + 15 + 2, 30); oledInvert(0, 4 * 9 - 3 - 2, OLED_WIDTH - 1, 4 * 9 - 3 + 15 + 2); - layoutButtonYes(btnYes); + layoutButtonYes(btnYes, &bmp_btn_confirm); oledRefresh(); } @@ -634,10 +634,10 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, } if (!qrcode) { - layoutButtonNo(_("QR Code")); + layoutButtonNo(_("QR Code"), NULL); } - layoutButtonYes(_("Continue")); + layoutButtonYes(_("Continue"), &bmp_btn_confirm); oledRefresh(); } diff --git a/legacy/firmware/reset.c b/legacy/firmware/reset.c index b80fe803a..a9031ade3 100644 --- a/legacy/firmware/reset.c +++ b/legacy/firmware/reset.c @@ -83,8 +83,8 @@ void reset_init(bool display_random, uint32_t _strength, 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")); + layoutButtonNo(_("Cancel"), &bmp_btn_cancel); + layoutButtonYes(_("Continue"), &bmp_btn_confirm); // 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); diff --git a/legacy/firmware/stellar.c b/legacy/firmware/stellar.c index 3607104f7..948aabd4c 100644 --- a/legacy/firmware/stellar.c +++ b/legacy/firmware/stellar.c @@ -1792,13 +1792,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2, offset_y += line_height; // Cancel button - oledDrawString(1, OLED_HEIGHT - 8, "\x15", FONT_STANDARD); - oledDrawString(fontCharWidth(FONT_STANDARD, '\x15') + 3, OLED_HEIGHT - 8, - "Cancel", FONT_STANDARD); - oledInvert(0, OLED_HEIGHT - 9, - fontCharWidth(FONT_STANDARD, '\x15') + - oledStringWidth("Cancel", FONT_STANDARD) + 2, - OLED_HEIGHT - 1); + layoutButtonNo("Cancel", &bmp_btn_cancel); // Warnings (drawn centered between the buttons if (warning) { @@ -1814,14 +1808,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2, strlcpy(str_next_label, _("Next"), sizeof(str_next_label)); } - oledDrawString(OLED_WIDTH - fontCharWidth(FONT_STANDARD, '\x06') - 1, - OLED_HEIGHT - 8, "\x06", FONT_STANDARD); - oledDrawString(OLED_WIDTH - oledStringWidth(str_next_label, FONT_STANDARD) - - fontCharWidth(FONT_STANDARD, '\x06') - 3, - OLED_HEIGHT - 8, str_next_label, FONT_STANDARD); - oledInvert(OLED_WIDTH - oledStringWidth(str_next_label, FONT_STANDARD) - - fontCharWidth(FONT_STANDARD, '\x06') - 4, - OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1); + layoutButtonYes(str_next_label, &bmp_btn_confirm); oledRefresh(); } diff --git a/legacy/gen/bitmaps.c b/legacy/gen/bitmaps.c index 7b40e628f..f1da68e47 100644 --- a/legacy/gen/bitmaps.c +++ b/legacy/gen/bitmaps.c @@ -1,6 +1,8 @@ // clang-format off #include "bitmaps.h" +const uint8_t bmp_btn_cancel_data[] = { 0x44, 0xee, 0x7c, 0x38, 0x7c, 0xee, 0x44, 0x00, }; +const uint8_t bmp_btn_confirm_data[] = { 0x02, 0x04, 0x08, 0xd8, 0xf0, 0x60, 0x20, 0x00, }; const uint8_t bmp_digit0_data[] = { 0xff, 0xff, 0xf8, 0x1f, 0xf0, 0x0f, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xf0, 0x0f, 0xf8, 0x1f, 0xff, 0xff, }; const uint8_t bmp_digit1_data[] = { 0xff, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf0, 0x3f, 0xf0, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xff, 0xff, }; const uint8_t bmp_digit2_data[] = { 0xff, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xf8, 0x0f, 0xf0, 0x1f, 0xe1, 0xff, 0xe1, 0xff, 0xe1, 0xff, 0xe1, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0xff, 0xff, }; @@ -26,6 +28,8 @@ const uint8_t bmp_logo64_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x const uint8_t bmp_logo64_empty_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x04, 0x00, 0x00, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x07, 0xe0, 0x10, 0x00, 0x00, 0x10, 0x08, 0x10, 0x08, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x20, 0x20, 0x04, 0x04, 0x00, 0x00, 0x20, 0x40, 0x02, 0x04, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x00, 0x40, 0x80, 0x01, 0x02, 0x00, 0x1f, 0xc0, 0xff, 0xff, 0x03, 0xf8, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x3f, 0xff, 0xff, 0xfc, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x04, 0x08, 0x10, 0x18, 0x00, 0x00, 0x18, 0x08, 0x10, 0x06, 0x00, 0x00, 0x60, 0x08, 0x10, 0x01, 0x80, 0x01, 0x80, 0x08, 0x10, 0x00, 0x60, 0x06, 0x00, 0x08, 0x18, 0x00, 0x18, 0x18, 0x00, 0x18, 0x06, 0x00, 0x06, 0x60, 0x00, 0x60, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x60, 0x00, 0x00, 0x06, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const uint8_t bmp_webauthn_data[] = { 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x03, 0xfe, 0x1c, 0x00, 0x03, 0xfc, 0x0c, 0x00, 0x07, 0xf8, 0x06, 0x00, 0x07, 0xf8, 0x06, 0x00, 0x0f, 0xf8, 0x06, 0x00, 0x0f, 0xf8, 0x07, 0x00, 0x0f, 0xfc, 0x0f, 0x00, 0x0f, 0xfe, 0x1f, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xfc, 0x00, 0x7f, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xe0, 0x01, 0xff, 0xdf, 0x80, 0x03, 0xff, 0x80, 0x00, 0x07, 0xff, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, }; +const BITMAP bmp_btn_cancel = {8, 8, bmp_btn_cancel_data}; +const BITMAP bmp_btn_confirm = {8, 8, bmp_btn_confirm_data}; const BITMAP bmp_digit0 = {16, 16, bmp_digit0_data}; const BITMAP bmp_digit1 = {16, 16, bmp_digit1_data}; const BITMAP bmp_digit2 = {16, 16, bmp_digit2_data}; diff --git a/legacy/gen/bitmaps.h b/legacy/gen/bitmaps.h index 41bc1507d..08809e118 100644 --- a/legacy/gen/bitmaps.h +++ b/legacy/gen/bitmaps.h @@ -8,6 +8,8 @@ typedef struct { const uint8_t *data; } BITMAP; +extern const BITMAP bmp_btn_cancel; +extern const BITMAP bmp_btn_confirm; extern const BITMAP bmp_digit0; extern const BITMAP bmp_digit1; extern const BITMAP bmp_digit2; diff --git a/legacy/gen/bitmaps/btn_cancel.png b/legacy/gen/bitmaps/btn_cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..71befb829647a672b7a4016d44cee479184a1042 GIT binary patch literal 877 zcmV-z1CsoSP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+Rc`2lG`8*hW~Sl9szwJaU9IYOmEQRSJ;lT&8C}V z$2pg{u6)K)v}w#5-V_QvBt%%LIwni0~lI>0s}fU?<-V~k+GwCk64k` zF(bu{l_CN0G#IFqsgV&<#ZE*V2#;7`^_y3J70f+1@Tmwc2EOD=3y&r|V`J3lIRfzA z!=5XT3vqIQnMRsVpXNYd?A&Bc@WqZ6K7b`BC~KO{H(27bNh|`_+M=}p$mfaoTYZ7H zNe$O3VfQT_43Hy;2}mG8R73?}LUTaHBS&IfoB)Vm^B|FllCv?dBlqoV6xO*YxQ+W! zaXvzc)Y)Vz4vSg5ew58?s0ay*ND>v3EF~mLoFt{BX`Z>Fq^zPzRZX)NBV!Xwre>C{ zWX$A8QgX_gE$3W{`z#!a6klC@Mkxy}wD2NJT6D1`FQt0 z)^aNyx|dSu+@+_k-Foh2c&!Z@JY=My!$uzEpte)}WG_&Iof@vB<~%*9`Kam?S|woK zGcuVuF=TM!Ith3|<75^Mm~oPu%wk4A6@nh5Og0T-36LBicR(3%u)C6bnp^N(KjMbZ zkP8#t3FI(zy5V+*TAMdvU5Ra{aOO0UpFaQIt)LZ8Hf}F*ESItCkR7iN`*4nom2i#> zTKKli&8qN>%R924oQHE{{D_<*GjsH+%wJ@~(^ww#;XA0mne6AX7~a#k#uZ-k`*mf% zou6~?cKK+3_;jaDPg@*qNll|QM1}xBp5_+#Zod5s;Gf6~2R0!8&U|?YQ|NlP&48Ylp z2o@s>n-NV1M3jMnff3yVMyLo*9ZZ;N5$dqI3MT*n?vo(+_cVP(00000NkvXXu0mjf D3Q?RO literal 0 HcmV?d00001 diff --git a/legacy/gen/bitmaps/btn_confirm.png b/legacy/gen/bitmaps/btn_confirm.png new file mode 100644 index 0000000000000000000000000000000000000000..6c583952ee6593f72ea051c717f88361c02c24c7 GIT binary patch literal 844 zcmV-S1GD^zP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=HGvKuK3hTmDmECERfiRI8-spx zKF7|}3@W#}XdwxGf^rz&zs>Lu20433YMx8Z5hImUxZ=g*ZH!YNa}?A5ybL;@6z+at zXn~ev($e`=&iRXdzG^tS^MUlk0=b6a9|K!G=Q;9E8CAK)xNYbB&Dnj+zF;ka7I}2M+uJ%o{>3QM2(2B zdpc`{yqFgUT4j{=gc*R)Jh|y!;EP;G_yMedpzdXMY_P`daIq=fdQ0{O5ZEd7(O+bJ zQRBT!5@IWoApwGzNt7~0V>Y5B>;P1eIZNUV1W1)TlH??k!N$=?h>bNyyDcjp^EfKt zqmsqIrbq>>lob7A$2=URD}|AUjy!DmD5FmF+LW25&OB}UEVEvzom793Pf(+i8tPF^f(q@gldF#lkoh%1BZdn@+I?%0QR~u}-?OyODdETR^QJapPym zg@x`7_`P>|R zF^`)LUy6SxZ1`N<-|O&N9=A09$Nwz;J8t-~+n-j2r>6860000width; + } + oledDrawString(8 + 3, OLED_HEIGHT - icon_width, btnNo, FONT_STANDARD); oledInvert(0, OLED_HEIGHT - 9, - fontCharWidth(FONT_STANDARD, '\x15') + - oledStringWidth(btnNo, FONT_STANDARD) + 2, + icon_width + oledStringWidth(btnNo, FONT_STANDARD) + 2, OLED_HEIGHT - 1); } -void layoutButtonYes(const char *btnYes) { - oledDrawString(OLED_WIDTH - fontCharWidth(FONT_STANDARD, '\x06') - 1, - OLED_HEIGHT - 8, "\x06", FONT_STANDARD); - oledDrawStringRight(OLED_WIDTH - fontCharWidth(FONT_STANDARD, '\x06') - 3, - OLED_HEIGHT - 8, btnYes, FONT_STANDARD); - oledInvert(OLED_WIDTH - oledStringWidth(btnYes, FONT_STANDARD) - - fontCharWidth(FONT_STANDARD, '\x06') - 4, - OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1); +void layoutButtonYes(const char *btnYes, const BITMAP *icon) { + int icon_width = 0; + if (icon) { + oledDrawBitmap(OLED_WIDTH - 8 - 1, OLED_HEIGHT - 8, icon); + icon_width = icon->width; + } + oledDrawStringRight(OLED_WIDTH - icon_width - 3, OLED_HEIGHT - 8, btnYes, + FONT_STANDARD); + oledInvert( + OLED_WIDTH - oledStringWidth(btnYes, FONT_STANDARD) - icon_width - 4, + OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1); } void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, @@ -70,10 +75,10 @@ void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, } } if (btnNo) { - layoutButtonNo(btnNo); + layoutButtonNo(btnNo, &bmp_btn_cancel); } if (btnYes) { - layoutButtonYes(btnYes); + layoutButtonYes(btnYes, &bmp_btn_confirm); } oledRefresh(); } diff --git a/legacy/layout.h b/legacy/layout.h index 3656ffff5..4b3f92acf 100644 --- a/legacy/layout.h +++ b/legacy/layout.h @@ -24,8 +24,8 @@ #include #include "bitmaps.h" -void layoutButtonNo(const char *btnNo); -void layoutButtonYes(const char *btnYes); +void layoutButtonNo(const char *btnNo, const BITMAP *icon); +void layoutButtonYes(const char *btnYes, const BITMAP *icon); void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *line2, const char *line3, const char *line4, const char *line5,