smart-leds-rs / smart-leds

The end user crate for smart leds (like ws2812)
Apache License 2.0
92 stars 13 forks source link

HSV to RGB conversion as a trait #11

Closed nils-van-zuijlen closed 10 months ago

nils-van-zuijlen commented 5 years ago

Why is the hsv to rgb conversion handled by the hsv2rgb function and not by an implementation of the Into<RGB8> trait ?

It would mean that we can use it directly in write function of SmartLedsWrite, which would be really useful.

https://github.com/smart-leds-rs/smart-leds-trait/blob/2a082914382fc63e07681c8df28c13fc4dd72f21/src/lib.rs#L13

david-sawatzke commented 5 years ago

I think the reason was that it really isn't advisable to do the conversion in the write function, except for very fast microcontrollers. In most (i think all) implementations the iterator has to yield in under 1 μs, especially to conform to the datasheet, so doing it just in time is usually way to slow. Having it separate encourages doing the transformation beforehand.

nils-van-zuijlen commented 5 years ago

Thank you, sounds sensible.

Could it be explained in the documentation or README then ?