ir-receive

dinosalvioni/irremote/ir-receive

No description
ir-receive
@/ir-receive
PORTnumber
UPDpulse
ir-receive
CODE
Type
Bits
Rawbuf
Rawlen
REC
ERR
PORT
UPD
ERRpulse
RECpulse
Rawlennumber
Rawbufnumber
Bitsnumber
Typenumber
CODEnumber
To use the node in your project you should have the dinosalvioni/irremote 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)) {
        decode_results results; //cache of decode of IR remoter control

        if (irrecv->decode(&results)) {

            if (results.decode_type == UNKNOWN) {
                emitValue<output_ERR>(ctx, 1);
            } else if (results.bits > 0)  {
                emitValue<output_CODE>(ctx, results.value);
                emitValue<output_Type>(ctx, results.decode_type);
                emitValue<output_Bits>(ctx, results.bits);
                // volatile unsigned int rawbuf = results.rawbuf;
                //emitValue<output_Rawbuf>(ctx, rawbuf);
                emitValue<output_Rawlen>(ctx, results.rawlen);
                emitValue<output_REC>(ctx, 1);
                
                
            }
        irrecv->resume();   
        }
     
     //delay(500);
     }


}