4 ms·
Thanks for sharing. One question about the code, why does the LedPanel struct use a String as a buffer rather than using a Vec<u8>? edit - I think I see the r
by JoshMcguigan 7y ago
Thanks for sharing.
One question about the code, why does the LedPanel struct use a String as a buffer rather than using a Vec<u8>?
edit - I think I see the reason now. Using a string made it easy to print the u8 as a string of bits, which you could then iterate over using chars. This was used to help perform the conversion from bits directly representing colors to the on the wire representation.
- slicedbrandy 7y agoThat would certainly work as well, and ultimately it does get converted into a Vec<u8>. I did consider just having the buffer as it from the start, but by using a String it was just a little more intuitive when it came to pushing more bits onto the buffer, as well as doing the padding operation at the end. More just to reduce complexity during development than anything I guess.
- JoshMcguigan 7y agoI may have overlooked some things, but I made a quick PR[0] just to see what this would look like using a Vec<u8>. Feel free to close if you prefer the original. [0]: https://github.com/tomarrell/rasp-ws2812b/pull/2 https://github.com/tomarrell/rasp-ws2812b/pull/2