Mintoris Forum

Author Topic: Using the onTouch interrupt  (Read 1183 times)

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Using the onTouch interrupt
« on: Jan 24, 2018, 08:06 PM »
Thread started by email to support@mintoris.com

hello Chuck,

thanks a lot for investing your time and
answering my request.

I tried your suggestion with the following
sample program, approach… now, if, I touch the display
with one finger and then with a second finger,
and then lift the second,
then I get a specific line in the print-output assigned to that touch-up-event.

unfortunatelly, I will get the same line in the output (x and y might vary a little) when
I lift the first finger at first.

so, unfortunatelly, like this, I am still not able to assign the
first touch-up-event…. what is it that I am doing wrong ?

kind regards,  chris


Code: [Select]
Global action, idx, x, y
SetOnTouchSub onTouch()

mainloop:

wait 1

if action=1 or action=3 or action=6 then
  i=i+1
  Print str$(i)+"   "+str$(action)+"   "+str$(idx)+"   "+str$(int(x))+"   "+str$(int(y))
  action=-10
  endif

goto mainloop
'===================
Sub onTouch(action1, idx1, x1, y1)
action=action1
idx=idx1
x=x1
y=y1
End Sub

to Chris:

More like this…

Code: [Select]
SetOnTouchSub onTouch()

do
wait 500
loop

'===================
Sub onTouch(action, index, x, y)

  if action=1 or action=3 or action=6 then

  ' do something with the index. the index is really the finger index.
  ' The action and the finger index go together. They say, "this action was triggered by this finger index"
  ' I think it goes, first finger down is 0 and each finger down after are 1,2, 3, etc.

    Print str$(i)+"   "+str$(action)+"   "+str$(idx)+"   "+str$(int(x))+"   "+str$(int(y))

  endif

End Sub

Do something with the index. the index is really the finger index.
The action and the finger index go together. They say, "this action was triggered by this finger index"
I think it goes, first finger down is 0 and each finger down after are 1,2, 3, etc.

another good structure is‥


Code: [Select]
Sub onTouch(action, index, x, y)

  Select action

    Case 0
      ' do something

    Case 1
       ' do something else

    Case 2
        ' and so on

    Case else
        Print str$(i)+"   "+str$(action)+"   "+str$(idx)+"   "+str$(int(x))+"   "+str$(int(y))

  End Select

End Sub
« Last Edit: Aug 26, 2018, 11:43 PM by Mintoris »