|
Forum Index : Microcontroller and PC projects : Thoughts on using touch screens
| Author | Message | ||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
function swipe time,min,max Swipe dir$= Swipe dir$ will = U,D,L,R for maxspan movement default maxspan is movement of 2/3 of screen dir$ will = u,d,l,r for minspan movement default minspan is movement of 1/2 of screen time is minimum swipe frame less is a touch or simple verison dir$=swipe time dir$ will = U,D,L,R for any thing over 1/2 screen movement time is minimum swipe frame less is a touch or are we locked in to the values of x and y at time of the touch interrupt. Quazee |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
As far as I know, you are locked into the value of X and Y at the time of interrupt - for now. Swipe might be something Geoff or Peter could add, but I expect it would probably not be that easy. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6351 |
TOUCH(X) and TOUCH(Y) can be called at any time. You could use an interrupt to get the starting position and then read again after a short delay. How you do it would depend on the device and the main program flow. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
@ Jim - Clever. And very simple. Smoke makes things work. When the smoke gets out, it stops! |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
Jim's solution is elegant and simple. Much better than cluttering the language with extra features with limited application. Geoff Graham - http://geoffg.net |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6351 |
Crude but something to start with The 300mS time will need adjusting as well as the 30 pixel dead zones Works on a MX170 and ILI9341 display. Jim VK7JH MMedit |
||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
My Granddaughter was asking. She lives on her phone and drawing tablet. The really nice computer we got her has dust and cobwebs. I may highjack it. Flipping around screens is something she wanted to do with the Micromite she plays with. Thanks TassyJim I'll pass the code on to her and see what artful things she does with it. Could this be a C-function? Asking as I don't do C. On the controllers they wanted bigger touch zones so . . . Instead of testing start xxx/yyy end xxx/yyy for object detection. This predefines the object size and uses the itx/ity or icx/icy with pendown gives a row col like row 2 col 5 easy for select case. The keyboard function I posted uses this way. (now how do I to point to post? ) SetPin 2, intl,touched SetPin 2, inth,untouched Sub touched tx=Touch(x):ty=Touch(y) If tx=-1 Then Exit Sub If ty=-1 Then Exit Sub itx=(tx\32):ity=(ty\24) ' 10 by 10 icx=(tx\64):icy=(ty\48) ' 5 by 5 PenDown=1:PenUp=0 End Sub Sub untouched PenDown=0:PenUp=1 End Sub Thanks Quazee TassyJim just tried the code on a 4" Hat Stand works. Like you said need to tune it a bit, 400 did better. She'll be very happy to play with it. |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
or another take - without touching your screen, control your 'mite like a jedi https://www.ebay.co.uk/itm/APDS-9960-GY-9960-Digital-RGB-Ambient-Light-Proximity-Gesture-Sensor-Module/202068693590?hash =item2f0c3b9256:g:YH8AAOSwNpBZzmyg |
||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
Jim thanks for getting this going for her. Here is what she is playing with. 'Hat Stand with 4" LCD Option EXPLICIT Dim tX, tY, PenDown,swipe$ SetPin 5, INTL, touched ' touch interrupt pin SetPin 5, inth,untouched Font 1,2 Color RGB(yellow),RGB(blue) CLS Do Select Case swipe$ Case "U" Text 10,100,"Going Up a screen " Case "D" Text 10,100,"Going Down a screen " Case "L" Text 10,100,"Going to screen on Left " Case "R" Text 10,100,"Going to screen on Right" Case "T" Text 10,100,"Just a Touch " End Select Loop End Sub touched tX=Touch(X) tY=Touch(Y) PenDown=1 SetTick 400, swiped, 1 ' check in 400mS End Sub Sub untouched PenDown=0 End Sub Sub swiped Local swX, swY, swDX, swDY,swXS,swYS SetTick 0, 0, 1 ' disable the timer swX = Touch(X) swY = Touch(Y) If pendown Then ' pen still down swDX = (swX - tX) swDY = (swY - tY) swXS=Sgn(swDX):swDX=Abs(swDX) swYS=Sgn(swDY):swDY=Abs(swDY) End If If (swDX > swDy) And swXS=1 Then swipe$="R" If (swDX > swDy) And swXS=-1 Then swipe$="L" If (swDX < swDy) And swYS=1 Then swipe$="D" If (swDX < swDy) And swYS=-1 Then swipe$="U" If swDX+swDY <30 Then swipe$="T" End Sub Jim Thanks again Quazee |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
If she is not a member here already, please encourage her to join. Heaps of people to offer help here, and then you would not need to act as a message relay. ![]() ....or you might not mind doing that. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
@grogster I told her she should. Well I guess she is not ready to show her raw code to anyone else. Here is a bit she added to turn swipe on and off Sub touched tX=Touch(X) tY=Touch(Y) PenDown=1 If swipe$<>"N" Then SetTick 400, swiped, 1 End Sub Thanks again Jim she is having fun playing with 9 screens she can flip to. (Im waiting on her trying to do the diagonals) Quazee |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |