Description
Through simple example for LVGL6.0, I’ve tried to create objects and control touch actions.
What MCU/Processor/Board and compiler are you using?
STM32F767II, IAR Workbench
What do you want to achieve?
I would like to check the primary functions provided by the library.
What have you tried so far?
Running the flush function with DMA with changing of buffer size.
Running the flush function without DMA with changing of buffer size.
If I set the one buffer size is 480x272, the flush function is OK.
But, if I set the buffer size to be less than 480x272, the flush function returns error (HAL_Error).
- LCD resolution: 480 x 272
I’d like to know what I have missed.
Screenshot and/or video
Run the simple button example with a buffer size smaller than 272.
The error is occurred in flush function. err 2 is HAL_Error.
Code to reproduce
tft_init() -> modifying buffer size
#define LINE_NUMBER (100) //272
void tft_init(void)
{
static lv_color_t buf1[LV_HOR_RES_MAX * LINE_NUMBER]; // 480 x 100
//static lv_color_t buf2[LV_HOR_RES_MAX * LINE_NUMBER ];
static lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, buf1, NULL, LV_HOR_RES_MAX * LINE_NUMBER );
//lv_disp_buf_init(&disp_buf, buf1, buf2, LV_HOR_RES_MAX * LINE_NUMBER );
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
...
}
tft_flush() with DMA
static void tft_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p)
{
/*Return if the area is out the screen*/
if(area->x2 < 0) return;
if(area->y2 < 0) return;
if(area->x1 > TFT_HOR_RES - 1) return;
if(area->y1 > TFT_VER_RES - 1) return;
/*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 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : area->y2;
x1_flush = act_x1;
y1_flush = act_y1;
x2_flush = act_x2;
y2_fill = act_y2;
y_fill_act = act_y1;
buf_to_flush = color_p;
HAL_StatusTypeDef err;
err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
(x2_flush - x1_flush + 1));
if(err != HAL_OK)
{
printf("err occurred ---------------------------------------- \r\n");
printf("err: %d\r\n", err);
while(1); /*Halt on error*/
}
lv_disp_flush_ready(drv);
}
Screenshot and/or video
I’ve tried it with simple flush function (put all pixels to the screen one-by-one).
buffer size = 480x272 -> flush function OK, click event OK
buffer size < 480x272 -> flush function may be OK, But when clicked the button, weird display as shown below
Code to reproduce
simple flush function
static void tft_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
int16_t y=0;
uint16_t i, j;
uint32_t w = lv_area_get_width(area);
for(y = area->y1; y <= area->y2 && y < disp_drv->ver_res; y++) {
memcpy((uint16_t *)&my_fb[y * TFT_HOR_RES + area->x1], color_p, TFT_HOR_RES* LINE_NUMBER * 2); //sizeof(lv_color_t));
color_p += w;
}
lv_disp_flush_ready(disp_drv);
}