kled(sig)

koadrobot/devices/kled(sig)

No description
kled(sig)
@/kled(sig)
PORTport
Board port number the LED is connected to. The port should be capable of generating PWM signal. Digital Port is On if Lum > 0.
STATEboolean
State to write
PULLboolean
Hardware connection. pulldown (true) - High, pullup (false) - Low (1-duty).
UPDpulse
Triggers new write
kled(sig)
PORT
STATE
PULL
UPD
DONE
ERR
ERRpulse
Fires if write failed. E.g. `PORT` does not exist.
DONEpulse
Fires on writing complete
To use the node in your project you should have the koadrobot/devices 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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx)
{
    if (isInputDirty<input_UPD>(ctx))
    {
        const uint8_t port = getValue<input_PORT>(ctx);

        if (isValidDigitalPort(port))
        {
            ::pinMode(port, OUTPUT);

            bool val = getValue<input_STATE>(ctx);

            if (getValue<input_PULL>(ctx))
                ::digitalWrite(port, val);
            else
                ::digitalWrite(port, !val);

            emitValue<output_DONE>(ctx, 1);
        }
        else
            emitValue<output_ERR>(ctx, 1);
    }
}