touch-device

bradzilla84/touch-adafruit/touch-device

Touch Device. These are the pins for some typical shields! S6D0154: YP=A1, XM=A2, YM=7, XP=6 ST7783 : YP=A2, XM=A1, YM=6, XP=7 ILI9320: YP=A2, XM=A3, YM=8, XP=9 ILI9325: YP=A1, XM=A2, YM=7, XP=6 ILI9325BG: YP=A2, XM=A1, YM=6, XP=7 ILI9341: YP=A2, XM=A1, YM=7, XP=6 ILI9488: YP=A1, XM=A2, YM=7, XP=6 R65109V: YP=A2, XM=A1, YM=6, XP=7
touch-device
@/touch-device
Touch Device. These are the pins for some typical shields! S6D0154: YP=A1, XM=A2, YM=7, XP=6 ST7783 : YP=A2, XM=A1, YM=6, XP=7 ILI9320: YP=A2, XM=A3, YM=8, XP=9 ILI9325: YP=A1, XM=A2, YM=7, XP=6 ILI9325BG: YP=A2, XM=A1, YM=6, XP=7 ILI9341: YP=A2, XM=A1, YM=7, XP=6 ILI9488: YP=A1, XM=A2, YM=7, XP=6 R65109V: YP=A2, XM=A1, YM=6, XP=7
YPport
YP Pin
XMport
XM Pin
YMport
YM Pin
XPport
XP Pin
ResistanceValuenumber
For better pressure precision, we need to know the resistance between X+ and X- Use any multimeter to read it For the one i am using, its 300 ohms across the X plate
touch-device
DEV
YP
XM
YM
XP
ResistanceValue
DEV@/touch-device
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

// Tell XOD where it could download the library:
#pragma XOD require "https://github.com/adafruit/Adafruit_TouchScreen"

{{#global}}
#include <stdint.h>
#include "TouchScreen.h"
{{/global}}

struct State {
    uint8_t mem[sizeof(TouchScreen)];
};

using Type = TouchScreen*;

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // It should be evaluated only once on the first (setup) transaction
    if (!isSettingUp())
        return;

    auto state = getState(ctx);
    // Create a new object in the memory area reserved previously.
    Type ts = new (state->mem) TouchScreen(getValue<input_XP>(ctx), getValue<input_YP>(ctx), getValue<input_XM>(ctx), getValue<input_YM>(ctx), getValue<input_ResistanceValue>(ctx));
    emitValue<output_DEV>(ctx, ts);
}