fill-solid

xod-dev/ws2812/fill-solid

Sets the color of pixels in the device to the same value.
fill-solid
@/fill-solid
Sets the color of pixels in the device to the same value.
DEV@/ws2812-device
The device
Cxod/color/color
The color
NUMnumber
Number of LEDs to fill up with the solid color. Set `Inf` to fill all LEDs. Set to a negative value to fill from the tail.
DOpulse
Trigger to fill pixels of the device
fill-solid
DEV
C
NUM
DO
DEV'
DONE
DONEpulse
Fires when the fill is done
DEV'@/ws2812-device
The device
To use the node in your project you should have the xod-dev/ws2812 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

node {
    void evaluate(Context ctx) {
        auto dev = getValue<input_DEV>(ctx);
        if (isInputDirty<input_DO>(ctx)) {
            auto color = getValue<input_C>(ctx);
            auto num = getValue<input_NUM>(ctx);
            if (isinf(num)) {
                // Fill all the LEDs
                dev->fill(color);
            } else {
                // Fill only specified number of LEDs
                bool fromTail = num < 0;
                uint32_t pixelsCount = (uint32_t) abs(num);
                dev->fill(color, pixelsCount, fromTail);
            }

            emitValue<output_DONE>(ctx, 1);
        }
        emitValue<output_DEVU0027>(ctx, dev);
    }
}