Skip to content

Commit

Permalink
lvgl/lcd_itf: Pass coordinate to lcd_itf_write_color_data
Browse files Browse the repository at this point in the history
Previously lcd_itf_write_color_data() only received pixel data and
number of bytes to write.
Now size is change to x-y coordinates that is needed for some drivers.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
  • Loading branch information
kasjer committed Sep 14, 2023
1 parent 3bea7ba commit 0515a8c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 43 deletions.
2 changes: 1 addition & 1 deletion hw/drivers/display/lcd_itf/include/lcd_itf.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ void lcd_itf_init(void);

/* Function implemented by LCD interface driver */
void lcd_ift_write_cmd(const uint8_t *cmd, int cmd_length);
void lcd_itf_write_color_data(const void *data, size_t size);
void lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const void *pixels);

#endif /* LCD_ITF_H */
3 changes: 2 additions & 1 deletion hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ lcd_itf_write_bytes(const uint8_t *bytes, size_t size)
}

void
lcd_itf_write_color_data(const void *pixels, size_t size)
lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const void *pixels)
{
const uint16_t *data = (const uint16_t *)pixels;
size_t size = (x2 - x1 + 1) * (y2 - y1 + 1) * 2;

LCD_DC_PIN_DATA();
LCD_CS_PIN_ACTIVE();
Expand Down
3 changes: 2 additions & 1 deletion hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ static uint8_t *lv_color_16_swap_buffer;
static size_t lv_color_16_swap_buffer_size;

void
lcd_itf_write_color_data(const void *pixels, size_t size)
lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const void *pixels)
{
const void *color_data = pixels;
size_t i;
size_t size = (x2 - x1 + 1) * (y2 - y1 + 1) * 2;

LCD_DC_PIN_DATA();
LCD_CS_PIN_ACTIVE();
Expand Down
9 changes: 1 addition & 8 deletions hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ gc9a01_drv_update(struct _lv_disp_drv_t *drv)
void
gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
int32_t y;
lv_coord_t w;
uint8_t cmd[5];

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= GC9A01_HOR_RES || area->y1 >= GC9A01_VER_RES) {
Expand All @@ -219,8 +217,6 @@ gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
int32_t act_x2 = area->x2 >= GC9A01_HOR_RES ? GC9A01_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 >= GC9A01_VER_RES ? GC9A01_VER_RES - 1 : area->y2;

w = lv_area_get_width(area);

/* Column address */
cmd[0] = GC9A01_CASET;
cmd[1] = (uint8_t)(act_x1 >> 8);
Expand All @@ -240,10 +236,7 @@ gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
cmd[0] = GC9A01_RAMWR;
lcd_ift_write_cmd(cmd, 1);

for (y = act_y1; y <= act_y2; y++) {
lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
color_p += w;
}
lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);

lv_disp_flush_ready(drv);
}
Expand Down
9 changes: 1 addition & 8 deletions hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ ili9341_drv_update(struct _lv_disp_drv_t *drv)
void
ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
int32_t y;
uint8_t cmd[5];
lv_coord_t w;

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9341_HOR_RES || area->y1 >= ILI9341_VER_RES) {
lv_disp_flush_ready(drv);
Expand All @@ -221,8 +219,6 @@ ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
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;

w = lv_area_get_width(area);

/* Column address */
cmd[0] = ILI9341_CASET;
cmd[1] = (uint8_t)(act_x1 >> 8);
Expand All @@ -242,10 +238,7 @@ ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
cmd[0] = ILI9341_RAMWR;
lcd_ift_write_cmd(cmd, 1);

for (y = act_y1; y <= act_y2; y++) {
lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
color_p += w;
}
lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);

lv_disp_flush_ready(drv);
}
Expand Down
9 changes: 1 addition & 8 deletions hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ ili9486_drv_update(struct _lv_disp_drv_t *drv)
void
ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
int32_t y;
lv_coord_t w;
uint8_t cmd[5];

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9486_HOR_RES || area->y1 >= ILI9486_VER_RES) {
Expand All @@ -204,8 +202,6 @@ ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
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;

w = lv_area_get_width(area);

/* Column address */
cmd[0] = ILI9486_CASET;
cmd[1] = (uint8_t)(act_x1 >> 8);
Expand All @@ -225,10 +221,7 @@ ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
cmd[0] = ILI9486_RAMWR;
lcd_ift_write_cmd(cmd, 1);

for (y = act_y1; y <= act_y2; y++) {
lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
color_p += w;
}
lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);

lv_disp_flush_ready(drv);
}
Expand Down
9 changes: 1 addition & 8 deletions hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ st7735s_drv_update(struct _lv_disp_drv_t *drv)
void
st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
int32_t y;
lv_coord_t w;
uint8_t cmd[5];

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ST7735S_HOR_RES || area->y1 >= ST7735S_VER_RES) {
Expand All @@ -197,8 +195,6 @@ st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
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;

w = lv_area_get_width(area);

/* Column address */
cmd[0] = ST7735S_CASET;
cmd[1] = (uint8_t)(act_x1 >> 8);
Expand All @@ -218,10 +214,7 @@ st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
cmd[0] = ST7735S_RAMWR;
lcd_ift_write_cmd(cmd, 1);

for (y = act_y1; y <= act_y2; y++) {
lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
color_p += w;
}
lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);

lv_disp_flush_ready(drv);
}
Expand Down
9 changes: 1 addition & 8 deletions hw/drivers/display/lvgl/tft/st7789/src/st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ st7789_drv_update(struct _lv_disp_drv_t *drv)
void
st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
int32_t y;
lv_coord_t w;
uint8_t cmd[5];

/* Truncate the area to the screen */
Expand Down Expand Up @@ -250,8 +248,6 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
#endif
#endif

w = lv_area_get_width(area);

/* Column addresses */
cmd[0] = ST7789_CASET;
cmd[1] = (uint8_t)(offsetx1 >> 8);
Expand All @@ -271,10 +267,7 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
cmd[0] = ST7789_RAMWR;
lcd_ift_write_cmd(cmd, 1);

for (y = offsety1; y <= offsety2; y++) {
lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
color_p += w;
}
lcd_itf_write_color_data(offsetx1, offsetx2, offsety1, offsety2, color_p);

lv_disp_flush_ready(drv);
}
Expand Down

0 comments on commit 0515a8c

Please sign in to comment.