General Arduino

how to get DFR0669 single click coordinates

userHead Sami.Kankaanpää 2024-08-27 00:28:33 48 Views1 Replies

I am using Arduino MEGA2560 and DFR0669 touch screen.

I have studied every example in the library but with my poor programming skills I have not found a way to get the X and Y coordinates of a single click gesture. Or any other means of reading the coordinates with the Touch library.

Should I use the UI or the Touch?

I have found out how to recognize an SCLICK gesture with the UI library but I haven't found any way to get the coordinates.

Could anyone please help me with an example line on this matter?

 

void loop()

{

    //getGestures():Recognize gestures

    DFRobot_UI:: eGesture_t gesture = ui.getGestures();

   switch (gesture) {

  //single click

    case ui.SCLICK : {

      // here I need to find a code to read the coordinates

      } break;

    case ui.NONE: {

      return;

      }

  }

}

2024-09-09 10:40:55

In the sample code for DFR0669, the touch function is handled by DFRobot_Touch_GT911, which inherits from the DFRobot_Touch class.

While in the DFRobot_Touch class, the sPoints_t structure hastwo member variables x,y. It should be the coordinates you need to find.
This structure is in public and you can access it from outside of the DFRobot_Touch. Inside this class, sPoints_t instantiates _point, which means you can try to call this structure from the touch in the .ino program.

 

 

I added the following two lines to .ino and it compiles fine, which proves my point. However, I don't have DFR0669 in hand to test it, and also, you need to put these two lines into loop()

 

int x = touch._point.x;

int y = touch._point.y;

 

userHeadPic Yeez_B