From d7398619e1661b187d7e9d625c22aa2c3fba9f70 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 3 Oct 2016 11:52:19 +0200 Subject: [PATCH] introduce trezor.ui.display.refresh --- extmod/modtrezorui/display-stmhal.h | 2 +- extmod/modtrezorui/display-unix.h | 3 +-- extmod/modtrezorui/display.c | 10 ---------- extmod/modtrezorui/display.h | 2 +- extmod/modtrezorui/modtrezorui-display.h | 11 +++++++++++ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/extmod/modtrezorui/display-stmhal.h b/extmod/modtrezorui/display-stmhal.h index f12e2d3fd7..854130ff1d 100644 --- a/extmod/modtrezorui/display-stmhal.h +++ b/extmod/modtrezorui/display-stmhal.h @@ -257,7 +257,7 @@ void display_set_window(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { #endif } -void display_update(void) { +void display_refresh(void) { } int display_backlight(int val) diff --git a/extmod/modtrezorui/display-unix.h b/extmod/modtrezorui/display-unix.h index 2121206dfd..c675db6c48 100644 --- a/extmod/modtrezorui/display-unix.h +++ b/extmod/modtrezorui/display-unix.h @@ -107,7 +107,7 @@ void display_set_window(uint16_t x, uint16_t y, uint16_t w, uint16_t h) DATAODD = 0; } -void display_update(void) +void display_refresh(void) { SDL_RenderClear(RENDERER); SDL_UpdateTexture(TEXTURE, NULL, SCREEN->pixels, SCREEN->pitch); @@ -121,7 +121,6 @@ int display_orientation(int degrees) if (degrees != ORIENTATION) { if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) { ORIENTATION = degrees; - display_update(); } } return ORIENTATION; diff --git a/extmod/modtrezorui/display.c b/extmod/modtrezorui/display.c index db937dd1b9..daa3f3e230 100644 --- a/extmod/modtrezorui/display.c +++ b/extmod/modtrezorui/display.c @@ -52,7 +52,6 @@ void display_clear(void) for (int i = 0; i < DISPLAY_RESX * DISPLAY_RESY * 2; i++) { DATA(0); } - display_update(); } void display_bar(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t c) @@ -62,7 +61,6 @@ void display_bar(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t c) DATA(c >> 8); DATA(c & 0xFF); } - display_update(); } #define CORNER_RADIUS 16 @@ -124,14 +122,12 @@ void display_bar_radius(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t c, } } } - display_update(); } void display_blit(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const void *data, int datalen) { display_set_window(x, y, w, h); DATAS(data, datalen); - display_update(); } static void inflate_callback_image(uint8_t byte, uint32_t pos, void *userdata) @@ -143,7 +139,6 @@ void display_image(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const void *data, { display_set_window(x, y, w, h); sinf_inflate(data, datalen, inflate_callback_image, NULL); - display_update(); } static void inflate_callback_icon(uint8_t byte, uint32_t pos, void *userdata) @@ -161,7 +156,6 @@ void display_icon(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const void *data, uint16_t colortable[16]; set_color_table(colortable, fgcolor, bgcolor); sinf_inflate(data, datalen, inflate_callback_icon, colortable); - display_update(); } static const uint8_t *get_glyph(uint8_t font, uint8_t c) @@ -219,8 +213,6 @@ void display_text(uint8_t x, uint8_t y, const char *text, int textlen, uint8_t f } px += g[2]; } - - display_update(); } // compute the width of the text (in pixels) @@ -250,7 +242,6 @@ void display_qrcode(uint8_t x, uint8_t y, const char *data, int datalen, int sca } } } - display_update(); } #include "loader.h" @@ -318,7 +309,6 @@ void display_loader(uint16_t progress, uint16_t fgcolor, uint16_t bgcolor, const } } } - display_update(); } void display_raw(uint8_t reg, const uint8_t *data, int datalen) diff --git a/extmod/modtrezorui/display.h b/extmod/modtrezorui/display.h index 1fc6edf963..cfbb7b52bd 100644 --- a/extmod/modtrezorui/display.h +++ b/extmod/modtrezorui/display.h @@ -17,12 +17,12 @@ void display_init(void); void display_set_window(uint16_t x, uint16_t y, uint16_t w, uint16_t h); -void display_update(void); int display_orientation(int degrees); int display_backlight(int val); void set_color_table(uint16_t colortable[16], uint16_t fgcolor, uint16_t bgcolor); void display_clear(void); +void display_refresh(void); void display_bar(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t c); void display_bar_radius(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t c, uint16_t b, uint8_t r); void display_blit(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const void *data, int datalen); diff --git a/extmod/modtrezorui/modtrezorui-display.h b/extmod/modtrezorui/modtrezorui-display.h index 50f57a79cf..2555e4a72e 100644 --- a/extmod/modtrezorui/modtrezorui-display.h +++ b/extmod/modtrezorui/modtrezorui-display.h @@ -31,6 +31,16 @@ STATIC mp_obj_t mod_TrezorUi_Display_clear(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorUi_Display_clear_obj, mod_TrezorUi_Display_clear); +/// def trezor.ui.display.refresh() -> None +/// ''' +/// Refresh display (update screen) +/// ''' +STATIC mp_obj_t mod_TrezorUi_Display_refresh(mp_obj_t self) { + display_refresh(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorUi_Display_refresh_obj, mod_TrezorUi_Display_refresh); + /// def trezor.ui.display.bar(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> None: /// ''' /// Renders a bar at position (x,y = upper left corner) with width w and height h of color fgcolor. @@ -319,6 +329,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorUi_Display_raw_obj, mod_TrezorUi_Disp STATIC const mp_rom_map_elem_t mod_TrezorUi_Display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&mod_TrezorUi_Display_clear_obj) }, + { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&mod_TrezorUi_Display_refresh_obj) }, { MP_ROM_QSTR(MP_QSTR_bar), MP_ROM_PTR(&mod_TrezorUi_Display_bar_obj) }, { MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&mod_TrezorUi_Display_blit_obj) }, { MP_ROM_QSTR(MP_QSTR_image), MP_ROM_PTR(&mod_TrezorUi_Display_image_obj) },