YP Pin (Some display's share pins with the touch Screen set this to your YP Pin to Workarround)
XMport
XM Pin (Some display's share pins with the touch Screen set this to your XM Pin to Workarround)
INITpulse
Check for Touch (just leave set to Continuously to recive touch evets on the TouchDetected pin)
TouchDetectedpulse
Pulse on Touch Detected
Pressurenumber
Pressure Applied
Ynumber
Y Location
Xnumber
X Location
To use the node in your project you should have the bradzilla84/touch-adafruit library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
struct State {
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
// The node responds only if there is an input pulse
if (!isInputDirty<input_INIT>(ctx))
return;
// Get a pointer to the class instance
auto ts = getValue<input_IN>(ctx);
// a point object holds x y and z coordinates
TSPoint p = ts->getPoint();
pinMode(getValue<input_XM>(ctx), OUTPUT); //restore shared pins
pinMode(getValue<input_YP>(ctx), OUTPUT);
digitalWrite(getValue<input_XM>(ctx), HIGH); //because TFT control pins
digitalWrite(getValue<input_YP>(ctx), HIGH);
// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing above 500 is error!
if (p.z > 0 && p.z < 500) {
emitValue<output_X>(ctx, p.x);
emitValue<output_Y>(ctx, p.y);
emitValue<output_Pressure>(ctx, p.z);
emitValue<output_TouchDetected>(ctx, 1);
}
}