ImpulseAdventure / GUIslice

GUIslice drag & drop embedded GUI in C for touchscreen TFT on Arduino, Raspberry Pi, ARM, ESP8266 / ESP32 / M5stack using Adafruit-GFX / TFT_eSPI / UTFT / SDL
https://www.impulseadventure.com/elec/guislice-gui.html
MIT License
1.17k stars 209 forks source link

Strange redraw strobing/flashing - TFT_eSPI/ESP32/ILI9341 #295

Open loopyengineeringco opened 3 years ago

loopyengineeringco commented 3 years ago

Hi guys

I'm using TFT_eSPI/ESP32/ILI9341. Using the latest available version of guislice and TFT_eSPI and taking advantage of the new image push code.

I have a hardware button toggling the visibility of the glowing image which is on top of the non-glowing version.

1606000627969_3

image

image

But as you can see, the drawing of the image tile isn't clean, it seems to clear the image with white first.

Is this a hardware limitation?

Apologies if this is more a TFT_eSPI question, I thought I'd ask you guys first as you're super knowleadgeble in this.

I tried all the SPI speeds from 10mhz to 80mhz, behaves the same just the angle of the diagonal line changes slightly (&is a little wobbly at 80mhz :-)).

It also seems to happen when popping up a new page, not just drawing images from flash. Feels like an e-paper display thing, where the pixels are flashed before the screen is filled with the correct pixels.

Any ideas how to fix/work around this? Thanks for any pointers!

ImpulseAdventure commented 3 years ago

Hi —

Can you confirm a couple things for me:

Looking at my code, I think I should probably be defaulting the image to have its fill attribute disabled. This might eliminate an extra background fill as in (3).

If you are able to attach this particular sketch (with the accompanying images), I may be able to carry out some of the tests myself.

Thanks!

loopyengineeringco commented 3 years ago

Thank you for the points @ImpulseAdventure - 'gslc_ElemSetFillEn(&m_gui,imageElement,false)' indeed masked the issue so it now wipes with the background colour instead of white: image (I think it's ghosting just because of pixel lag)

I wanted to ask first, in case there's something easy to try before uploading everything! If you'd be so kind as to take a look to see if the tearing can be eliminated, i would appreciate it. I have attached the sketch, guibuilder project file, and libraries (GUISlice, TFT_eSPI, TimerObject). If the tearing now seems normal behaviour, then I'm happy to keep it as is, it's not noticeable unless you look for it. Thanks! RedrawStrobeIssue295.zip

Pconti31 commented 3 years ago

@ASMotionLab @ImpulseAdventure Hi, I don't have anything to do with the API but I did write and do support the Builder. So I thought I would answer why the Builder doesn't have FillEnable setting. The answer is simply that it does but I thought it would confuse people so I just word it as "Transparent?= false" as default. If you set "Transparent?= true" it creates the gslc_ElemSetFillEn(&m_gui,imageElement,false) API call. Otherwise no call is made since the API default is Fill is enabled. There was a bug in earlier versions that wouldn't set this correctly. Paul--

loopyengineeringco commented 3 years ago

Thank you @Pconti31 for explaining, it makes perfect sense.

ImpulseAdventure commented 3 years ago

@ASMotionLab -- thanks again for the detailed analysis!

When you set E_ELEM_IMAGE34 and E_ELEM_IMAGE_35 to use FillEn(false), you should not see any white strobing effect. ie.: image

You mentioned that you are still observing tearing -- was this referring to the black redraw before the image button is redrawn? If so, this briefly appears because: a) the current image draw routines support transparency AND b) when we hide or update an element, we need to redraw the background before drawing the [transparent] image since it is difficult to determine a priori what will show through (assumes we don't use more advanced techniques described below)

By utilizing a read/modify/write methodology (only supported by a subset of [readable] displays / drivers) or an offscreen bitmap, it may be possible to enhance the redraw routines to eliminate such "overdraw", but unfortunately I haven't tried embarking on this as these features are not widely available.

Perhaps I could add an API that adds an image attribute that indicates whether transparency is required or not. This would enable one to determine when the underlying images / background are fully obscured and hence we can optimize the redraw. This might work for your case since I don't believe your particular icons relied on transparency.

Let me look into this to see if this can be done without too much work. Please note that I am quite busy at the moment and may not have an opportunity to try this out for a bit.

thanks!

Pconti31 commented 3 years ago

@ASMotionLab @ImpulseAdventure I wonder if a better and more consistent solution than a new API would be to simply add a new feature say transparent fill color for images. Currently setting a Fill Enabled to false means the UI element is transparent and you deal with as such. But this doesn't cover this case where he wants the image to be non-transparent but still don't refresh background. I would think that first checking the fill color for say your current transparent "pink" could than indicate to your API to optimize by not refreshing background for this UI element. The Builder could even add a "Transparent" Color to the possible fill color selections. Just a thought. Paul--