1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

refactor(core): remove unused parameter from display_qrcode

[no changelog]
This commit is contained in:
Martin Milata 2022-05-17 13:41:20 +02:00
parent 9f0ebf6d1a
commit 24a1f2e25e
6 changed files with 9 additions and 12 deletions

View File

@ -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};

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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.

View File

@ -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