digital-pullup-input

escape-ford/encoder-ky040/digital-pullup-input

Standard digital input node with pullup modification
digital-pullup-input
@/digital-pullup-input
Standard digital input node with pullup modification
PORTnumber
Board GPIO port number to read from
UPDpulse
Triggers new read
digital-pullup-input
PORT
UPD
SIG
SIGboolean
The last read signal value
To use the node in your project you should have the escape-ford/encoder-ky040 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 {
    int configuredPort = -1;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_UPD>(ctx))
        return;

    State* state = getState(ctx);
    const int port = (int)getValue<input_PORT>(ctx);
    if (port != state->configuredPort) {
        ::pinMode(port, INPUT_PULLUP);
        // Store configured port so to avoid repeating `pinMode` on
        // subsequent requests
        state->configuredPort = port;
    }

    emitValue<output_SIG>(ctx, ::digitalRead(port));
}