.
Description - LVGL Screen rotate seems to not work properly (rotates 1 or 2 times then seems to crash and not rotate at all?)
What MCU/Processor/Board and compiler are you using? STM32F412G-Disco & STM32CUBEIDE
What LVGL version are you using? 8.3.6
What do you want to achieve? Rotate the screen 0,90,180,270
What have you tried so far? 4 input pushbuttons mapped to rotate function
Code to reproduce
lcd_lvgl.c:
void Display_init(int rotation)
{
// ST7789_Init();
BSP_LCD_Init();
BSP_LCD_DisplayOn();
lv_init();
static lv_color_t buf[ST7789H2_LCD_PIXEL_WIDTH * ST7789H2_LCD_PIXEL_HEIGHT / 10];
lv_disp_draw_buf_init(&buf, disp_buf1, disp_buf2, ST7789H2_LCD_PIXEL_WIDTH * 10);
lv_disp_drv_init(&disp_drv);
disp_drv.full_refresh = 1;
disp_drv.draw_buf = &buf;
disp_drv.flush_cb = disp_flush;
disp_drv.monitor_cb = monitor_cb;
disp_drv.hor_res = ST7789H2_LCD_PIXEL_WIDTH;
disp_drv.ver_res = ST7789H2_LCD_PIXEL_HEIGHT;
disp_drv.sw_rotate = 1;
disp_drv.rotated = rotation;
lv_disp_drv_register(&disp_drv);
}
main.c
uint8_t Rotate0 = 0;
uint8_t Rotate90 = 0;
uint8_t Rotate180 = 0;
uint8_t Rotate270 = 0;void Rotate_Function(void)
{if(HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_14))
{
Rotate0 = 1;
Rotate90 = 0;
Rotate180 = 0;
Rotate270 = 0;
}if(HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_15))
{
Rotate90 = 1;
Rotate0 = 0;
Rotate180 = 0;
Rotate270 = 0;
}if(HAL_GPIO_ReadPin(GPIOG, GPIO_PIN_0))
{
Rotate180 = 1;
Rotate0 = 0;
Rotate90 = 0;
Rotate270 = 0;
}if(HAL_GPIO_ReadPin(GPIOG, GPIO_PIN_1))
{
Rotate270 = 1;
Rotate0 = 0;
Rotate90 = 0;
Rotate180 = 0;
}if(Rotate0 == 1)
{
lv_disp_set_rotation(NULL, LV_DISP_ROT_NONE);
}if(Rotate90 == 1)
{
lv_disp_set_rotation(NULL, LV_DISP_ROT_90);}
if(Rotate180 == 1)
{
lv_disp_set_rotation(NULL, LV_DISP_ROT_180);
}if(Rotate270 == 1)
{
lv_disp_set_rotation(NULL, LV_DISP_ROT_270);}
}
while (1)
{
/* USER CODE END WHILE *//* USER CODE BEGIN 3 */ HAL_Delay(5); lv_task_handler(); lv_tick_inc(1); Rotate_Function();
}
}
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.