Customer btn flash

Description

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

STM32

What LVGL version are you using?

V7.9

What do you want to achieve?

Draw the customer btn.

What have you tried so far?

As the code, the btn is fine if no obj creating on it .If some obj created on it(not fully covered) and during pressing , there have large chance to flash on the background btn. Anything wrong?
Best Regards,

Code to reproduce

 if(mode == LV_DESIGN_COVER_CHK) {
       /*Use the original function for cover check*/
      return old_btn_design(obj, mask, mode);
    } else 
		if(mode == LV_DESIGN_DRAW_MAIN) {
	  lv_disp_buf_t * vdb_p = lv_disp_get_buf(_lv_refr_get_disp_refreshing());
      lv_color_t * vdb_buf_tmp= vdb_p->buf_act;
	  draw_buf(vdb_buf_tmp);
);	
    } else if(mode == LV_DESIGN_DRAW_POST) {
        /*Use the original function for post draw*/
        old_btn_design(obj, mask, mode);
    }

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Hi, embeddedt,
I doubt the issue is in the mode == LV_DESIGN_COVER_CHK , right? When the top obj is pressing, the button behind ,Which is not fully covered , should totally redraw before the top obj being drawing. But there have chance to invert the order. How can I debug?

Best Regards,
James

I don’t fully understand your question but it looks to me like you’re accessing the VDB directly from the widget, instead of using the standard lv_draw APIs. That might be the problem.

1 Like

Hi, embeddedt,
Many Thanks!
Yes I am copy the drawn buffer to the VDB in the object area. The flash means the part of the backgroud button will have chance to jump to the top in the covered area, likely the fault of the mode == LV_DESIGN_COVER_CHK. When an obj is covered partly , doed the obj being drawing fully when updating?

Best Regards,
James

If I understand it correctly, a partially covered object will be redrawn fully from a logical perspective, but the expectation is that LV_DESIGN_DRAW_MAIN will skip drawing the fully covered areas of the object. The lv_draw functions also use the mask parameter to only redraw the necessary portions of the rectangle/arc/etc. However, I don’t know how to make that work when manipulating the VDB. I don’t think that’s the intended use case.

1 Like

Hi, embeddedt,
Many Thanks!
It might due to the directly copying the VDB without the cover check in the LV_DESIGN_DRAW_MAIN. The back button will show the live picture and need to be clickable or pressable.I decode the picture in a buffer and copy to the VDB. What obj would you suggest to realise that purpose SAFETY?

Best Regards,
James

I think you would want to use a canvas. If you call lv_obj_set_click(canvas, true) on it you can receive click events, just like a button.

1 Like

Hi, embeddedt,
Many Thanks!
I wil try.
BTW, it seems have not support the gesture events in the lib, like zoom in /out?

Best Regards,
James

That’s correct. Multitouch is not supported because it’s often not needed on embedded systems.

1 Like

Hi, embeddedt,
Many Thanks!

I had tried the canvas and it works but a little slower than the direct buffer copy.
It is worth to find out the issue of my original code. What is the main purpose of the LV_DESIGN_COVER_CHK state in the design function? Must I use the MASK when drawing in the LV_DESIGN_DRAW_MAIN mode?

Best Regards,
James

Sorry; I’m not familiar enough with the design functions to give a confident answer. :slightly_smiling_face:

I’ve asked @kisvegabor to comment.

1 Like

Cover check tells LVGL if the object covers the area to redraw. It is used during finding the “top object” from where drawing should start.

In LV_DESIGN_DRAW_MAIN all you need to do is respecting the clip_area because no drawing should happen out of it.

A screenshot or video would be really helpful to see how “flashing” really looks like.

1 Like

Sorry , duplex text.

Hi, kisvegabor,
Many Thanks!

  1. If so, the old_btn_design(obj, mask, mode) should work within the design function. Right?
  2. Flash means the partially covered area of the background btn will show on the top instead of the part of the top obj ,which created on the btn, sometime when pressing the top obj . In my old customer design function , I just copy the whole drawn buffer to the position of the background btn should be in the VDB, regardless of the clip area. So that might be the reason? Per my understanding, the partially covered obj will be redraw wholly in each refresh cycle and so the clip area should equal to the object position and size ,then will have no use in that design function calling. Right?

Best Regards,
James

Yes.

Let’s say there is a background image and there is a button with a label on it and you press the button. The followings happen:

  1. Let’s say the button has a radius and therefore can’t fully cover the area. So the background image will be the top object.
  2. The background will be redrawn only under the button. The clip area can be:
    • equal to the size of the button if your disp_buf (set in the display driver) is large enough to store the whole area to redraw
    • smaller than the button, and equal to the size of the disp_buf. (in this case, this area is refreshed in multiple chunks)
  3. After the background, draw the button too.
  4. After the button draw, the label. The clip_area is truncated to the coordinates of the label to indicate where the label can draw.

Hi, kisvegabor,
Thanks a lot!

I will try

Best Regards,
James