hc595(one-uinit)

samele1222/ship-data/hc595(one-uinit)

No description
hc595(one-uinit)
@/hc595(one-uinit)
ENboolean
CLOCKport
DATAport
TRIGport
INbyte
hc595(one-uinit)
OUT
IN
EN
CLOCK
DATA
TRIG
OUTboolean
To use the node in your project you should have the samele1222/ship-data 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(!getValue<input_EN>(ctx))
        return;

    auto Value = getValue<input_IN>(ctx);

    auto Clock = getValue<input_CLOCK>(ctx);
    auto Data = getValue<input_DATA>(ctx);
    auto Trig = getValue<input_TRIG>(ctx);

    uint8_t i;
    uint32_t t1,tim;
    uint32_t timer = 1000000;

    ::pinMode(Clock, OUTPUT);
    ::pinMode(Data, OUTPUT);
    ::pinMode(Trig, OUTPUT);

    ::digitalWrite(Clock, 0);
    ::digitalWrite(Trig, 0);
    for(tim=timer;tim>0;tim--)t1 = tim;
    for(i=0x80;i>0;i=i/2){
        ::digitalWrite(Data, !(Value&i)? 0 : 1);
        ::digitalWrite(Clock, 1);
        for(tim=timer;tim>0;tim--)t1 = tim;
        ::digitalWrite(Clock, 0);
        for(tim=timer;tim>0;tim--)t1 = tim;
    }
    ::digitalWrite(Trig, 1);
    for(tim=timer;tim>0;tim--)t1 = tim;
    ::digitalWrite(Trig, 0);
    for(tim=timer;tim>0;tim--)t1 = tim;

    emitValue<output_OUT>(ctx, true);
}