This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 340770b57a8484a2b4c20c03485f4c4f90666b0c Author: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> AuthorDate: Mon May 19 12:06:34 2025 +0200 lvgl/drivers: Fix flush after rotation Drivers were not working correctly when lvgl performed display rotation. Now display can switch between horizontal and vertical layout. ILI9341 rotation adjusted to work same as for other drivers (rotation went in different direction before) Signed-off-by: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> --- hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c | 13 ++++++++----- hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c | 9 ++++++--- hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c | 9 ++++++--- hw/drivers/display/lvgl/tft/st7789/src/st7789.c | 12 ++++++++++-- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c index 28bd75bc8..daf353583 100644 --- a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c +++ b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c @@ -132,9 +132,9 @@ static const uint8_t madctl[] = { MADCTL_MX, - MADCTL_MX | MADCTL_MY | MADCTL_MV, - MADCTL_MY, MADCTL_MV, + MADCTL_MY, + MADCTL_MX | MADCTL_MY | MADCTL_MV, }; void @@ -231,8 +231,11 @@ void ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { uint8_t cmd[5]; + lv_disp_t *disp = lv_disp_get_default(); + lv_coord_t hor_res = lv_disp_get_hor_res(disp); + lv_coord_t ver_res = lv_disp_get_ver_res(disp); - if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9341_HOR_RES || area->y1 >= ILI9341_VER_RES) { + if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) { lv_disp_flush_ready(drv); return; } @@ -240,8 +243,8 @@ ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) /* Truncate the area to the screen */ int32_t act_x1 = area->x1 < 0 ? 0 : area->x1; int32_t act_y1 = area->y1 < 0 ? 0 : area->y1; - int32_t act_x2 = area->x2 >= ILI9341_HOR_RES ? ILI9341_HOR_RES - 1 : area->x2; - int32_t act_y2 = area->y2 >= ILI9341_VER_RES ? ILI9341_VER_RES - 1 : area->y2; + int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2; + int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2; /* Column address */ cmd[0] = ILI9341_CASET; diff --git a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c index d741db250..59826baf3 100644 --- a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c +++ b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c @@ -190,8 +190,11 @@ void ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { uint8_t cmd[5]; + lv_disp_t *disp = lv_disp_get_default(); + lv_coord_t hor_res = lv_disp_get_hor_res(disp); + lv_coord_t ver_res = lv_disp_get_ver_res(disp); - if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9486_HOR_RES || area->y1 >= ILI9486_VER_RES) { + if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) { lv_disp_flush_ready(drv); return; } @@ -199,8 +202,8 @@ ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) /* Truncate the area to the screen */ int32_t act_x1 = area->x1 < 0 ? 0 : area->x1; int32_t act_y1 = area->y1 < 0 ? 0 : area->y1; - int32_t act_x2 = area->x2 >= ILI9486_HOR_RES ? ILI9486_HOR_RES - 1 : area->x2; - int32_t act_y2 = area->y2 >= ILI9486_VER_RES ? ILI9486_VER_RES - 1 : area->y2; + int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2; + int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2; /* Column address */ cmd[0] = ILI9486_CASET; diff --git a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c index 5e1208b81..7e980771f 100644 --- a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c +++ b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c @@ -183,8 +183,11 @@ void st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { uint8_t cmd[5]; + lv_disp_t *disp = lv_disp_get_default(); + lv_coord_t hor_res = lv_disp_get_hor_res(disp); + lv_coord_t ver_res = lv_disp_get_ver_res(disp); - if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ST7735S_HOR_RES || area->y1 >= ST7735S_VER_RES) { + if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) { lv_disp_flush_ready(drv); return; } @@ -192,8 +195,8 @@ st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) /* Truncate the area to the screen */ int32_t act_x1 = area->x1 < 0 ? 0 : area->x1; int32_t act_y1 = area->y1 < 0 ? 0 : area->y1; - int32_t act_x2 = area->x2 >= ST7735S_HOR_RES ? ST7735S_HOR_RES - 1 : area->x2; - int32_t act_y2 = area->y2 >= ST7735S_VER_RES ? ST7735S_VER_RES - 1 : area->y2; + int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2; + int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2; /* Column address */ cmd[0] = ST7735S_CASET; diff --git a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c index 60b8ba301..44c24780e 100644 --- a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c +++ b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c @@ -209,12 +209,20 @@ void st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { uint8_t cmd[5]; + lv_disp_t *disp = lv_disp_get_default(); + lv_coord_t hor_res = lv_disp_get_hor_res(disp); + lv_coord_t ver_res = lv_disp_get_ver_res(disp); + + if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) { + lv_disp_flush_ready(drv); + return; + } /* Truncate the area to the screen */ int32_t offsetx1 = area->x1 < 0 ? 0 : area->x1; int32_t offsety1 = area->y1 < 0 ? 0 : area->y1; - int32_t offsetx2 = area->x2 >= ST7789_HOR_RES ? ST7789_HOR_RES - 1 : area->x2; - int32_t offsety2 = area->y2 >= ST7789_VER_RES ? ST7789_VER_RES - 1 : area->y2; + int32_t offsetx2 = area->x2 >= hor_res ? hor_res - 1 : area->x2; + int32_t offsety2 = area->y2 >= ver_res ? ver_res - 1 : area->y2; #if (CONFIG_LV_TFT_DISPLAY_OFFSETS) offsetx1 += CONFIG_LV_TFT_DISPLAY_X_OFFSET;