Description
Hello everyone,
I used LVGL for my application. After porting my device, my screen showed as the figure below. Can any body know what happen?
What MCU/Processor/Board and compiler are you using?
Stm32L476RG and ST7565 - my screen
What LVGL version are you using?
V7-10
Code to reproduce
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
// LREP("\r\n(%d,%d) (%d,%d)",(long)(area->x1), (long)(area->y1), (long)(area->x2), (long)(area->y2));
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
// LcdFillRect(area->x1, area->y1, abs(area->x2 - area->x1 +1) , abs(area->y2 - area->y1), color_p->full);
if(area->x2 < 0) return;
if(area->y2 < 0) return;
if(area->x1 > 128 - 1) return;
if(area->y1 > 64 - 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 > (128 - 1) ? (128 - 1) : area->x2;
int32_t act_y2 = area->y2 > (64 - 1) ? (64 - 1) : area->y2;
int32_t x, y;
/*Refresh frame buffer*/
for(y = act_y1; y <= act_y2; y++) {
for(x = act_x1; x <= act_x2; x++) {
if(lv_color_to1(*color_p) != 0) {
st7565_buffer[x + (y / 8)*128] &= ~(1 << ((y % 8)));
} else {
st7565_buffer[x + (y / 8)*64] |= (1 << ((y % 8)));
}
color_p ++;
}
color_p += area->x2 - act_x2; //Next row
}
LcdSetBufferPixel(st7565_buffer);
lv_disp_flush_ready(disp_drv);
My main function:
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
LREP("\r\n[LVGL Build Date:<%s>.<%s>]\r\n",BUILD_TIME,BUILD_DATE);
//TestDisplay();
memset(st7565_buffer,0,1024);
#if(1)
lv_init();
lv_port_disp_init();
//lv_theme_t * th = lv_theme_mono_init(LV_COLOR_BLACK, LV_COLOR_BLACK, LV_THEME_MATERIAL_FLAG_DARK, LV_FONT_MONTSERRAT_12,LV_FONT_MONTSERRAT_12,LV_FONT_MONTSERRAT_12,LV_FONT_MONTSERRAT_12);
//lv_obj_t * scr = lv_disp_get_scr_act(NULL);
//lv_theme_set_act(th); // Not run USB CDC
// Input device keyboard
// lv_indev_drv_t indev_drv;
// lv_indev_drv_init(&indev_drv); /*Basic initialization*/
// indev_drv.read_cb = button_read;
// /*Register the driver in LVGL and save the created input device object*/
// lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
lv_obj_t * scr = lv_disp_get_scr_act(NULL);
lv_theme_t * th = lv_theme_mono_init(LV_COLOR_BLACK, LV_COLOR_BLACK, 0, &lv_font_montserrat_12, &lv_font_montserrat_12,
&lv_font_montserrat_12, &lv_font_montserrat_12);
/* Set the mono system theme */
lv_theme_set_act(th);
#if(1)
/*Create a Label on the currently active screen*/
// lv_style_init(&my_style);
// lv_style_set_text_font(&my_style,LV_STATE_DEFAULT,LV_THEME_DEFAULT_FONT_SMALL);
label1 = lv_label_create(scr, NULL);
// lv_obj_set_pos(label1,3, 3); // position, position);
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(label1, "abc123");
#endif
LREP("\r\n[LVGL Object]\r\n");
#endif
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
lv_tick_inc(1);
lv_task_handler();
HAL_Delay(10);
}
}
Iām looking forward to seeing your reply.
Thanks,
Best Regards,