pimoroni / hyperpixel

Setup for the Pimoroni Hyper Pixel 800x480 pixel multi-touch display
https://shop.pimoroni.com/products/hyperpixel
MIT License
96 stars 29 forks source link

Multitouch support #22

Closed bahamut657 closed 1 year ago

bahamut657 commented 6 years ago

I see that the support in multitouch is partial (script hyperpixel-touch). The software given read only 2 touch points (and sometimes is buggy). Is it possible to read touch list indefinitely? (I know that this screen can read more than 2) Regards Jacopo

Gadgetoid commented 6 years ago

I have some example code somewhere in the form of a custom driver that can read more than 2 touches, but the display is small enough that 2 is really the practical limit. Any more and it becomes tricky to distinguish between individual fingers, since - iirc - the sensor only has something like 14 vertical lines and 7 horizontal.

bahamut657 commented 6 years ago

Can u post some example code for enabling multitouch plz? Another thing with only 2 finger is: 1) start touch with finger A in position X,Y (near the top right side of the screen) 2) after a while start touching with finger B in position X-500, Y+200 (mantaining the finger A pressed) => Sometimes in the second touch arrive the X or the Y of the first finger

Gadgetoid commented 6 years ago

Found it, at least this is how far I got: https://gist.github.com/Gadgetoid/64e57db4a22e4cd585ad35c6be2c7682

bahamut657 commented 6 years ago

I tried your code...but it seems to work better the original one. With this new code, mantaining pressed a finger then pressing with the second one some point in the screen happens: 1) Sometimes touchend was triggered on the first finger (even if mantained pressed) 2) The second finger hit has sometimes the wrong X or Y 3) Is it possible to create a stable software managing at least 2 fingers? I found an example in the Internet(managing indefinitely fingers and also simplifies the implementation)..Could we apply this to hyperpixel-touch script? In case, I'm available to help you developing this piece of code if you want (this screen is wonderful but we need a stable driver for touchscreen) The example code is in the attached file hyperpixel-touch-more.txt

Regards, Jacopo

Gadgetoid commented 6 years ago

The attached code looks like another test I put together, where did you find it? I'm usually so buried under SD cards that these things go astray.

It had a problem, though; the relationship between reported touch ADC value, and distance to the actual row or col on the screen is not linear so as I moved my finger across the screen the position would accelerate and decelerate as it moved closer to/further away from each electrode. I need to find an algorithm that would map the nonlinear response of the ADC to a position between any two electrodes.

It also does not properly track touches, so a single touch at x=300,y=300 would be recognised as "Touch 1", but if you then touch at x=150,y=150 that would replace "Touch 1", and the original "Touch 1" would become "Touch 2."

bahamut657 commented 6 years ago

I found it on the Internet but it does communicate with EVDEV hooks. It is nice to know that the author is you :+1: I think we can inspire to Android http://www.masonchang.com/blog/2014/8/25/androids-touch-resampling-algorithm or there from CYPRESS http://www.cypress.com/file/134996/download Make me know if it is ueful and if I can help you. Regards, Jacopo

Gadgetoid commented 6 years ago

I've put together a basic pygame app for getting a better idea of the touch data and recognition. You can find it here: https://gist.github.com/Gadgetoid/8bc3bbbd64d7f96f585920eb1ef6abde

Unfortunately it's shown just how many bugs are in my current detection, it's pretty poor. It also makes no effort at all to actually track fingers across the screen, it just recognises raw points of touch which results in all sorts of problems.

bahamut657 commented 6 years ago

Thanks, I will try it soon