Xinyuan-LilyGO / T-Display-S3-Long

36 stars 11 forks source link

Double tap happening all the time #8

Closed d3mac123 closed 6 months ago

d3mac123 commented 6 months ago

@nikthefix I am not sure if this is related to your library (I guess it is related to the lcd_PushColors_rotated_90(0, 0, 640, 180, (uint16_t*)sprite.getPointer()); call but, I am not sure) but, every time I tap the display (for example, a tap would go to another screen), I am getting double returns.

Explaining better, lets say the user is in screen1 and taps the display. He should go to screen2. However, what is happening is the code sends him to screen2 but returns to screen1. Any ideas why?

nikthefix commented 6 months ago

Hi,

How have you configured the 'tap to select screen' in your sketch? Is it a button or just a tap anywhere on the panel? Is it 'activate on press' or 'activate on release'?

I suggest starting with separate gui buttons for separate functions - just until everything seems to be working as it should. Since the touch driver is always polling the sensor (at least in the Lilygo demo), touch functions at the same coordinates on 2 different screens may rebound causing the effect you describe. You end up with a kind of gui oscillator!

Activate on release can really help with this. Using the touch interrupt pin to limit polling to touch duration and detect a finger release is also a good thing. Use software traps to compare and discard any unchanged polled coordinates.

I've noticed that some touch panels show coord 0,0 upon release. I guess this is to help in cases where there is no interrupt implementation but it can problematic if you don't set a trap for 0,0

I have touch working with LVGL and my modified graphic driver so I think the hardware and driver are OK so far. I'll try it with TFT_eSPI. Are you using TFT_eSPI touch implementation or rolling your own?

Cheers and thank you for the coffees.

nik

d3mac123 commented 6 months ago

I have to admit my development skills are not the best so, my answers will surprise you :)

Would you happen to have any basic examples on how to set up and capture a button touch with the TFT_eSPI?

Regarding the coffees, you deserve way more than that. Thanks again!

nikthefix commented 6 months ago

Ah yes, the Lilygo example is a 'blunt instrument' implementation of touch. You have to do more to make it useful. I'll post an example asap but I think Volos will have something supreme in the next day or two which we can all learn from.

Or maybe not - I know he's frustrated with it. As am I. It's good but it could have been better. Just a matter of clearing out the weeds. It's great hardware but the software....

In the meantime, you have everything you need for your touch ui. It's nothing more than a monitor of touch coordinates. You marry this with known regions of buttons etc in TFT_eSPI and trigger functions based on incursions into those spaces. Most mobile phone apps use the 'activate on release' approach 'cos it makes a lot of sense! And because we tend to tap buttons we don't notice that they're active on release.

I prefer activate on press. More immediate. I'll post a TFT_eSPI example with touch here as soon as - but Volos will beat me to it:)

I'm working on getting region update of the screen so that we can speed things up. There's an odd problem which may be hardware related.

Watch this space and please continue to feed back.

nik