mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
add Display.rotation (WIP for stmhal)
This commit is contained in:
parent
927589ddcb
commit
05d00668e0
@ -95,6 +95,25 @@ static void display_unsleep(void) {
|
||||
CMD(0x29); // display
|
||||
}
|
||||
|
||||
static void display_orientation(uint16_t degrees)
|
||||
{
|
||||
// memory access control
|
||||
switch (degrees) {
|
||||
case 0:
|
||||
CMD(0x36); DATA(0x08);
|
||||
break;
|
||||
case 90:
|
||||
CMD(0x36); DATA(0x08);
|
||||
break;
|
||||
case 180:
|
||||
CMD(0x36); DATA(0x08);
|
||||
break;
|
||||
case 270:
|
||||
CMD(0x36); DATA(0x08);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void display_init(void) {
|
||||
sram_init();
|
||||
CMD(0x01); // software reset
|
||||
@ -110,7 +129,7 @@ static void display_init(void) {
|
||||
CMD(0xC1); DATA(0x12); // power control SAP[2:0] BT[3:0]
|
||||
CMD(0xC5); DATAS("\x60\x44", 2); // vcm control 1
|
||||
CMD(0xC7); DATA(0x8A); // vcm control 2
|
||||
CMD(0x36); DATA(0x08); // memory access control (RGB)
|
||||
display_orientation(0);
|
||||
CMD(0x3A); DATA(0x55); // memory access control (16-bit 565)
|
||||
CMD(0xB1); DATAS("\x00\x18", 2); // framerate
|
||||
CMD(0xB6); DATAS("\x0A\xA2", 2); // display function control
|
||||
|
@ -13,6 +13,7 @@ static SDL_Surface *SCREEN = 0;
|
||||
static SDL_Texture *TEXTURE = 0;
|
||||
static int DATAODD = 0;
|
||||
static int POSX, POSY, SX, SY, EX, EY = 0;
|
||||
static int ROTATION = 0;
|
||||
|
||||
#define DATA(X) DATAfunc((X))
|
||||
|
||||
@ -65,7 +66,14 @@ static void display_set_window(uint8_t x, uint8_t y, uint8_t w, uint8_t h) {
|
||||
static void display_update(void)
|
||||
{
|
||||
if (!SDL_inited) return;
|
||||
SDL_RenderClear(RENDERER);
|
||||
SDL_UpdateTexture(TEXTURE, NULL, SCREEN->pixels, SCREEN->pitch);
|
||||
SDL_RenderCopy(RENDERER, TEXTURE, NULL, NULL);
|
||||
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, NULL, ROTATION, NULL, 0);
|
||||
SDL_RenderPresent(RENDERER);
|
||||
}
|
||||
|
||||
static void display_orientation(int degrees)
|
||||
{
|
||||
ROTATION = degrees;
|
||||
display_update();
|
||||
}
|
||||
|
@ -246,12 +246,24 @@ STATIC mp_obj_t mod_TrezorUi_Display_text(size_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_obj, 7, 7, mod_TrezorUi_Display_text);
|
||||
|
||||
// def Display.text(self, degrees: int) -> None:
|
||||
STATIC mp_obj_t mod_TrezorUi_Display_orientation(mp_obj_t self, mp_obj_t degrees) {
|
||||
mp_int_t deg = mp_obj_get_int(degrees);
|
||||
if (deg != 0 && deg != 90 && deg != 180 && deg != 270) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Value must be 0, 90, 180 or 270"));
|
||||
}
|
||||
display_orientation(deg);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorUi_Display_orientation_obj, mod_TrezorUi_Display_orientation);
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_TrezorUi_Display_locals_dict_table[] = {
|
||||
{ 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) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_icon), MP_ROM_PTR(&mod_TrezorUi_Display_icon_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&mod_TrezorUi_Display_text_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_orientation), MP_ROM_PTR(&mod_TrezorUi_Display_orientation_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_TrezorUi_Display_locals_dict, mod_TrezorUi_Display_locals_dict_table);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user