No announcement yet.

Serial Touch Detection

  • Filter
  • Time
  • Show
Clear All
new posts

  • Serial Touch Detection

    Hi all;

    Having worked though the serial graphic and text commands, I am now looking at the Touch Screen.

    I understand the 3 commands which are used with the touch screen, however I am a bit confused as to how to implement it with a microcontroller.

    Also the Get Touch Coordinates is a bit confusing, it has Wait For... modes, does this mean that if you send this command it will not reply with anything until a touch is detected ?? - will it never timeout ?

    Is this the typical method of implementation:

    1) Enable TS
    2) Define Area if required
    3) Send Wait Until Touch
    4) Wait for ACK (when the screen is touched or timeout)
    5) Send Get Touch Coordinates
    6) Do something with coordinates.

    This would mean that the micro would either need to be frozen waiting for the ACK to happen, or it would need to be able to read the ack using an interrupt routine.

    Or do you instead need to execute the Get Touch Coordinates command twice, once for the Wait for Touch (mode 0-3) and a second time to get the coordinates (4 & 5) after the touch ??

    I'm sure that this is clear to everyone else, guess I'm just not very bright :-)

  • #2

    The 'wait' type touch commands are just for 'simplistic' usage.

    For any real usage you should use the 'get status' command and implement using that.


    • #3

      Thanks, but what I am trying to determine is how do I detect a press ??

      Here's what I am doing now:

      1) Enable Touch - Send 59 05 00
      2) Wait Any Touch - Send 6F 00

      So after sending the Wait Any Touch Command, I now assume that when I touch the screen, it will send an .

      So I then touch the screen and nothing at all happens, I was expecting to get the that was not previously received after sending Wait Any Touch, so that I know that a touch event has occurred.

      But nothing at all

      Hope I've explained clearer ??


      • #4

        If, as I think, you are doing this in FAT Controller, then you need to understand that FAT Controller times out and stops waiting for a response.

        This means you have to do the touch within that time to see the ACK, otherwise it will be lost.


        • #5

          Thanks, yes I was using the FATController, now by using a serial terminal I can detect the touch with the Wait For Command using a Microcontroller or serial terminal.

          So I have created a script file which I have saved onto the SD Card as T1.4DS.

          When I execute the script from a Serial Terminal using the @p Execute Program, the script executes and waits for the touch and then quits, but nothing is sent back to the Serial Port.

          1) The device is then hung and is un-responsive to any commands and requires a power down and power up again, why is that ??

          2) I have searched the command reference, but cannot find any command to transmit data to the serial port using the scripts, so how can I send the touch coordinates back to the host from the script file ??

          3) How do I configure the 4D Workshop to save it's compiled file as a .4ds file rather than .4dScrpObj File ??

          === T1.4DS ====
          #include ""
          Control(5,0) // turn on touch
          String(0,1,xlarge,lightblue,'Wait For Touch...')
          GetTouch(0) // wait until any touch activity
          GetTouch(4) // get the status (and clear for next activity)


          • #6

            1) You need to put an exit command at the end, at least I think that's what's missing
            2) how to do that is described in the forum somewhere, have a search and see if you can find it.
            3) Um, maybe using the #origin statement

            Sorry gotta run, yell if you can't work out all the answers from that