Description
Trying to print simple widgets on SSD1306-based OLED
What MCU/Processor/Board and compiler are you using?
MCU: STM32L496ZG
Compiler: GCC
IDE: CubeIDE (Eclipse)
What LVGL version are you using?
8.3
What do you want to achieve?
Display widgets to continue learning about interactions with them
What have you tried so far?
Downloaded LVGL ver.8.3 from Github
Setted up project according to Porting guide
Used template from Github to register display and flush buffer
Setted needed variables/buffers/callbacks
Code to reproduce
To mention, problem is not in display driver, since i’m using it with basic functions (draw pixel, etc.) and it works.
My disp_flush()
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
int32_t x, y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
ssd1306_DrawPixel(x, y, lv_color_to1(*color_p));
++color_p;
}
}
ssd1306_UpdateScreen();
lv_disp_flush_ready(disp_drv);
}
My lv_port_disp_init()
void lv_port_disp_init(void)
{
disp_init();
static lv_disp_draw_buf_t draw_buf_dsc_1;
static lv_color_t buf_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.hor_res = MY_DISP_HOR_RES;
disp_drv.ver_res = MY_DISP_VER_RES;
disp_drv.flush_cb = disp_flush;
disp_drv.draw_buf = &draw_buf_dsc_1;
lv_disp_drv_register(&disp_drv);
}
disp_init() just calls for ssd1306_init()
In my system timer i am calling lv_tick_inc(1);
Finally, my main()
int main(void)
{
lv_init();
lv_port_disp_init();
/*Create a spinner*/
lv_obj_t * spinner = lv_spinner_create(lv_scr_act(), 1000, 30);
lv_obj_set_size(spinner, 32, 32);
lv_obj_align(spinner, LV_ALIGN_BOTTOM_MID, 0, 0);
while (1)
{
lv_timer_handler();
HAL_Delay(5);
}
}
However, after flashing whole screen becomes filled with white.
I think that my main problem is that i don’t really undertand how flushing function works with monochrome display. Or maybe my problem in spinner init? All hepl will be highly appreciated.