Romonaga / Ws2811Wrapper

Wrapper for https://github.com/jgarff/rpi_ws281x
3 stars 0 forks source link

Help needed #2

Closed gbkwiatt closed 3 years ago

gbkwiatt commented 3 years ago

Hi,

I am basically trying to do, what you did. but on a smaller scale.

So I have class and constructor.

When in my constructor as a test I was doing :

ws2811_channel_t ledstring = {
        .gpionum = LED_PIN,
        .invert = LED_INVERT,
        .count = LED_COUNT,
        .brightness = LED_BRIGHTNESS,
    };
    ws2811_t initString = {
        .freq = LED_FREQ_HZ,
        .dmanum = LED_DMA,
        ledstring,
    };
ws2811_init(&initString )
//Some LEd changing 
ws2811_render(&initString )

And that was working just fine, I could change Led colors etc.

But then I wanted to make it nice and like in private properties etc. so I moved initString to private in my class, and changed constructor to:

struct ws2811_t{
    uint64_t render_wait_time;                   //< time in µs before the next render can run
    struct ws2811_device *device;                //< Private data for driver use
    const rpi_hw_t *rpi_hw;                      //< RPI Hardware Information
    uint32_t freq;                               //< Required output frequency
    int dmanum;                                  //< DMA number _not_ already in use
    ws2811_channel_t channel[RPI_PWM_CHANNELS];
};

ws2811_channel_t ledstring;

ledstring.gpionum = LED_PIN;
ledstring.invert = LED_INVERT;
ledstring.count = LED_COUNT;
ledstring.brightness = LED_BRIGHTNESS;

ws2811_t initString;

initString.freq = LED_FREQ_HZ;
initString.dmanum = LED_DMA;
initString.channel[LED_CHANNEL] = ledstring;

ws2811_init(&initString )
//Some LEd changing 
ws2811_render(&initString )

So init works, I gues success, but render hands and whole thing freezes. I did some messing around and if I define gamma then I get error in ws2811_render function.

I just can't figure it out, I belive it's some init issue when it's in private property. When I try to print initString.channel[0].birghtness it does not give me my 255 value but I believe some bit or buffer ?

It's something I do with init,

        ws2811_channel_t channel;
    channel.gpionum = LED_PIN;
    channel.invert = LED_INVERT;
    channel.count = TOTAL_NUM_LEDS;
    channel.strip_type = WS2811_STRIP_RGB;
    channel.leds = nullptr;
    channel.brightness = 255;
    channel.gamma = nullptr;

    ws2811_t test = {
        .freq = LED_FREQ_HZ,
        .dmanum = LED_DMA,
        channel,
    };

that works as well something to do with channel assignment :/