fastread-pullup

robertspark/faster-digital-read-write/fastread-pullup

Faster read of 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
fastread-pullup
@/fastread-pullup
Faster read of 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 write to
UPDpulse
Triggers new read
fastread-pullup
PORT
UPD
SIG
DONE
DONEpulse
Fires on writing complete
SIGboolean
The last read signal value
To use the node in your project you should have the robertspark/faster-digital-read-write 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 error_raise enable
#pragma XOD require "https://github.com/robertspark/FastDigitalWrite"

{{#global}}
#include <digitalWriteFast.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

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

    const uint8_t port = getValue<input_PORT>(ctx);
    if (!isValidDigitalPort(port)) {
        raiseError<output_DONE>(ctx);
        return;
    }

    pinModeFast(port, INPUT_PULLUP);
    emitValue<output_SIG>(ctx, digitalReadFast(port));
    emitValue<output_DONE>(ctx, 1);
}