Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:10 20 May 2024 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 : Question about Touch

     Page 3 of 3    
Author Message
Grogster

Admin Group

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

  lew247 said   I thought on the test it drew the touch points
top left top right bottom right bottom left?


It does.









These are normal results. Yours are really badly off.

Smoke makes things work. When the smoke gets out, it stops!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 05:52am 01 Sep 2017
Copy link to clipboard 
Print this post

The problem was the touchscreen
Luckily I had a spare put away somewhere, found it and connected it and it works great
The buzzer even beeps now when the screen it touched :)


Now is there any way to "draw" 2 arrows? 1 in red and 1 in blue?
Red facing up and the blue facing down but I only want one displayed at any one time?
Edited by lew247 2017-09-02
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:14am 02 Sep 2017
Copy link to clipboard 
Print this post

Can someone check this code and tell me if it "should" work please?

It draws the boxes properly and Touch "SHOULD" work in the boxes but its not
maybe I've made a "stupid" mistake?

[code] rBOX 560 ,295,170,50,10,RGB(BLACK),RGB(131,178,37) 'displaybox "Tomorrow"
rbox 560 ,355,170,50,10,RGB(BLACK),RGB(GREEN) 'displaybox "Day 2"
rBOX 560 ,415,170,50,10,RGB(BLACK),RGB(BLUE) 'displaybox "Day 3"
TEXT 640,320, "Tomorrow", CM, 3, 1, RGB(black),RGB(131,178,37)
TEXT 640,380, "Day 2", CM, 3, 1, RGB(black),RGB(GREEN)
TEXT 640,440, "Day 3", CM, 3, 1, RGB(black),RGB(BLUE)

' '***********************IF the Buttons are touched********************************
IF Touch(X)>560 AND Touch(X)<(730) AND Touch(Y)>295 AND Touch(Y)< (345) THEN print "Tomorrow Touched" 'If Touch pressed
IF Touch(X)>560 AND Touch(X)<(730) AND Touch(Y)>355 AND Touch(Y)< (405) THEN print "Day 2 Touched" 'If Touch pressed
IF Touch(X)>560 AND Touch(X)<(730) AND Touch(Y)>415 AND Touch(Y)< (465) THEN print "Day 3 Touched" 'If Touch pressed
[/code]Edited by lew247 2017-09-03
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9084
Posted: 02:36pm 02 Sep 2017
Copy link to clipboard 
Print this post

Great you found the touchscreen was crook - something was not right there....

Why are you NOT using buttons and advanced GUI controls?
IE: Why are you using touch co-ordinates instead of buttons, and basic drawing commands like TEXT instead of GUI CAPTION?

GUI BUTTON will automatically configure the touch co-ordinates for you.
All you have to do, is define the button with the GUI BUTTON command.

As an example, take the following button:

  Quote   GUI button BU_MR_ACK,"OK",250,375,250,100,RGB(Yellow),RGB(gray)


This will draw a large-ish button down the bottom of a 7" LCD, then when you touch it, it will animate as being touched, and will make the 'Click' noise from the peizo if you have set up that side of things.

This will keep running, even at the command prompt, so if you type in the above at the command prompt and press ENTER(change BU_MR_ACK to a number), you should get a button on the screen, and when you touch it, it should 'Click' and look like it is depressed. Release it, and it should pop back up again.

To check this button, you use the TOUCH(REF) function inside a GUI INTERRUPT, such as this:

  Quote  Sub MSG_RXD_OK 'Touch interrupt for OK button in MSG_RXD routine
LCD_OK=0 'Clear flag
Select Case Touch(REF)
Case BU_MR_ACK 'OK button touched
LCD_OK=1
End Select
End Sub


Then you catch that touch inside a loop.

I will try to find a little time tonight to take YOUR example, and just re-format it with touch buttons, captions, and an interrupt so you can see the whole picture if what I am writing here still has you scratching your head.

Don't worry if you ARE still scratching your head - GUI's are confusing for a start.
Edited by Grogster 2017-09-04
Smoke makes things work. When the smoke gets out, it stops!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 09:37pm 02 Sep 2017
Copy link to clipboard 
Print this post

I did try GUI BUTTON but I couldn't get it to do what I wanted because I want it to jump to a sub when it is pressed
but what I found is while it is pressed it kept going to that sub and nothing else until I touched the button again to release it

Unless you know a way to get it to only go to the sub once :)
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9084
Posted: 10:26pm 02 Sep 2017
Copy link to clipboard 
Print this post

You probably need some flags to tell the system what the state of the button is.
I will rustle up some demo code in the next few hours and post it here.
Smoke makes things work. When the smoke gets out, it stops!
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1401
Posted: 10:41pm 02 Sep 2017
Copy link to clipboard 
Print this post

The two code examples I posted on Page 2 take care of that. Here it is again.

