feat(st7789.c): Initial support for display rotation control using LVGL

This commit is contained in:
C47D 2021-09-09 22:47:47 -05:00
parent ffae578a39
commit 0e29128b3b

View file

@ -122,6 +122,22 @@ void st7789_enable_backlight(lv_disp_drv_t *drv, bool backlight)
* account that gap, this is not necessary in all orientations. */ * account that gap, this is not necessary in all orientations. */
void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{ {
static lv_disp_rot_t prev_rotation = LV_DISP_ROT_NONE;
lv_disp_t *display = (lv_disp_t *) drv;
lv_disp_rot_t rotation = lv_disp_get_rotation(display);
if (rotation != prev_rotation) {
/* Update rotation */
/* TODO Handle all other rotations */
if (LV_DISP_ROT_180 == rotation) {
st7789_set_orientation(drv, 1);
}
prev_rotation = rotation;
}
uint8_t data[4] = {0}; uint8_t data[4] = {0};
uint16_t offsetx1 = area->x1; uint16_t offsetx1 = area->x1;
@ -138,8 +154,13 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 240) #elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 240)
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT) #if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
if (LV_DISP_ROT_NONE == rotation) {
offsetx1 += 80; offsetx1 += 80;
offsetx2 += 80; offsetx2 += 80;
}
else {
}
#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED) #elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
offsety1 += 80; offsety1 += 80;
offsety2 += 80; offsety2 += 80;