tftbuttonpress

ivanmason/tft-lcd-touch/tftbuttonpress

Has A Button Been Pressed
tftbuttonpress
@/tftbuttonpress
Has A Button Been Pressed
DEV@/tftbutton-device
XINnumber
YINnumber
UPDpulse
tftbuttonpress
DEV
XIN
YIN
UPD
DONE
PRESS
XOUT
YOUT
YOUTnumber
XOUTnumber
PRESSboolean
DONEpulse
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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
     if (!isInputDirty<input_UPD>(ctx))
        return;
    
    auto button = getValue<input_DEV>(ctx);
    int16_t xin = getValue<input_XIN>(ctx);
    int16_t yin = getValue<input_YIN>(ctx);
    
    if (button->contains(xin, yin)) { 
            button->press(true);  // tell the button it is pressed
            
    } else { 
            button->press(false);  // tell the button it is NOT pressed
            
            
    }

    if (button->justPressed()) { 
        button->drawButton(true);  // draw invert! 
        emitValue<output_PRESS>(ctx, 1);
    }

    if (button->justReleased()) { 
        button->drawButton();  // draw normal 
        emitValue<output_PRESS>(ctx, 0);
    }
    
    emitValue<output_XOUT>(ctx, xin);
    emitValue<output_YOUT>(ctx, yin);
    emitValue<output_DONE>(ctx, 1);
}