How can I use gpu_fill_cb?


I want to use gpu_fill_cb, but I could not understand how to use it.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

I want to fill my frame buffer with using gpu_fill_cb.

What have you tried so far?

I can fill my buffer with using tft_flush. I set buf_1 address as LTDC frame buffer (FBStartAdress) address. It is working with flush_cb function, but dest_buf in gpu_fill_cb function can’t fill my frame buffer.

Code to reproduce

static __IO uint16_t * buf_1 = (__IO uint16_t*) ((uint32_t)0xC0000000);
//LTDC FBStartAdress = 0xC0000000;
void tft_init(void)
    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf_1, NULL, 480 * 272);   /*Initialize the display buffer*/

    * Register the display in LittlevGL

    lv_disp_drv_t disp_drv;                         /*Descriptor of a display driver*/
    lv_disp_drv_init(&disp_drv);                    /*Basic initialization*/

    /*Set up the functions to access to your display*/

    /*Set the resolution of the display*/
    disp_drv.hor_res = 480;
    disp_drv.ver_res = 272;

    /*Used to copy the buffer's content to the display*/
    disp_drv.gpu_fill_cb = gpu_fill_cb;

    /*Set a display buffer*/
    disp_drv.buffer = &disp_buf;

    /*Finally register the driver*/
    disp = lv_disp_drv_register(&disp_drv);

void gpu_fill_cb(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color)
    /*It's an example code which should be done by your GPU*/
    uint32_t x, y;
    dest_buf += dest_width * fill_area->y1; /*Go to the first line*/

    for(y = fill_area->y1; y < fill_area->y2; y++) {
        for(x = fill_area->x1; x < fill_area->x2; x++) {
        	dest_buf[x] = color;
        dest_buf+=dest_width;    /*Go to the next line*/

Maybe some misinterpretation here.

As I interpret it: You (your sources) have to provide a gpu_fill_cb function if you have a special controller where filling a rectangle/area with a color is provided by a specific hardware function.

You have a STM32F7xx. For using the build in DMA2D of that controller, you have to config it within the lv_config.h.
In this case all (lvgl internal) functions which benefits from using DMA are using the DMA2D hardware.
Also in this case you don’t need to provide a special gpu_fill_cb. There is one already build in in lvgl.

The disp_drv.flush_cb which you have to provide (and set) is used to copy all data which are drawn by lvgl to the real framebuffer (0xC000000) which the STM327xxx is using to drive the real display.

In this case you write your own function which uses the DMA2D of the STM32Fxx, or you do it by the CPU itself.