ir-remote

czadohubert/ir-remote/ir-remote

No description
ir-remote
@/ir-remote
PORTport
UPDpulse
ir-remote
OUT
PORT
UPD
OUTnumber
To use the node in your project you should have the czadohubert/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);
    }
}