I want to find...

Search

Shares

Table of Content

EthercatDevice_DmpLCD.touchX()

[EthercatDevice_DmpLCD_Generic]

Description

Read the X-axis position of the touch point on the touchscreen of the LCD module on the EtherCAT slave device. The coordinate will be rotated according to the configuration of lcdSetRotation().

Derived Class:

Class NameVendor IDProduct Code
EthercatDevice_QECR11UN010x00000bc30x0086d103
EthercatDevice_QECR00UN010x00000bc30x0086d100

Syntax

int touchX(size_t point = 0);

Parameters

  • [in] size_t point
    Touchpoint sequence number. If the device supports multi-touch, this parameter can be used to read the X-axis position of the specified touch point.
    • 0: 1st touch point.
    • 1: 2nd touch point.
    • And so on.

Return Value

Return the X-axis position of the touch point. If the return value is smaller than 0, it means an error code.

Comment

This function must be called after a successful execution of EthercatMaster::start() and before EthercatMaster::stop(). This function is non-blocking and can be called within the callback functions.

Example

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_QECR00UN01 slave;

bool Touched = false;
int TouchX;
int TouchY;

void CyclicCallback() {
  if (!Touched && slave.isTouched() > 0) {
    Touched = true;
    TouchX = slave.touchX();
    TouchY = slave.touchY();
  }
}

void setup() {
  Serial.begin(115200);

  master.begin();
  slave.attach(0, master);
  slave.lcdInit(ECAT_LCD_ILI9341_1);
  master.attachCyclicCallback(CyclicCallback);
  master.start();
}

void loop() {
  if (Touched) {
    Serial.print("Touched. X: ");
    Serial.print(TouchX);
    Serial.print(", Y: ");
    Serial.println(TouchY);
    delay(500);
    Touched = false;
  }
  // ...
}

Please see EthercatDevice_DmpLCD_Generic Class for more QEC Stepper Drivers instructions and API usage.

Scroll to Top