Announcement

Collapse
No announcement yet.

Object coordinates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Object coordinates

    Is there a command that I can find out the x - y coordinates of an object (button) in an image?

    Lets say I have a list of 6 buttons in the *.dat file:

    Winbutton1
    Winbutton2
    Winbutton3
    Winbutton4
    Winbutton5
    Winbutton6

    and I want to know the coordinates for Winbutton3 (index 2)?

    That way I can tie it to a touch region for detection.

  • #2


    Not sure on what you asked but there is an img_Touched command that may do what you are trying to do

    Karl

    Comment


    • #3


      Why yes I think that may work. Thanks.

      Comment


      • #4


        I'm trying to get this to work.

        I have 6 items on Form 0. The first item (0) is a static text. The remaining 5 are buttons.

        I mounted the disk.
        I implemented Load_Image_Control and retrieved the handle value from it.

        The 6 objects display fine on the screen and now I want to know when buttons 1 through 5 are touched.

        So I do a repeat loop like this:

        repeat
        repeat idx from 1 to 5
        img_tchd := Img_Touched(hndl, idx)

        I am looking at the response using a logic analyzer and all I ever see is a response of $06 $FF $FF as it cycles through the index of 1 to 5 which indicates there isn't any of the objects being touched even though I am touching them or even holding my finger on them..

        Is there something else that I need to implement in order to enable touch of the objects?

        What am I missing?

        Comment


        • #5


          Have you turned touch on?

          Have a look at the bigdemo sample to see how it does it.

          You can also do img_Touched(hndl, ALL) which will give you the image that is touched, or -1 if nothing is touched
          Mark

          Comment


          • #6


            What's the command for turning touch on?

            Comment


            • #7


              touch_Set(TOUCH_ENABLE);

              Comment


              • #8


                Thanks.

                Comment


                • #9


                  Ok I enabled touch- touch_set($0) but I still don't get any response.

                  I tried touch_get($0) and I see the various responses for press, release and moving no matter where I touch on the screen.

                  So let me start over here.

                  I created a form using Visi. I put 6 objects on the screen, compiled and saved to the sd card.

                  I then uploaded Serial SPE to the display.

                  I send the serial commands successfully to display the images and enabled touch but I get no response.

                  Question: When I placed the buttons on the display using Visi was there any setting I needed to use so that these buttons can be used as touch buttons? I was assuming that just using the handle / index of the buttons was enough to find them.

                  Comment


                  • #10


                    ESPsupport wrote:
                    Have a look at the bigdemo sample to see how it does it.
                    Where do I find the code listing for this?

                    Comment


                    • #11


                      samples are in documents / 4d

                      Not sure what you mean 'I tried touch_get($0) and I see the various responses for press, release and moving'

                      if you get them you should then read the x and y

                      Comment


                      • #12

                        Here is my list of commands that I am sending in order:

                        File_Mount <<<<< This mounts the usd card.

                        handle := \Load_Image_Control(string("DONFILE1.dat"), string("DONFILE1.gci"), 1) <<<<< I send this to get the "handle" value.

                        Touch_Set(0x000) <<<<< I send this to enable touch.

                        repeat idx from 0 to 5 <<<<< This loop displays the 6 objects on the screen.
                        Set_Image_Parameters(hndl, $0000, $0009, idx)
                        Show_Image(handle, idx)

                        So far this part is working. The images display ok and I get a "handle" value (otherwise the images wouldn't display).

                        Here is where I can't get any further:

                        repeat
                        img_tchd := \disp.Img_Touched(hndl, -1) <<<<< Look for any of the images to be touched and get image number (img_tchd).
                        if (img_tchd &amp; $FFFF) <> $FFFF <<<<< Print image number if other than not touched
                        print(img_tchd)

                        All I ever see on the logic analyzer is 0x06FFFF no matter whether I'm touching or not. I never see anything printed because the word response is always 0xFFFF.

                        This is a simplistic scheme of my code without being more specific.

                        So what am I missing?

                        I can define touch "regions" and check to see whether they are touched or not and get that to work using the x y commands etc. but I was under the assumption that by using predefined images in a dat file I wouldn't have to do that. The reason I would like to do it this way is because I develop the screens in Visi and it saves the images and dat file to the sd card. So I should be able to then index those images.

                        In the Serial Environment manual on page 152 of the latest manual it describes Image Touched and it looks to me as being as simple as putting it in a repeat loop and testing for a certain value. It's supposed to return the "image index" if successful but I can't seem to get it to do that.

                        Comment


                        • #13
                          Sorry, you are enabling touch

                          The Bigdemo examples are in various languages starting at C:\Users\Public\Documents\4D Labs\Picaso Serial
                          The relevant part of the C sample is

                          touch_Set(TOUCH_ENABLE) ;
                          printf("Please Touch an Image\n") ;
                          i = -1 ;
                          do
                          {
                          j = touch_Get(TOUCH_STATUS) ;
                          if (j == TOUCH_PRESSED)
                          i = img_Touched(handle, ALL) ;
                          } while (i == -1) ;
                          printf("You touched Image Index %d\n", i) ;
                          It is a bit simplistic, but the imp[ortant bit is to get the status, as img_Touched() uses the values 'locked in' by the status command to determine what has been touched.
                          Mark

                          Comment


                          • #14

                            Using the C sample above as a guideline here is what I have modified my code to do with still no satisfactory results.

                            Touch_Set(0x0000) <<< Turns on Touch controller

                            repeat

                            if (Touch_Get($0000) &amp; $FF) == $01 <<<< If display was touched
                            display("Display touched !") <<<< Show that display was touched
                            img_tchd := \disp.Img_Touched(hndl, -1) <<<< assign the returned value from Image_Touched to img_tchd
                            display(img_tchd) <<<< display image touched index

                            Still get nothing other than "Display touched !" message and 0xFFFF returned from Image_Touched when display is touched.

                            Comment


                            • #15


                              This is driving me nuts....

                              Here's my dat file from the sd card:

                              "Statictext1" 0000 0000 80 1C
                              "Winbutton1" 3E00 0000 18 70
                              "Winbutton2" 8000 0000 18 B8
                              "Winbutton3" C200 0000 BC 70
                              "Winbutton4" 0400 0001 150 B8
                              "Winbutton5" 4600 0001 BC B8

                              So is the following logic correct?

                              1. Mount the sd card.
                              2. Load Image control using the dat and gci files from sd card. The value returned from this command will be the "handle".
                              3. Show all the objects on the display using the "handle" from step 2 and indexing from 0 to 5 from dat list above in show_image.
                              4. Enable touch controller using touch_set(0x0000)
                              5. Now do a repeat loop waiting for any touch using touch_get(0x0000)
                              6. If step 5 above = 0x01 then get the image index by using img_touched(handle, -1). Note: I use -1 as indicated in manual to enable all objects in image
                              7. If the display was touched AND if it was an object (image) that was touched then I should get the image index number correct?

                              Comment

                              Working...
                              X