smart-leds-rs / smart-leds-trait Goto Github PK
View Code? Open in Web Editor NEWA trait for implementing effects, modifiers and drivers for programmable leds
License: Apache License 2.0
A trait for implementing effects, modifiers and drivers for programmable leds
License: Apache License 2.0
Quote from the documentation of RGB8
:
The colorspace is techincally undefined, but generally sRGB is assumed.
This is incorrect. Most LED strips use Linear sRGB, not normal, gamma corrected sRGB color space.
More detail about the difference can be found here: https://matt77hias.github.io/blog/2018/07/01/linear-gamma-and-sRGB-color-spaces.html
My experience is that LED strips try to be as close as possible to the linear brightness scale, some even use high-speed PWM to achieve that. (like the sk6805/sk6812)
Therefore I propose two things:
From<palette::LinSrgb<u8>>
for RGB8
, and similar for the other types.From
cannot be implemented for them.Some LED strips (like APA102 with global brightness bits) can achieve greater than 8-bit per color channel resolution under certain conditions. Similarly LEDs driven using 12-bit or 16-bit pwm (either via peripherals or an external PWM chip) would also be nice to support.
For context I'm working on a crate that implements the interpolation, gamma correction and temporal dithering techniques from fadecandy. It supports writing into the internal state using the SmartLedsWrite
trait and itself writes to the underlying LEDs via the same. I have a few custom LED spotlights that use 16-bit pwm and would like to re-use the interpolation and gamma correction to take advantage of the 16-bit pwm during fades while still only having to provide 8-bit per channel input.
It seems like either a new 16-bit specific trait could be defined or now that this is using the rgb crate a generic trait over RGB
could be defined. e.g.
pub use rgb::RGB;
pub type Color = rgb::RGB8;
pub type Color16 = rgb::RGB16;
pub trait SmartLedsWrite<RGB> {
type Error;
fn write<T>(&mut self, iterator: T) -> Result<(), Self::Error>
where
T: Iterator<Item = RGB>;
}
The rgb
crate provides a RGB8
type alias which corresponds to this crate's Color
struct. Given the fact that some programs might have the RGB8
in use already, I think it makes sense to use it here as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.