Shop OBEX P1 Docs P2 Docs Learn Events
C code to work with WS2812 NeoPixel LEDs - Page 5 — Parallax Forums

C code to work with WS2812 NeoPixel LEDs

1235»

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-25 16:02
    Here you go.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-25 16:12
    NWCCTV wrote: »
    Here you go.
    Thanks. I see the problem. You're not using the ws2812 code that was in the #114 zip file. You're using the code that Parallax posted on their WS2812 product page. That code has a different API from the code that I posted. You'll have to read their documentation to understand how to use this API and modify the code that I posted in #114 accordingly. In this case, it looks like they added additional parameters to the ws2812_init function. I think what they did is remove the code I had for supporting multiple strings of LEDs per COG and replaced it with code that only handles one string at a time.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-25 16:13
    At this point my concern is more about getting some different patterns going for Green and Blue. Not real worried about the error message,
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-25 16:40
    NWCCTV wrote: »
    At this point my concern is more about getting some different patterns going for Green and Blue. Not real worried about the error message,
    I'm afraid I'm not good at coming up with interesting patterns. Sorry! Maybe JonnyMac will suggest something. He does this sort of thing for a living!
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-25 16:46
    Thanks. I was actually just thinking of using JM's driver but I need to modify it to use only Green and Blue. The code in his ws2812 demo would be the perfect pattern. I have tried modifying it but it is not working..
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-01-26 18:35
    My name is being tossed around like a volleyball -- is there something I can do to help?
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-26 18:43
    JonnyMac wrote: »
    My name is being tossed around like a volleyball -- is there something I can do to help?
    It's tough being a wizard! :-)
  • Keith YoungKeith Young Posts: 569
    edited 2015-06-02 20:26
    I am not getting dimming to work. I am using the code from Parallax's WS2812 product page https://www.parallax.com/downloads/ws2812b-rgb-led-module-propeller-c-code. Do I need a different library? I'm trying to use _wheel_dim, however the only way to set the colors seems to be _set.

    ws2812_set(driver, LED_PIN, ws2812_wheel_dim(pos,dim), LED_COUNT);

    Hope to have all my stuff in C in time for Mini Maker Faire Ann Arbor this Saturday so I don't have to do so much shuffling. These events get pretty busy.

    Thanks!
  • kuronekokuroneko Posts: 3,623
    edited 2015-06-03 03:57
    I am not getting dimming to work. I am using the code from Parallax's WS2812 product page https://www.parallax.com/downloads/ws2812b-rgb-led-module-propeller-c-code. Do I need a different library? I'm trying to use _wheel_dim, however the only way to set the colors seems to be _set.

    Not sure what you're expecting here. ws2812_wheel_dim() is a passive function, i.e. it just returns an RGB colour value. Said value goes into the colour array (your job) which is then passed to ws2812_set().
  • Keith YoungKeith Young Posts: 569
    edited 2015-06-03 06:34
    Yep, that's what I'm trying and it won't change the brightness. So I don't know if there are other commands in other libraries like _setx or something where brightness will work.

    So there are some possibilities. A) I'm doing it wrong B) _wheel_dim isn't doing brightness correct C) _set can't set brightness D) ?

    ws2812_set(driver, LED_PIN, ws2812_wheel_dim(pos,dim), LED_COUNT); //This is what I'm doing with pos and dim as integers between 0 and 255.
  • kuronekokuroneko Posts: 3,623
    edited 2015-06-03 06:49
    I vote A. ws2812_set() expects a colour array as the 3rd argument but you're passing a colour value instead. If you look at ws2812_Demo.c's alternate() function, inside the loop you see the colour array being initialised. This is where you'd apply your dim function, e.g.
    ledColors[0] = ws2812_wheel_dim(pos,dim);
    ...
    
    And I just realised that you posted the call in a previous post. Apologies for not picking up on it earlier.
  • Keith YoungKeith Young Posts: 569
    edited 2015-06-04 19:53
    That did it. Thanks kuroneko!
Sign In or Register to comment.