k74hc595(shiftout)

koadrobot/devices/k74hc595(shiftout)

No description
k74hc595(shiftout)
@/k74hc595(shiftout)
CLKport
CLOCK(Pin 11 on the chip)
DSport
DATA SERIAL (Pin 14 on the chip)
PINSbyte
State of Output Pins of the hc595 is high.
UPDpulse
Triggers new write
k74hc595(shiftout)
DONE
ERR
CLK
DS
PINS
UPD
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 ds = getValue<input_DS>(ctx);

        const uint8_t clk = getValue<input_CLK>(ctx);

        if (isValidDigitalPort(ds) && isValidDigitalPort(clk))
        {
            uint8_t bits = getValue<input_BITS>(ctx);

            ::pinMode(ds, OUTPUT);
            ::pinMode(clk, OUTPUT);

            ::digitalWrite(clk, 0);
            for(uint8_t i=0; i<8; i++){
                ::digitalWrite(ds, 1 & (bits >> i));
            }
            ::digitalWrite(clk, 1);

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