Library allowing up to 16 strings of 60 WS2811 or WS2812 LEDs to be driven from a single FRDM-KL25Z board. Uses hardware DMA to do a full 800 KHz rate without much CPU burden.

Dependents:   Multi_WS2811_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Colors.h Source File

Colors.h

00001 #ifndef __included_colors_h
00002 #define __included_colors_h
00003 
00004 #include <stdint.h>
00005 
00006 /**
00007  * Converts the components of a color, as specified by the HSB
00008  * model, to an equivalent set of values for the default RGB model.
00009  * <p>
00010  * The <code>saturation</code> and <code>brightness</code> components
00011  * should be floating-point values between zero and one
00012  * (numbers in the range 0.0-1.0).  The <code>hue</code> component
00013  * can be any floating-point number.  The floor of this number is
00014  * subtracted from it to create a fraction between 0 and 1.  This
00015  * fractional number is then multiplied by 360 to produce the hue
00016  * angle in the HSB color model.
00017  * <p>
00018  * The integer that is returned by <code>HSBtoRGB</code> encodes the
00019  * value of a color in bits 0-23 of an integer value that is the same
00020  * format used by the method {@link #getRGB() <code>getRGB</code>}.
00021  * This integer can be supplied as an argument to the
00022  * <code>Color</code> constructor that takes a single integer argument.
00023  * @param     hue   the hue component of the color
00024  * @param     saturation   the saturation of the color
00025  * @param     brightness   the brightness of the color
00026  * @return    the RGB value of the color with the indicated hue,
00027  *                            saturation, and brightness.
00028  */
00029 void HSBtoRGB(float hue, float saturation, float brightness, uint8_t *pr, uint8_t *pg, uint8_t *pb);
00030 
00031 /**
00032  * Converts the components of a color, as specified by the default RGB
00033  * model, to an equivalent set of values for hue, saturation, and
00034  * brightness that are the three components of the HSB model.
00035  * <p>
00036  * If the <code>hsbvals</code> argument is <code>null</code>, then a
00037  * new array is allocated to return the result. Otherwise, the method
00038  * returns the array <code>hsbvals</code>, with the values put into
00039  * that array.
00040  * @param     r   the red component of the color
00041  * @param     g   the green component of the color
00042  * @param     b   the blue component of the color
00043  * @param     hsbvals  the array used to return the
00044  *                     three HSB values, or <code>null</code>
00045  * @return    an array of three elements containing the hue, saturation,
00046  *                     and brightness (in that order), of the color with
00047  *                     the indicated red, green, and blue components.
00048  */
00049 float* RGBtoHSB(uint8_t r, uint8_t g, uint8_t b, float* hsbvals);
00050 
00051 #endif