digital-read-pullup

xod/gpio/digital-read-pullup

Reads a digital signal value from a board GPIO port with the internal built-in pull-up resistor enabled. It forces the resulting signal to be True if the wire on the port floats (is disconnected). Possible errors: — Invalid port
digital-read-pullup
@/digital-read-pullup
Reads a digital signal value from a board GPIO port with the internal built-in pull-up resistor enabled. It forces the resulting signal to be True if the wire on the port floats (is disconnected). Possible errors: — Invalid port
PORTport
Board port to read from
UPDpulse
Triggers new read
digital-read-pullup
PORT
UPD
SIG
DONE
DONEpulse
Fires on reading complete
SIGboolean
The last read signal value

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {
        static_assert(isValidDigitalPort(constant_input_PORT), "must be a valid digital port");

        if (!isInputDirty<input_UPD>(ctx))
            return;

        ::pinMode(constant_input_PORT, INPUT_PULLUP);
        emitValue<output_SIG>(ctx, ::digitalRead(constant_input_PORT));
        emitValue<output_DONE>(ctx, 1);
    }
}