Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:03 13 Nov 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 : MMBASIC TOUCH FUNCTIONS

Author Message
TrevorW
Newbie

Joined: 20/08/2019
Location: New Zealand
Posts: 6
Posted: 01:43am 23 Aug 2019
Copy link to clipboard 
Print this post

I have a (grandkid's) requirement to draw on a 2.8" display in a similar fashion to that provided by the GUI TEST TOUCH subroutine. Trying to duplicate this using MMBASIC's interrupt-driven TOUCH() functions is not satisfactory as you have to lift and replace the pen to generate a new interrupt. Embedding GUI TEST TOUCH in the program also does not work as it clears the screen which then removes a button installed on the display. Also an issue exiting out of the function.

I sense I need a CFUNCTON for this screen size that provides a preesure value in addition to the X- and Y- coordinates.

Any assistance/advice would be appreciated

Regards,
Trevor W
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 09:33am 23 Aug 2019
Copy link to clipboard 
Print this post

I think I understand what you mean... take a look at this vid and see how the traces change with the stylus movement.

https://www.youtube.com/watch?v=wP46Ie4o3F8&feature=youtu.be&t=44

If this is like what you are after? If so, I can give you some pointers and the bit of code involved.

let me know

h
Edited 2019-08-23 19:38 by CaptainBoing
 
TrevorW
Newbie

Joined: 20/08/2019
Location: New Zealand
Posts: 6
Posted: 11:21am 23 Aug 2019
Copy link to clipboard 
Print this post

Thanks for the reply.
Yes, this is close to what I was after. In the video part of the line graph is replaced by a new segment. In my case I would like to leave the original intact and draw a new (another) line. Having said that if I had some code for starters I would like to think I could make the customisation needed.

TrevorW
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 03:29pm 23 Aug 2019
Copy link to clipboard 
Print this post

Ok, that's good. here's how I did it.

first, I dispensed with doing it via interrupt. I am only doing one thing so there is no harm in having the process whiz round in a circle doing it - nothing else is going to be starved of CPU.

In that clip, here is the code that looks for the touches. As you already noted I removed the old trace in favour of the new but that is just a complication - my application needed it - it's actually a lot easier not to have to do that.

It is really quite easy...  just use the TOUCH(X|Y) function to return the coordinates and draw to them from the current (last) graphics position... I use a graphics module so I can talk in "sensible" co-ordinates (with 0,0 in the bottom left) so you can change the drawing bit to suit, but the interesting bit to solve your problem is at the top - if you want that module too, you can grab it here:
http://www.fruitoftheshed.com/MMBasic.Sensible-Cartesian-Co-ordinate-graphics-pack.ashx


Do
tx=Touch(x):ty=Touch(y)
If tx=-1 Or ty=-1 Then Exit Do ' here we determine we are not touching the screen

Draw tx,ty ' part of my graphics module
Loop ' we go round in the loop while you touch the screen


hope this helps, should get you past you sticking point

h
Edited 2019-08-24 01:31 by CaptainBoing
 
TrevorW
Newbie

Joined: 20/08/2019
Location: New Zealand
Posts: 6
Posted: 12:56am 24 Aug 2019
Copy link to clipboard 
Print this post

Works like a charm. Thanks for help.

TrevorW
 
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