diff --git a/core/embed/extmod/modtrezorui/display.c b/core/embed/extmod/modtrezorui/display.c index db2c69cdc..a377b0de3 100644 --- a/core/embed/extmod/modtrezorui/display.c +++ b/core/embed/extmod/modtrezorui/display.c @@ -872,8 +872,7 @@ int display_text_height(int font) { #define QR_MAX_VERSION 9 -void display_qrcode(int x, int y, const char *data, uint32_t datalen, - uint8_t scale) { +void display_qrcode(int x, int y, const char *data, uint8_t scale) { if (scale < 1 || scale > 10) return; uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0}; diff --git a/core/embed/extmod/modtrezorui/display.h b/core/embed/extmod/modtrezorui/display.h index 797cc6a85..dcad222e3 100644 --- a/core/embed/extmod/modtrezorui/display.h +++ b/core/embed/extmod/modtrezorui/display.h @@ -128,8 +128,7 @@ int display_text_split(const char *text, int textlen, int font, int requested_width); int display_text_height(int font); -void display_qrcode(int x, int y, const char *data, uint32_t datalen, - uint8_t scale); +void display_qrcode(int x, int y, const char *data, uint8_t scale); void display_offset(int set_xy[2], int *get_x, int *get_y); int display_orientation(int degrees); diff --git a/core/embed/extmod/modtrezorui/modtrezorui-display.h b/core/embed/extmod/modtrezorui/modtrezorui-display.h index 966c9efc7..0fb03c65e 100644 --- a/core/embed/extmod/modtrezorui/modtrezorui-display.h +++ b/core/embed/extmod/modtrezorui/modtrezorui-display.h @@ -476,7 +476,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_text_split_obj, 4, 4, mod_trezorui_Display_text_split); -/// def qrcode(self, x: int, y: int, data: bytes, scale: int) -> None: +/// def qrcode(self, x: int, y: int, data: str, scale: int) -> None: /// """ /// Renders data encoded as a QR code centered at position (x,y). /// Scale determines a zoom factor. @@ -489,10 +489,9 @@ STATIC mp_obj_t mod_trezorui_Display_qrcode(size_t n_args, if (scale < 1 || scale > 10) { mp_raise_ValueError("Scale has to be between 1 and 10"); } - mp_buffer_info_t data = {0}; - mp_get_buffer_raise(args[3], &data, MP_BUFFER_READ); - if (data.len > 0) { - display_qrcode(x, y, data.buf, data.len, scale); + const char *data = mp_obj_str_get_str(args[3]); + if (data) { + display_qrcode(x, y, data, scale); } return mp_const_none; } diff --git a/core/embed/prodtest/main.c b/core/embed/prodtest/main.c index d7350864e..b4e523426 100644 --- a/core/embed/prodtest/main.c +++ b/core/embed/prodtest/main.c @@ -385,7 +385,7 @@ int main(void) { // format: TREZOR2-YYMMDD if (sectrue == flash_otp_read(FLASH_OTP_BLOCK_BATCH, 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_qrcode(DISPLAY_RESX / 2, DISPLAY_RESY / 2, dom, 4); display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 30, dom + 8, -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK); } diff --git a/core/mocks/generated/trezorui.pyi b/core/mocks/generated/trezorui.pyi index 98c1a069e..2c992d779 100644 --- a/core/mocks/generated/trezorui.pyi +++ b/core/mocks/generated/trezorui.pyi @@ -175,7 +175,7 @@ class Display: font is used for rendering. """ - def qrcode(self, x: int, y: int, data: bytes, scale: int) -> None: + def qrcode(self, x: int, y: int, data: str, scale: int) -> None: """ Renders data encoded as a QR code centered at position (x,y). Scale determines a zoom factor. diff --git a/core/src/trezor/ui/qr.py b/core/src/trezor/ui/qr.py index e81e6f91b..6761795a1 100644 --- a/core/src/trezor/ui/qr.py +++ b/core/src/trezor/ui/qr.py @@ -40,5 +40,5 @@ class Qr(ui.Component): def on_render(self) -> None: if self.repaint: - ui.display.qrcode(self.x, self.y, self.data.encode(), self.scale) + ui.display.qrcode(self.x, self.y, self.data, self.scale) self.repaint = False