rpi-ws281x / rpi-ws281x-rust

Rust bindings to the ws821x library enabled by bindgen.
MIT License
38 stars 25 forks source link

added working SPI example / use latest bindgen version #20

Closed anzbert closed 2 years ago

anzbert commented 2 years ago

Hey ! This is my first pull request ever, so forgive me if i am doing something wrong here.

I just thought it would be a good idea to have a working example. You already had one somewhere in your source code, but the API use was outdated and did not compile. All I did was a few minor changes to make it run and light up some LEDs.

I have also increased the bindgen version, since 0.54 was relying on a really outdated clang-sys which created problems when using this library with other C-wrapped libs.

Thx :) Andreas

JMurph2015 commented 2 years ago

Hi! I'll try to merge this later today! I have been a bit offline for the holidays but am catching up on things.

anzbert commented 2 years ago

Thanks man!!!

On Thu, 9 Dec 2021, 05:17 Joseph Murphy, @.***> wrote:

Hi! I'll try to merge this later today! I have been a bit offline for the holidays but am catching up on things.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rpi-ws281x/rpi-ws281x-rust/pull/20#issuecomment-989203176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIGOFFQFAKZJFZTHOVUUCLUP7DPPANCNFSM5HASEEMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

JMurph2015 commented 2 years ago

Finally got around to bringing my dev environment for this project up to date. Looks good.

JMurph2015 commented 2 years ago

(Also my deepest apologies for the intense code review latency, my setup for doing Raspberry Pi development has been collecting a ton of dust recently so I couldn't easily test whether this broke anything or not.)

anzbert commented 2 years ago

Hey Joseph! Not to worry :) and thx for the approval. I am actually pretty new at coding and teaching myself with little hobby projects. This was my first ever pull-request and I am pretty happy it was accepted. it's a big step for me :)

All the best to you and happy new year !

Andreas

On Wed, 29 Dec 2021, 08:37 Joseph Murphy, @.***> wrote:

(Also my deepest apologies for the intense code review latency, my setup for doing Raspberry Pi development has been collecting a ton of dust recently so I couldn't easily test whether this broke anything or not.)

— Reply to this email directly, view it on GitHub https://github.com/rpi-ws281x/rpi-ws281x-rust/pull/20#issuecomment-1002338737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIGOFG6XP6G7GVC74UR3A3UTJJ6HANCNFSM5HASEEMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ayashjorden commented 1 year ago

@anzbert , I'm new to Rust, may I ask about the led color order? When I select strip_type(StripType::Ws2811Rgb on pin(10), the controller.leds_mut array element is [Blue, Green,Red, NOT_SURE]

  1. NOT_SURE - I'm not sure what this element does...
  2. Ws2811Rgb => I'd thought the array element would be [Red, Green, Blue, NOT_SURE]
  3. Is there a diff between SPI1 (GPIO18. pin 12) and SPI0 (GPIO 10, pin 19) when it comes to setting led color?

Appreciate the help/clarification. J

anzbert commented 1 year ago

hey @ayashjorden.

  1. So i didnt make this library, and i dont have access to a rpi at the moment. But i had a look in the original rpi-WS281x C library, which this library is wrapping around, and apparently it is a 'white' value. Whatever that means haha. just try setting it to 255 or 0 and see if it makes a difference to the color. i vaguely remember that i just ignored it when i used this library and i was ok :) see here

  2. Depending on LED type, the order of colors may be different, as far as i know. Again just try setting each one of the array positions to 255 with all others on 0 and just try out what color you get. Like try [255,0,0,0] and see if its red , blue or green.

  3. colors should be the same

hope that helped at all, since i basically just told you to test it yourself. 😅 good luck!

anzbert commented 1 year ago

Ah I just googled rgbw and apparently there are strips with an additional white channel. So that may not apply to your strips, in which case just set the last value to 0 and ignore it.

See here

ayashjorden commented 1 year ago

Thanks @anzbert , I figured, just wanted to see if I was using the library correctly.