diff --git a/extmod/modtrezorui/display.c b/extmod/modtrezorui/display.c index 09d3b12849..10ff225cb1 100644 --- a/extmod/modtrezorui/display.c +++ b/extmod/modtrezorui/display.c @@ -13,6 +13,7 @@ #include "trezor-qrenc/qr_encode.h" #include "display.h" +#include #if defined STM32_HAL_H #include "display-stmhal.h" @@ -238,6 +239,12 @@ void display_qrcode(uint8_t x, uint8_t y, const char *data, int datalen, int sca #include "loader.h" +static void inflate_callback_loader(uint8_t byte, uint32_t pos, void *userdata) +{ + uint8_t *out = (uint8_t *)userdata; + out[pos] = byte; +} + void display_loader(uint16_t progress, uint16_t fgcolor, uint16_t bgcolor, const uint8_t *icon, uint16_t iconfgcolor) { uint16_t colortable[16], iconcolortable[16]; @@ -246,6 +253,13 @@ void display_loader(uint16_t progress, uint16_t fgcolor, uint16_t bgcolor, const set_color_table(iconcolortable, iconfgcolor, bgcolor); } display_set_window(RESX / 2 - img_loader_size, RESY * 2 / 5 - img_loader_size, img_loader_size * 2, img_loader_size * 2); + if (icon && memcmp(icon, "TOIg\x60\x00\x60\x00", 8) == 0) { + uint8_t icondata[96 * 96 / 2]; + sinf_inflate(icon + 12, inflate_callback_loader, icondata); + icon = icondata; + } else { + icon = NULL; + } for (int y = 0; y < img_loader_size * 2; y++) { for (int x = 0; x < img_loader_size * 2; x++) { int mx = x, my = y; diff --git a/extmod/modtrezorui/modtrezorui-display.h b/extmod/modtrezorui/modtrezorui-display.h index 14ece88f5e..e97c1feed2 100644 --- a/extmod/modtrezorui/modtrezorui-display.h +++ b/extmod/modtrezorui/modtrezorui-display.h @@ -211,13 +211,6 @@ STATIC mp_obj_t mod_TrezorUi_Display_qrcode(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_qrcode_obj, 5, 5, mod_TrezorUi_Display_qrcode); - -static void inflate_callback_loader(uint8_t byte, uint32_t pos, void *userdata) -{ - uint8_t *out = (uint8_t *)userdata; - out[pos] = byte; -} - /// def trezor.ui.display.loader(progress: int, fgcolor: int, bgcolor: int, icon: bytes=None, iconfgcolor: int=None) -> None /// /// Renders a rotating loader graphic. @@ -245,15 +238,13 @@ STATIC mp_obj_t mod_TrezorUi_Display_loader(size_t n_args, const mp_obj_t *args) if (datalen != icon.len - 12) { nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Invalid size of data")); } - uint8_t icondata[96 * 96 /2]; - sinf_inflate(data + 12, inflate_callback_loader, icondata); uint16_t iconfgcolor; if (n_args > 5) { // icon color provided iconfgcolor = mp_obj_get_int(args[5]); } else { iconfgcolor = ~bgcolor; // invert } - display_loader(progress, fgcolor, bgcolor, icondata, iconfgcolor); + display_loader(progress, fgcolor, bgcolor, data, iconfgcolor); } else { display_loader(progress, fgcolor, bgcolor, NULL, 0); }