mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
embed/extmod/modtrezorui: refactor text bar prefill into from display.c into extmod
This commit is contained in:
parent
d5ae4d72b6
commit
a25af7d22a
@ -34,7 +34,6 @@ SOURCE_MOD += [
|
||||
CPPDEFINES_MOD += [
|
||||
'TREZOR_FONT_MONO_ENABLE',
|
||||
'TREZOR_FONT_NORMAL_ENABLE',
|
||||
('TREZOR_FONT_PREFILL', '0'),
|
||||
('QR_MAX_VERSION', '0'),
|
||||
]
|
||||
SOURCE_MOD += [
|
||||
|
@ -75,9 +75,9 @@ void ui_screen_boot(const vendor_header * const vhdr, const image_header * const
|
||||
}
|
||||
|
||||
if (show_string) {
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 50, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_WHITE, boot_background, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 50, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_WHITE, boot_background);
|
||||
const char *ver_str = format_ver("%d.%d.%d", fw_version);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 25, ver_str, -1, FONT_NORMAL, COLOR_WHITE, boot_background, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 25, ver_str, -1, FONT_NORMAL, COLOR_WHITE, boot_background);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,12 +86,12 @@ void ui_screen_boot_wait(int wait_seconds)
|
||||
char wait_str[16];
|
||||
mini_snprintf(wait_str, sizeof(wait_str), "starting in %d s", wait_seconds);
|
||||
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, wait_str, -1, FONT_NORMAL, COLOR_WHITE, boot_background, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, wait_str, -1, FONT_NORMAL, COLOR_WHITE, boot_background);
|
||||
}
|
||||
|
||||
void ui_screen_boot_click(void) {
|
||||
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, "click to continue ...", -1, FONT_NORMAL, COLOR_WHITE, boot_background, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, "click to continue ...", -1, FONT_NORMAL, COLOR_WHITE, boot_background);
|
||||
}
|
||||
|
||||
// welcome UI
|
||||
@ -111,7 +111,7 @@ void ui_screen_third(void)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_icon((DISPLAY_RESX - 180) / 2, (DISPLAY_RESY - 30) / 2, 180, 30, toi_icon_welcome + 12, sizeof(toi_icon_welcome) - 12, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
// info UI
|
||||
@ -120,30 +120,30 @@ void ui_screen_info(secbool buttons, const vendor_header * const vhdr, const ima
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
const char *ver_str = format_ver("Bootloader %d.%d.%d", VERSION_UINT32);
|
||||
display_text(16, 32, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(16, 32, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BLACK);
|
||||
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12, COLOR_BL_GRAY, COLOR_WHITE);
|
||||
if (vhdr && hdr) {
|
||||
ver_str = format_ver("Firmware %d.%d.%d", (hdr->version));
|
||||
display_text(55, 70, ver_str, -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE, 0);
|
||||
display_text(55, 95, "by", -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE, 0);
|
||||
display_text(55, 120, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE, 0);
|
||||
display_text(55, 70, ver_str, -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE);
|
||||
display_text(55, 95, "by", -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE);
|
||||
display_text(55, 120, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE);
|
||||
} else {
|
||||
display_text(55, 70, "No Firmware", -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE, 0);
|
||||
display_text(55, 70, "No Firmware", -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_WHITE);
|
||||
}
|
||||
|
||||
if (sectrue == buttons) {
|
||||
display_text_center(120, 170, "Connect to host?", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(120, 170, "Connect to host?", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
ui_confirm_cancel_buttons();
|
||||
} else {
|
||||
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_screen_info_fingerprint(const image_header * const hdr)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_text(16, 32, "Firmware fingerprint", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(16, 32, "Firmware fingerprint", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BLACK);
|
||||
|
||||
static const char *hexdigits = "0123456789abcdef";
|
||||
@ -153,7 +153,7 @@ void ui_screen_info_fingerprint(const image_header * const hdr)
|
||||
fingerprint_str[i * 2 + 1] = hexdigits[hdr->fingerprint[i] & 0xF];
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
display_text_center(120, 70 + i * 25, fingerprint_str + i * 16, 16, FONT_MONO, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(120, 70 + i * 25, fingerprint_str + i * 16, 16, FONT_MONO, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
display_bar_radius(9, 184, 222, 50, COLOR_BL_DONE, COLOR_WHITE, 4);
|
||||
@ -165,27 +165,27 @@ void ui_screen_info_fingerprint(const image_header * const hdr)
|
||||
void ui_screen_install_confirm_upgrade(const vendor_header * const vhdr, const image_header * const hdr)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_text(16, 32, "Firmware update", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(16, 32, "Firmware update", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BLACK);
|
||||
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 70, "Update firmware by", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 95, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 70, "Update firmware by", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 95, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
const char *ver_str = format_ver("to version %d.%d.%d?", hdr->version);
|
||||
display_text(55, 120, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 120, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
ui_confirm_cancel_buttons();
|
||||
}
|
||||
|
||||
void ui_screen_install_confirm_newvendor(const vendor_header * const vhdr, const image_header * const hdr)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_text(16, 32, "Vendor change", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(16, 32, "Vendor change", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BLACK);
|
||||
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 70, "Install firmware by", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 95, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 70, "Install firmware by", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 95, vhdr->vstr, vhdr->vstr_len, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
const char *ver_str = format_ver("(version %d.%d.%d)?", hdr->version);
|
||||
display_text(55, 120, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL, COLOR_BL_FAIL, COLOR_WHITE, 0);
|
||||
display_text(55, 120, ver_str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL, COLOR_BL_FAIL, COLOR_WHITE);
|
||||
ui_confirm_cancel_buttons();
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ void ui_screen_install(void)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_loader(0, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_install, sizeof(toi_icon_install), COLOR_BLACK);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Installing firmware", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Installing firmware", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
void ui_screen_install_progress_erase(int pos, int len)
|
||||
@ -211,13 +211,13 @@ void ui_screen_install_progress_upload(int pos)
|
||||
void ui_screen_wipe_confirm(void)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_text(16, 32, "Wipe device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(16, 32, "Wipe device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BLACK);
|
||||
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 70, "Do you want to", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 95, "wipe the device?", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text(55, 70, "Do you want to", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
display_text(55, 95, "wipe the device?", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
|
||||
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL, COLOR_BL_FAIL, COLOR_WHITE, 0);
|
||||
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL, COLOR_BL_FAIL, COLOR_WHITE);
|
||||
ui_confirm_cancel_buttons();
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ void ui_screen_wipe(void)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_loader(0, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_wipe, sizeof(toi_icon_wipe), COLOR_BLACK);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Wiping device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Wiping device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
void ui_screen_wipe_progress(int pos, int len)
|
||||
@ -252,7 +252,7 @@ void ui_screen_done(int restart_seconds, secbool full_redraw)
|
||||
if (secfalse == full_redraw) {
|
||||
display_bar(0, DISPLAY_RESY - 24 - 18, 240, 23, COLOR_WHITE);
|
||||
}
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, str, -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
// error UI
|
||||
@ -261,7 +261,7 @@ void ui_screen_fail(void)
|
||||
{
|
||||
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
|
||||
display_loader(1000, -20, COLOR_BL_FAIL, COLOR_WHITE, toi_icon_fail, sizeof(toi_icon_fail), COLOR_BLACK);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Failed! Please, reconnect.", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Failed! Please, reconnect.", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE);
|
||||
}
|
||||
|
||||
// general functions
|
||||
|
@ -37,6 +37,9 @@ static int DISPLAY_OFFSET[2] = {0, 0};
|
||||
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
|
||||
#endif
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
// common display functions
|
||||
|
||||
static inline uint16_t interpolate_color(uint16_t color0, uint16_t color1, uint8_t step)
|
||||
@ -57,8 +60,6 @@ static inline void set_color_table(uint16_t colortable[16], uint16_t fgcolor, ui
|
||||
|
||||
static inline void clamp_coords(int x, int y, int w, int h, int *x0, int *y0, int *x1, int *y1)
|
||||
{
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
*x0 = MAX(x, 0);
|
||||
*y0 = MAX(y, 0);
|
||||
*x1 = MIN(x + w - 1, DISPLAY_RESX - 1);
|
||||
@ -457,41 +458,26 @@ static void display_text_render(int x, int y, const char *text, int textlen, uin
|
||||
}
|
||||
}
|
||||
|
||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth)
|
||||
void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor)
|
||||
{
|
||||
x += DISPLAY_OFFSET[0];
|
||||
y += DISPLAY_OFFSET[1];
|
||||
#if TREZOR_FONT_PREFILL
|
||||
int w = display_text_width(text, textlen, font);
|
||||
int barwidth = max(w, minwidth);
|
||||
display_bar(x - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
#endif
|
||||
display_text_render(x, y, text, textlen, font, fgcolor, bgcolor);
|
||||
}
|
||||
|
||||
void display_text_center(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth)
|
||||
void display_text_center(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor)
|
||||
{
|
||||
x += DISPLAY_OFFSET[0];
|
||||
y += DISPLAY_OFFSET[1];
|
||||
int w = display_text_width(text, textlen, font);
|
||||
#if TREZOR_FONT_PREFILL
|
||||
int barwidth = max(w, minwidth);
|
||||
display_bar(x - barwidth / 2 - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
#endif
|
||||
display_text_render(x - w / 2, y, text, textlen, font, fgcolor, bgcolor);
|
||||
}
|
||||
|
||||
void display_text_right(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth)
|
||||
void display_text_right(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor)
|
||||
{
|
||||
x += DISPLAY_OFFSET[0];
|
||||
y += DISPLAY_OFFSET[1];
|
||||
int w = display_text_width(text, textlen, font);
|
||||
#if TREZOR_FONT_PREFILL
|
||||
int barwidth = max(w, minwidth);
|
||||
display_bar(x - barwidth - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
#endif
|
||||
display_text_render(x - w, y, text, textlen, font, fgcolor, bgcolor);
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,6 @@
|
||||
#ifdef TREZOR_FONT_BOLD_ENABLE
|
||||
#define FONT_BOLD 2
|
||||
#endif
|
||||
#ifndef TREZOR_FONT_PREFILL
|
||||
#define TREZOR_FONT_PREFILL 1
|
||||
#endif
|
||||
|
||||
#define AVATAR_IMAGE_SIZE 144
|
||||
#define LOADER_ICON_SIZE 64
|
||||
@ -64,9 +61,9 @@ void display_print(const char *text, int textlen);
|
||||
void display_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
#endif
|
||||
|
||||
void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth);
|
||||
void display_text_center(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth);
|
||||
void display_text_right(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor, int minwidth);
|
||||
void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor);
|
||||
void display_text_center(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor);
|
||||
void display_text_right(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor);
|
||||
int display_text_width(const char *text, int textlen, uint8_t font);
|
||||
|
||||
void display_qrcode(int x, int y, const char *data, int datalen, uint8_t scale);
|
||||
|
@ -196,7 +196,12 @@ STATIC mp_obj_t mod_trezorui_Display_text(size_t n_args, const mp_obj_t *args) {
|
||||
mp_int_t fgcolor = mp_obj_get_int(args[5]);
|
||||
mp_int_t bgcolor = mp_obj_get_int(args[6]);
|
||||
mp_int_t minwidth = (n_args > 7) ? mp_obj_get_int(args[7]) : 0;
|
||||
display_text(x, y, text.buf, text.len, font, fgcolor, bgcolor, minwidth);
|
||||
// prefill start
|
||||
int w = display_text_width(text.buf, text.len, font);
|
||||
int barwidth = MAX(w, minwidth);
|
||||
display_bar(x - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
// prefill end
|
||||
display_text(x, y, text.buf, text.len, font, fgcolor, bgcolor);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_text_obj, 7, 8, mod_trezorui_Display_text);
|
||||
@ -215,7 +220,12 @@ STATIC mp_obj_t mod_trezorui_Display_text_center(size_t n_args, const mp_obj_t *
|
||||
mp_int_t fgcolor = mp_obj_get_int(args[5]);
|
||||
mp_int_t bgcolor = mp_obj_get_int(args[6]);
|
||||
mp_int_t minwidth = (n_args > 7) ? mp_obj_get_int(args[7]) : 0;
|
||||
display_text_center(x, y, text.buf, text.len, font, fgcolor, bgcolor, minwidth);
|
||||
// prefill start
|
||||
int w = display_text_width(text.buf, text.len, font);
|
||||
int barwidth = MAX(w, minwidth);
|
||||
display_bar(x - barwidth / 2 - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
// prefill end
|
||||
display_text_center(x, y, text.buf, text.len, font, fgcolor, bgcolor);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_text_center_obj, 7, 8, mod_trezorui_Display_text_center);
|
||||
@ -234,7 +244,12 @@ STATIC mp_obj_t mod_trezorui_Display_text_right(size_t n_args, const mp_obj_t *a
|
||||
mp_int_t fgcolor = mp_obj_get_int(args[5]);
|
||||
mp_int_t bgcolor = mp_obj_get_int(args[6]);
|
||||
mp_int_t minwidth = (n_args > 7) ? mp_obj_get_int(args[7]) : 0;
|
||||
display_text_right(x, y, text.buf, text.len, font, fgcolor, bgcolor, minwidth);
|
||||
// prefill start
|
||||
int w = display_text_width(text.buf, text.len, font);
|
||||
int barwidth = MAX(w, minwidth);
|
||||
display_bar(x - barwidth - 1, y - 18, barwidth + 2, 23, bgcolor);
|
||||
// prefill end
|
||||
display_text_right(x, y, text.buf, text.len, font, fgcolor, bgcolor);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_text_right_obj, 7, 8, mod_trezorui_Display_text_right);
|
||||
|
@ -317,7 +317,7 @@ int main(void)
|
||||
// format: TREZOR2-YYMMDD
|
||||
if (sectrue == flash_otp_read(0, 0, (uint8_t *)dom, 32) && 0 == memcmp(dom, "TREZOR2-", 8) && dom[31] == 0) {
|
||||
display_qrcode(DISPLAY_RESX / 2, DISPLAY_RESY / 2, dom, strlen(dom), 4);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 30, dom + 8, -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK, 0);
|
||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 30, dom + 8, -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
||||
}
|
||||
|
||||
display_fade(0, BACKLIGHT_NORMAL, 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user