What MCU/Processor/Board and compiler are you using?
STM32F103RCT6 (RAM 48 KB, custom board)
display: 128*160, RGB565(16 bit), ST7735/ST7789 lcd driver, SPI comm.
IDE: STM32CubeIDE
What LVGL version are you using?
the latest one (v8.0)
What do you want to achieve?
To create objects.
When I add an example in main code, objects doesn’t show up.
I’ve tested several examples, I could just watch some pixels’ color was changed.
The changed color on specific area was scrolling when I tested lv_example_label_1().
I guess it scrolls some text, but it isn’t created.
Instead, light-pink one is moving. I added the gif file below.
I wonder if it is a problem of spi communication size or my lcd_flush fuction.
However, I cannot find the cause.
If anyone knows, let me know.
Code to reproduce
main processing function
void App_Start(void)
{
lv_init();
LCD_Init(); // lcd init func
HAL_Delay(1000);
lv_config_main(); // lvgl configuration func
lv_example_label_1();
}
void lv_config_main(void)
{
static lv_disp_draw_buf_t disp_buf;
static lv_color_t buf_1[LV_HOR_RES_MAX*10];
lv_disp_draw_buf_init(&disp_buf, buf_1, NULL, LV_HOR_RES_MAX * 10);
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.draw_buf = &disp_buf;
LCD_flush(&disp_drv, &area, &my_color); // I've added it for testing and print data change
disp_drv.flush_cb = LCD_flush;
lv_disp_t * disp_ex;
disp_ex = lv_disp_drv_register(&disp_drv);
}
flush function
void LCD_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{
int16_t x, y;
lv_color_t color = *color_map;
for(x = area->x1; x <= area->x2; x++) {
for(y = area->y1; y <= area->y2; y++) {
LCD_DrawPaint((uint16_t)x, (uint16_t)y, (uint16_t)color.full);
}
}
lv_disp_flush_ready(drv);
DEV_Digital_Write(DEV_CS_PIN, 1);
}
display driver function for drawing
void LCD_DrawPaint(uint16_t x, uint16_t y, uint16_t Color)
{
LCD_SetCursor(x, y);
LCD_WriteData_Word(Color);
}
void LCD_SetCursor(uint16_t X, uint16_t Y)
{
LCD_Write_Command(0x2a);
LCD_WriteData_Byte(X >> 8);
LCD_WriteData_Byte(X);
LCD_WriteData_Byte(X >> 8);
LCD_WriteData_Byte(X);
LCD_Write_Command(0x2b);
LCD_WriteData_Byte(Y >> 8);
LCD_WriteData_Byte(Y);
LCD_WriteData_Byte(Y >> 8);
LCD_WriteData_Byte(Y);
LCD_Write_Command(0x2C);
}
static void LCD_Write_Command(uint8_t data)
{
DEV_Digital_Write(DEV_CS_PIN, 0); // it makes GPIO pin set/reset
DEV_Digital_Write(DEV_DC_PIN, 0);
DEV_SPI_WRITE(data);
}
static void LCD_WriteData_Byte(uint8_t data)
{
DEV_Digital_Write(DEV_CS_PIN, 0);
DEV_Digital_Write(DEV_DC_PIN, 1);
DEV_SPI_WRITE(data);
DEV_Digital_Write(DEV_CS_PIN,1);
}
// spi function
void DEV_SPI_WRite(uint8_t _dat)
{
HAL_SPI_Transmit(&hspi1, (uint8_t *)&_dat, 1, 500);
}
example code that I used
void lv_example_label_1(void)
{
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/
lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center"
"and wrap long text automatically.");
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
lv_obj_set_style_text_align(label1, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -40);
lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
lv_obj_set_width(label2, 150);
lv_label_set_text(label2, "It is a circularly scrolling text. ");
lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 40);
}