Full CIE color correction with the Teensy 3.1
I put together a general purpose firmware that lets you define specific LED sources as CIE-LUV coordinates, and then abstracts it away so that you can use hue, saturation, and intensity with optimal selection and mixing of the available sources to get the desired CIE-LCH value (hue based instead of coordinate based).
You define a LED source like this:
CIELED white(0.202531646, 0.469936709, (float)180/180, 9); CIELED red(0.5137017676, 0.5229440531, (float)78/78, 6); CIELED amber(0.3135687079, 0.5529418124, (float)60/60, 5); CIELED green(0.0595846867, 0.574988823, (float)125/125, 22); CIELED cyan(0.0306675939, 0.5170937486, (float)95/95, 3); CIELED blue(0.1747943747, 0.1117834986, (float)30/30, 23); CIELED violet(0.35, 0.15, (float)30/30, 4);
and then you add them to the colorspace like this:
// Create a colorspace object that will be put into the abstract lamp. std::shared_ptr colorspace (new Colorspace(white)); // Add the CIE LED definitions to the colorspace. colorspace->addLED(red); colorspace->addLED(amber); colorspace->addLED(green); colorspace->addLED(cyan); colorspace->addLED(blue);
Then all you need to do is ask the colorspace to return the proper values and output them to the PWM pins defined in the CIELED object.
Code example showing this alongside USB control, and several types of LED effects you can use is here:
with an overall project description here: