ir-read

gweimer/ir-remote/ir-read

Read IR remote. Return -1 if no data found, else return data.
ir-read
@/ir-read
Read IR remote. Return -1 if no data found, else return data.
PORTport
UPDpulse
ir-read
OUT
PORT
UPD
OUTnumber
To use the node in your project you should have the gweimer/ir-remote 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 require "https://github.com/z3t0/Arduino-IRremote"

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

struct State {
    int configuredPort = -1;
    IRrecv* irrecv;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    State* state = getState(ctx);
    auto port = getValue<input_PORT>(ctx);
    auto irrecv = state->irrecv;
    if (state->configuredPort != port) {
        state->irrecv = irrecv = new IRrecv(port);
        irrecv->enableIRIn(); // Start the receiver
        state->configuredPort = port;
    }
    if (isInputDirty<input_UPD>(ctx)) {
        long int out = 0;
        decode_results results;         //cache of decode of IR remoter control
        if (irrecv->decode(&results)) {
            out = results.value;
            irrecv->resume();
        }
        emitValue<output_OUT>(ctx, out);
    }
}