Slider Flickers #2056
-
First of all I would like to say I appreciate the work that bodmer has done to create this amazing library. Hi, So, I've wrapped my head around the internet trying to make it work but no luck. tl;dr: I'm trying to make a "Slider" in the sense that there's a path and an object running on top of it. The final idea would be to have a gradient rectangle (background) and on top of it a ring that would slide on top of it depending on the variable it would slide more to one side or to the other (0% to 100%). My problem is in the "transparency" in the inside of the ring. I haven't been able to make it without either flickering the background or the ring itself. To explain what I'm doing right now in my code
code:
I've narrowed down the problem to one simple thing. (ofc I'm not a pro level programmer so I might just be building everything wrong) In the beginning I was trying to achieve this with an image as the background, to me pushImage should do "virtually" (in ram) the same as pushSprite does to the screen. Since that wasn't working I tried to build the background with a simple Rectangle. My problem remained if I didn't do a pushSprite after building the background, which led to flickering due to "deleting" the foreground ring every cycle. (image 2) My obvious solution is to have the circle not be transparent in the middle, which doesn't require me to do a pushSprite after drawing the background every time. I would be very appreciative if someone could help me in my crusade or push me towards a suitable path, I have researched a lot and I feel like I have a good enough understanding on how sprites work. But my underlying doubt relies with question why the inside of the ring doesn't get updated without pushing the bkg sprite. I've also tried to use a drawCircle (looping number x of circles) instead of a filled circle. While this solution works amazingly well, the circles aren't filled properly having unfilled pixels in the middle |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
The problem is that the screen is like a peice of paper, if you draw and X on it and then an X somewhere else the first X does not disappear and has to be erased somehow. In the TFT_eWidget library the erasing is done by having a pixel border of the slider colour and background colour in appropriate places in the slider knob sprite, then the slider is only ever moxed 1 pixel at a time to the new position. Thus the border wipes the old knob image as it moves. Transparency is not used as then the last knob position is not erased by over-writing with the correct colour (this is how the Yin-Yanf example works, if you slow it down by setting WAIT to 1000 you will see what happens. You could use the same approach for the inside of your knob, but you have to know the colour of the slider "slot" to fill it with a circle. Using transparency will leave previous images on the screen "behind" the new sprite. I would get your project working first with a simpler approach, perhaps using the TFT_eWidget library, then improve it as skills develop. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Here is the code that is close to your needs. It uses other useful functions:
|
Beta Was this translation helpful? Give feedback.
Here is the code that is close to your needs. It uses other useful functions: