Migrating flush function from lvgl v6 to lvgl v9.2.2

No because some displays have internal GRAM so only small areas are able to be updated. This allows a user to have a small frame buffer and if the frame buffer is not able to fit all of the updates then it will need to render sections and flush each suction to the display.

Real life example to make sure that we are on the same page:

  1. You update 2 labels.
  2. LVGL will have 2 areas to update
  3. flush_cb is called after each is rendered to let the user do anything (cache invalidation, recording the rendered area for any reason, etc).

So calling it on each area gives the users more flexibility.

Ok.
I know this, but I didn’t understand what you said here:

In direct mode LVGL renderes all the dirty areas into the the frame buffer directly. flush_cb is called after each area, however you need to sync (that is swap the buffers, flush cache, etc) only when the last area is also rendered.

You can use lv_display_flush_is_last() to check if the last area was sent to the flush_cb.

I only needed to use this function( lv_display_flush_is_last() ) when I programmed the pic32mz/mk to be able to control the chip select pin.

The strange thing:

LV_DISPLAY_RENDER_MODE_PARTIAL → works
LV_DISPLAY_RENDER_MODE_FULL → works
LV_DISPLAY_RENDER_MODE_DIRECT → doesn’t work

@kisvegabor, could you edit this code and insert the function “lv_display_flush_is_last()” to work with the LV_DISPLAY_RENDER_MODE_DIRECT mode ?

void ili9806g_drv_display_flush( lv_display_t* drv, const lv_area_t* area, uint8_t* color_map )
{   
    (void)color_map;
    
    uint32_t length = (uint32_t) ( 2 * ( lv_area_get_width(area) * lv_area_get_height(area) ) );  
        
    lv_draw_buf_t* p = lv_display_get_buf_active(drv); 
    uint8_t* p_buf_act = p->data;   
  
    if (p_buf_act == (uint8_t*)p_buffer_a)
    { 
    
    #if lvgl_buffer_psram        
        // flush data from cache to the physical memory
        esp_cache_msync( (void*)p_buffer_a, length, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_UNALIGNED );
    #endif    

        ili9806g_drv_lcd_write_pixels_a( length, area );      
        lv_disp_flush_ready( drv );
    }
    else if(p_buf_act == (uint8_t*)p_buffer_b )
    {

    #if lvgl_buffer_psram            
        // flush data from cache to the physical memory
        esp_cache_msync( (void*)p_buffer_b, length, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_UNALIGNED );
    #endif

        ili9806g_drv_lcd_write_pixels_b( length, area );        
        lv_disp_flush_ready( drv );
    }
    else
    {
        printf("bug");
        return;
    }
}

I don’t know if it will work, but this my suggestion. Just add 3 lines at the very beginning:

void ili9806g_drv_display_flush( lv_display_t* drv, const lv_area_t* area, uint8_t* color_map )
{   
    /*Added by kisbegabor*/
    if(!lv_display_flush_is_last(drv)) { /*Return if it's not the last area*/
        lv_disp_flush_ready( drv );
        return;
    }

    (void)color_map;
    
    uint32_t length = (uint32_t) ( 2 * ( lv_area_get_width(area) * lv_area_get_height(area) ) );  
        
    lv_draw_buf_t* p = lv_display_get_buf_active(drv); 
    uint8_t* p_buf_act = p->data;   
  
    if (p_buf_act == (uint8_t*)p_buffer_a)
    { 
    
    #if lvgl_buffer_psram        
        // flush data from cache to the physical memory
        esp_cache_msync( (void*)p_buffer_a, length, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_UNALIGNED );
    #endif    

        ili9806g_drv_lcd_write_pixels_a( length, area );      
        lv_disp_flush_ready( drv );
    }
    else if(p_buf_act == (uint8_t*)p_buffer_b )
    {

    #if lvgl_buffer_psram            
        // flush data from cache to the physical memory
        esp_cache_msync( (void*)p_buffer_b, length, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_UNALIGNED );
    #endif

        ili9806g_drv_lcd_write_pixels_b( length, area );        
        lv_disp_flush_ready( drv );
    }
    else
    {
        printf("bug");
        return;
    }
}