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
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);
}