tft-touchscreen-device

ivanmason/tft-lcd-touch/tft-touchscreen-device

No description
tft-touchscreen-device
@/tft-touchscreen-device
YPport
XMport
YMport
XPport
tft-touchscreen-device
DEV
DONE
YP
XM
YM
XP
DONEpulse
DEV@/tft-touchscreen-device
To use the node in your project you should have the ivanmason/tft-lcd-touch 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

#pragma XOD require "https://github.com/adafruit/Adafruit_TouchScreen"

// Include C++ library:
{{#global}}
#include <TouchScreen.h>
{{/global}}

//#define YP A3  // must be an analog pin, use "An" notation! 
//#define XM A2  // must be an analog pin, use "An" notation! 
//#define YM 9   // can be a digital pin 
//#define XP 8   // can be a digital pin 

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);
    auto YP = getValue<input_YP>(ctx);
    auto XM = getValue<input_XM>(ctx);
    auto YM = getValue<input_YM>(ctx);
    auto XP = getValue<input_XP>(ctx);
    
    // Create a new object in the memory area reserved previously.
    Type ts = new (state->mem) TouchScreen(XP, YP, XM, YM, 300);
    
    emitValue<output_DEV>(ctx, ts);
    emitValue<output_DONE>(ctx, 1);
}