Kch RGBW Lib
RGB/RGBW LED class library in typescript. It provides following classes and functions,
- Composite LED class
RGBWLEDfor multi-color LED. In addition to R-G-B (3 LEDs), R-G-B-W (4 LEDs), it can have unlimited many number of component LEDs.
- Mathematically clear solution for many-LED problem.
- Conversions between
- Composite color <=> Each component LEDs mix ratio (e.g. PWM).
- RGB, HSV and CIE 1931 Chromaticity (XYZ, xy+Y) colorspace
- Color temperature <=> chromaticity (experimental)
- Wavelength <=> CIE
- Typical RGB LED properties
It is intended to use with homebridge-raspi-rgbw-led project.
Many-LED problem is a mathematical and engineering problem to determine the mix ratio of R-G-B or more LED light sources (component LEDs) to produce an intermediate color and luminosity. While a color and luminosity is given by 3 parameters (for example, x-y chromaticity and luminance), many-LED problem is to determine the mix ratio of 3 or more component LEDs.
For 3 LEDs, it is a determinate problem. For 4 or more, this problem is indeterminate and needs additional constraint(s) to solve. Minimizing power consumption is a useful constraint. For 4 LEDs, it is solved as a single parameter inequality. For more than 5 LEDs we need to solve it using linear programming (LP).
In detail, see Solve RGB+ LEDs PWM from Chromaticity.
- Node 10.20.0 or newer except 11.x.
- Unix systems with C++-17 compiler.
These are limitation of linear-program-solver.
Install with npm:
npm install kch-rgbw-lib
Some additional npm packages will be installed.
- CSpace : Color conversion class.
- RGBWLED : Composite LED class.
- LEDChip : Single color LED chip class.
- ColorTemperature : Functions for color temperature of black body.
- WaveLength : Functions for CIE 1931 chromaticity and wave length.
More to read
- Solve RGB+ LEDs PWM from Chromaticity : A mathematical solution for many-LED problem.
- A Beginner’s Guide to (CIE) Colorimetry - Color and Imaging
- CIE 1931 color space / Wikipedia
- HSL and HSV / Wikipedia
- sRGB / Wikipedia
- Blackbody color temperature data file / Mitchell Charity
- 新しいカラーマネージメントの方法 / 中村芳樹
- AN1562 High Resolution RGB LED Color Mixing Application Note / Microchip
The MIT License (MIT) Copyright (c) K. Chinzei (firstname.lastname@example.org) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.