In this case you were using a switch, changing it to a button is correct way to go.



CONST GUI_TOMORROW = 25
CONST GUI_DAY2 = 26
CONST GUI_DAY3 = 27

GUI SWITCH GUI_TOMORROW,560,295,170,50,RGB(BLACK),RGB(RED)
GUI SWITCH GUI_DAY2,560,355,170,50,RGB(BLACK),RGB(GREEN)
GUI SWITCH GUI_DAY3,560,415,170,50,RGB(BLACK),RGB(BLUE)

Sub PenDown()

Select CASE Touch(REF)
CASE GUI_TOMORROW
TOMORROW
CASE GUI_DAY2
DAY2
CASE GUI_DAY3
DAY3
END SELECT

END SUB


Or do it this way in the main loop.


DIM ThisControl as integer

Sub PenDown()

Select CASE Touch(REF)
CASE GUI_TOMORROW
ThisControl = 1
CASE GUI_DAY2
ThisControl = 2
CASE GUI_DAY3
ThisControl = 3
END SELECT

END SUB

DO
IF ThisControl = 1 then TOMORROW
IF ThisControl = 2 then DAY2
IF ThisControl = 3 then DAY3

ThisControl = 0

LOOP

Edited by KeepIS 2017-09-04
It's all too hard.
Mike.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9084
Posted: 12:01am 03 Sep 2017
Copy link to clipboard 
Print this post

Completely agree with KeepIS above, so I won't bother to post any demo code.

TOMORROW, DAY2 and DAY3 are your subroutine names that you want to call.

Please do stick with it - GUI is confusing for a start, but hang in there, cos once you know how to do it, it is a fabulous feature to know how to use.
Smoke makes things work. When the smoke gets out, it stops!
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 12:28pm 03 Sep 2017
Copy link to clipboard 
Print this post

I might chime in here,

Both the Grog-man and KeepIS are right, but if I may, I'll just make a couple of additions to KeepIS' code to hopefully make it easier to understand:-




CONST GUI_TOMORROW = 25
CONST GUI_DAY2 = 26
CONST GUI_DAY3 = 27

GUI INTERRUPT PenDown 'Important line, without it Pendown won't be called

GUI BUTTON GUI_TOMORROW,"Tomorrow",560,295,170,50,RGB(BLACK),RGB(RED)
GUI BUTTON GUI_DAY2,"Day2",560,355,170,50,RGB(BLACK),RGB(GREEN)
GUI BUTTON GUI_DAY3,"Day3",560,415,170,50,RGB(BLACK),RGB(BLUE)

Sub PenDown

Select CASE Touch(REF)
CASE GUI_TOMORROW 'is the TOMORROW button pressed?
TOMORROW 'call sub TOMORROW
CASE GUI_DAY2 'is the DAY2 button pressed?
DAY2 'call sub DAY2
CASE GUI_DAY3 'is the DAY3 button pressed?
DAY3 'call sub DAY3
CASE ELSE 'the "oops I didn't expect this" case
EXIT SUB
END SELECT

END SUB

Sub TOMORROW

'your code here

END SUB

Sub DAY2

'your code here

END SUB

Sub DAY3

'your code here

END SUB



Personally I think in this case GUI BUTTON's instead of SWITCH's are the way to go. The Button is a momentary type of control, whereas the switch is a click on/ click off job.
It's definitely worth converting all of your controls to the GUI set of commands.
They are a lot easier to work with.

Hope the above makes sense,

GTG!
...... Don't worry mate, it'll be GoodToGo!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 09:09pm 04 Sep 2017
Copy link to clipboard 
Print this post

Thank you so much everyone
I really couldn't get my head around how the gui interrupt worked and how touching the button worked
thanks to everyone it's now really clear and really simple once you actually understand it
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:56am 16 Sep 2017
Copy link to clipboard 
Print this post

Is there a way to delete display boxes?

AN example is
The main program draws display boxes in the top left quarter of the screen
If I call a subroutine by touching a button
Is there any way to delete those display boxes?
There's a background picture so I ideally don't want to do a CLS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8608
Posted: 07:07am 16 Sep 2017
Copy link to clipboard 
Print this post

MM+ manual

GUI HIDE

or

GUI DELETE
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 07:48am 16 Sep 2017
Copy link to clipboard 
Print this post

Thanks Peter, I do read the manuals but unfortunately I forgot things like GUI Hide after I started working out how GUI worked.

 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 08:00am 16 Sep 2017
Copy link to clipboard 
Print this post

Just tried GUI HIDE and unfortunately it replaces the GUI button with a black box
(current background colour)
Edit: GUI DELETE does the same as GUI HIDE
What I'd like to do is remove the button but leave the background picture there instead of a black box
I presume this isn't possibleEdited by lew247 2017-09-17
 
     Page 3 of 3    
Print this page


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

© JAQ Software 2024