diff --git a/extmod/modtrezorui/display.c b/extmod/modtrezorui/display.c index 0fca555186..67773170bd 100644 --- a/extmod/modtrezorui/display.c +++ b/extmod/modtrezorui/display.c @@ -413,7 +413,9 @@ void display_raw(uint8_t reg, const uint8_t *data, int datalen) if (reg) { CMD(reg); } - DATAS(data, datalen); + if (data && datalen > 0) { + DATAS(data, datalen); + } } int *display_offset(int xy[2]) diff --git a/extmod/modtrezorui/modtrezorui-display.h b/extmod/modtrezorui/modtrezorui-display.h index b1388ba7f8..669a49af23 100644 --- a/extmod/modtrezorui/modtrezorui-display.h +++ b/extmod/modtrezorui/modtrezorui-display.h @@ -337,18 +337,22 @@ STATIC mp_obj_t mod_TrezorUi_Display_offset(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_offset_obj, 1, 2, mod_TrezorUi_Display_offset); -/// def trezor.ui.display.raw(reg: int, data: bytes) -> None: +/// def trezor.ui.display.raw(reg: int, data: bytes=None) -> None: /// ''' /// Performs a raw command on the display. Read the datasheet to learn more. /// ''' -STATIC mp_obj_t mod_TrezorUi_Display_raw(mp_obj_t self, mp_obj_t reg, mp_obj_t data) { - mp_int_t r = mp_obj_get_int(reg); - mp_buffer_info_t raw; - mp_get_buffer_raise(data, &raw, MP_BUFFER_READ); - display_raw(r, (raw.len > 0) ? raw.buf : "" , raw.len); +STATIC mp_obj_t mod_TrezorUi_Display_raw(size_t n_args, const mp_obj_t *args) { + mp_int_t r = mp_obj_get_int(args[1]); + if (n_args > 2){ + mp_buffer_info_t raw; + mp_get_buffer_raise(args[2], &raw, MP_BUFFER_READ); + display_raw(r, raw.buf, raw.len); + } else { + display_raw(r, NULL, 0); + } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorUi_Display_raw_obj, mod_TrezorUi_Display_raw); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_raw_obj, 2, 3, mod_TrezorUi_Display_raw); /// def trezor.ui.display.save(filename: string) -> None: /// '''