beyondscreen/node-rpi-ws281x-native

[v1.x] config issue surrounding LED CHANNEL 1 bleeding;

Closed this issue · 2 comments

Configs seem volatile, and bleeds onto led channel 1. As such,

options = {
        dma: 10,
        freq: 800000,
        channels: [
            { count: 10, gpio: 18, invert: false, brightness: 255, stripType: w.stripType.WS2812 },
            { count: 256, gpio: 13, invert: false, brightness: 10, stripType: w.stripType.WS2812 }
        ],
    };

will result in channel 1 giving nothing but the first 10 pixels, and

options = {
        dma: 10,
        freq: 800000,
        channels: [
            { count: 256, gpio: 18, invert: false, brightness: 255, stripType: w.stripType.WS2812 },
            { count: 256, gpio: 13, invert: false, brightness: 10, stripType: w.stripType.WS2812 }
        ],
    };

works fine. In addition, it seems to be the lowest of the two.
In addition, this seems to happen with brightness too:

options = {
        dma: 10,
        freq: 800000,
        channels: [
            { count: 256, gpio: 18, invert: false, brightness: 0, stripType: w.stripType.WS2812 },
            { count: 256, gpio: 13, invert: false, brightness: 10, stripType: w.stripType.WS2812 }
        ],
    };

will show nothing.
I've had a look, and on the javascript side of things, the parameters are maintained. This seems to be an issue with the binding.

Thanks for the report, I never actually worked with multiple LED strips, so that is quite valuable.
But I think this is something in the upstream-library. This part of the code shouldn't be causing this:

ws2811_channel_t* channel = &ws281x.channel[channelNumber];
const int param = info[1]->Int32Value();
const int value = info[2]->Int32Value();
switch (param)
{
case PARAM_GPIONUM:
channel->gpionum = value;
break;
case PARAM_COUNT:
channel->count = value;
break;
case PARAM_INVERT:
channel->invert = value;
break;
case PARAM_BRIGHTNESS:
channel->brightness = (uint8_t)value;
break;
case PARAM_STRIP_TYPE:
channel->strip_type = value;
break;

Can you maybe try to do the same with the upstream-library (https://github.com/jgarff/rpi_ws281x) and see if that behaves any diffferent? I can't see anything obvious there either, but maybe there is a better place to solve this.

I think I found the issue, more or less by accident:

const int numBytes = std::min(
node::Buffer::Length(buffer),
sizeof(ws2811_led_t) * ws281x.channel[0].count);

I published a fix with the latest version, 1.0.0-alpha3 (49c7018).