Giter Site home page Giter Site logo

smart-leds-trait's People

Contributors

cyril-marpaud avatar david-sawatzke avatar finomnis avatar no111u3 avatar sajattack avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

smart-leds-trait's Issues

Documentation hint about color space incorrect

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:

  • Reword the documentation
  • Implement From<palette::LinSrgb<u8>> for RGB8, and similar for the other types.
    Edit: I realized that the color types are only re-imported, so From cannot be implemented for them.

Support 16bit color per channel

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>;
}

Idea: use the RGB8 type from the rgb crate

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.