Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:07 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Touch and the manual

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:34am 01 Sep 2016
Copy link to clipboard 
Print this post

In the MM manual (5.2) page 19 it says
[quote]For example, if the command OPTION TOUCH 7, 15 was used to configure touch the following program will
print out the X and Y coordinates of any touch on the screen:
SETPIN 15, INTL, MyInt
DO : LOOP
SUB MyInt
PRINT TOUCH(X) TOUCH(Y)
END SUB
The interrupt can be cancelled with the command SETPIN pin, OFF.[/quote]

On the lcd I'm using it was set as OPTION TOUCH 50, 51

If I try this routine with my pin 51 instead of pin 15, then I get the error
[quote]SetPin 51, INTL, MyInt
Error: Pin 51 is reserved on startup
[/quote]

Why?

What I want to do is detect if the screen is touched (anywhere) then once it is do a cls and page 2 type thing
but to start this I need the interrupt working
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:43am 01 Sep 2016
Copy link to clipboard 
Print this post

When you use OPTION TOUCH 50,51 the pin 50 is the CS pin and 51 the interrupt pin.
Sofar so good.
As those pins are now used and their function defined you can not do that again with a SETPIN command.
The error tells that they are already reserved. (by the OPTION TOUCH command)

To capture the touch down and touch up interrupts you need to use:
[code]
GUI INTERRUPT MyTouchDown, MyTouchUp
[/code]

You also need to have two subroutine to match that statement.

[code]
SUB MyTouchDown
'....
END SUB

SUB MyTouchUp
'...
END SUB
[/code]



Microblocks. Build with logic.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:50am 01 Sep 2016
Copy link to clipboard 
Print this post

Thanks Jean

Would I be right in assuming MyTouchDown is when the screen is touched first
and MyTouchUp is when it's pressed a 2nd time?
EDIT : just tried it and no it doesnt
Edited by lew247 2016-09-02
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9589
Posted: 02:02am 01 Sep 2016
Copy link to clipboard 
Print this post

MyTouchDown is when you touch the screen(so touching a button etc), and MyTouchUp is when you remove your finger from the screen.

So, MyTouchDown needs to work out which screen control is being touched and do whatever, and MyTouchUp(which is optional) is called whenever touch is released - on ANY control that was being touched.

The process is:

1) Finger or touch pen etc touched on screen
2) MyTouchDown called.
3) Finger or touch pen etc lifted from screen
4) MyTouchUp called.

This happens every single time the screen is touched. Most of the time, you only need to know when something has been touched, but not when it has been released, and a good proportion of the time, the optional MyTouchUp interrupt can be ignored.Edited by Grogster 2016-09-02
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10215
Posted: 02:09am 01 Sep 2016
Copy link to clipboard 
Print this post

I think this is a difference between the MM and MM+

On the MM Geoff has allowed a setpin command to be used in order to create the interrupt. On the MM+ there is a GUI command so SETPIN is not allowed
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:18am 01 Sep 2016
Copy link to clipboard 
Print this post

Thanks Peter, that explains why I got confused, I "assumed" it would be the same with both.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025