write(digital-bits)

koadrobot/ports/write(digital-bits)

Write Bits from Start to Stop Index of Bits. Stop Index must be greater than start and between (0..7).
write(digital-bits)
@/write(digital-bits)
Write Bits from Start to Stop Index of Bits. Stop Index must be greater than start and between (0..7).
PORTport
Board port to write to. If the port supports hardware PWM, it will be used by analogWrite. If not, it will be set high for values greater than 0.0 and set low otherwise and used by digitalWrite.
BITSbyte
Write bit states of BITS (0000000b) on digital Port.
STARTbyte
Start Index of Bits that are written. (0..7)
STOPbyte
Stop Index of Bits that are written. (0..7).
PULLboolean
Hardware connection. pulldown (true) - High, pullup (false) - Low (1-duty).
UPDpulse
Triggers new write
write(digital-bits)
PORT
BITS
START
STOP
PULL
UPD
DONE
ERR
ERRpulse
Fires on Error. Start, stop must be between 0..7 and stop>start.
DONEpulse
Fires on writing complete
To use the node in your project you should have the koadrobot/ports 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))
        {
            uint8_t bits = getValue<input_BITS>(ctx);
            uint8_t start = getValue<input_START>(ctx);
            uint8_t stop = getValue<input_STOP>(ctx);

            ::pinMode(port, OUTPUT);
            bool val;

            if (start<8 && stop<8 && stop>=start)
            {
                for(uint8_t i=start; i<=stop; i++)
                {
                    val = 1 & (bits >> i));
                    if (getValue<input_PULL>(ctx))
                        ::digitalWrite(port, val);
                    else
                        ::digitalWrite(port, !val);
                }
                emitValue<output_DONE>(ctx, 1);
            }
            else
                emitValue<output_ERR>(ctx, 1);
        }
        else
           emitValue<output_ERR>(ctx, 1);
    }
}