fastread

robertspark/faster-digital-read-write/fastread

Faster read of digital signal value from board GPIO port. Possible errors: — Invalid port
fastread
@/fastread
Faster read of digital signal value from board GPIO port. Possible errors: — Invalid port
PORTport
Board port to write to
UPDpulse
Triggers new read
fastread
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);
    emitValue<output_SIG>(ctx, digitalReadFast(port));
    emitValue<output_DONE>(ctx, 1);
}