1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

Remove duplicated code

This commit is contained in:
Jochen Hoenicke 2018-02-06 22:34:31 +01:00 committed by Pavol Rusnak
parent 83a69a0334
commit b9b36e0768
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 21 additions and 17 deletions

View File

@ -320,9 +320,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last)
oledDrawString(left, 2 * 9, word_pos < 10 ? index_str + 1 : index_str, FONT_STANDARD);
oledDrawString(left, 3 * 9, word, FONT_STANDARD | FONT_DOUBLE);
oledHLine(OLED_HEIGHT - 13);
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);
layoutButtonYes(btnYes);
oledRefresh();
}
@ -500,16 +498,10 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
}
if (!qrcode) {
static const char *btnNo = _("QR Code");
oledDrawString(2, OLED_HEIGHT - 8, btnNo, FONT_STANDARD);
oledInvert(0, OLED_HEIGHT - 9, oledStringWidth(btnNo, FONT_STANDARD) + 3, OLED_HEIGHT - 1);
layoutButtonNo(_("QR Code"));
}
static const char *btnYes = _("Continue");
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);
layoutButtonYes(_("Continue"));
oledRefresh();
}

View File

@ -22,6 +22,20 @@
#include "layout.h"
#include "oled.h"
void layoutButtonNo(const char *btnNo)
{
oledDrawString(1, OLED_HEIGHT - 8, "\x15", FONT_STANDARD);
oledDrawString(fontCharWidth(FONT_STANDARD, '\x15') + 3, OLED_HEIGHT - 8, btnNo, FONT_STANDARD);
oledInvert(0, OLED_HEIGHT - 9, fontCharWidth(FONT_STANDARD, '\x15') + 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 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, const char *line6)
{
int left = 0;
@ -47,14 +61,10 @@ void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, con
}
}
if (btnNo) {
oledDrawString(1, OLED_HEIGHT - 8, "\x15", FONT_STANDARD);
oledDrawString(fontCharWidth(FONT_STANDARD, '\x15') + 3, OLED_HEIGHT - 8, btnNo, FONT_STANDARD);
oledInvert(0, OLED_HEIGHT - 9, fontCharWidth(FONT_STANDARD, '\x15') + oledStringWidth(btnNo, FONT_STANDARD) + 2, OLED_HEIGHT - 1);
layoutButtonNo(btnNo);
}
if (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);
layoutButtonYes(btnYes);
}
oledRefresh();
}

View File

@ -24,6 +24,8 @@
#include <stdbool.h>
#include "bitmaps.h"
void layoutButtonNo(const char *btnNo);
void layoutButtonYes(const char *btnYes);
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, const char *line6);
void layoutProgressUpdate(bool refresh);
void layoutProgress(const char *desc, int permil);