How to know all the draw tasks are finished

Description

Is there any function to check if all the draw tasks are finished?
I know that whenever a (joined) area is drawn, the callback will be called.
If there are multiple joined areas, will the current mechanism wait for all areas being redrawn and called the flush callback “once”? (Based on the document, I think no.)

I need to wait for all the draw tasks finished before I render them to my device.

Any suggestions are appreciated.
Many thanks for your help.

monitor_cb will be called when all drawing is done.

@BLUE_S

If there are multiple joined areas, will the current mechanism wait for all areas being redrawn and called the flush callback “once”? (Based on the document, I think no.)

I have done a test on this with an online debugger. When the buffer is set to a smaller size than the whole frame, flushing callback is called more than once.

Example:

void lv_hal_init(void){
 hw_disp_init(); //low level display init 
 static lv_color_t lv_buf_array[LV_HOR_RES_MAX*LV_VER_RES_MAX];
 static lv_disp_buf_t lv_disp_buf;
 lv_disp_buf_init(&lv_disp_buf, lv_buf_array, NULL, LV_HOR_RES_MAX*LV_VER_RES_MAX);
}

When I ran the debugger with breakpoint set to my_flush_cb(), it halted on it only once with the whole display updated.

However, if I set the buffer size half with LV_VER_RES_MAX -> LV_VER_RES_MAX/2, update is done in two passes.

lv_disp_flush_is_last also can be used.

1 Like

Hi @kisvegabor,

There are a lv_disp_flush_is_first ?

I am thinking to use display “chip_select signal( cs = 0 )” in “lv_disp_flush_is_first” and display “chip_deselect signal( cs = 1 )” in “lv_disp_flush_is_last”.

This way i can control the chip select signal from the display as if it were an information packet (command plus display data(pixels)).

I think it is important not to leave the chip select fixed at logic level 0, because i think that toggle chip select reset state machine of display controller.
If the display goes into an unknown state, it may crash the display controller with fixed chip select( cs = 0 ).

Thank’s.

Hi,

There is no lv_disp_flush_is_first or similar. But you can handle this with a local variable. E.g.

void my_flush_cb(...)
{
   static bool last = false;

  if(last == true) {
    last = false;
    CS = 0;  
 }


  if(lv_disp_flush_is_last(drv)) { 
     last = true;
     CS = 1;
  }
}

Or simply:

void my_flush_cb(...)
{
  CS = 0;  //Alwyas clear
 
  if(lv_disp_flush_is_last(drv)) { 
     CS = 1;
  }
}

Could it work in your case?

1 Like

Hi @kisvegabor,

I did it like this and everything seems ok.

void my_flush_cb(...)
{
    static bool first = true;

    if( first == true )
    {
        first = false;
        CS = 0;  
    }

....
....
....


    if( lv_disp_flush_is_last(drv) ) 
    { 
        first = true;
    
        // Wait for the end of the transmission

        CS = 1;
    }
}

Thank’s for the help.

1 Like