Optimised fork of bikeNomad's WS2811 LED control library. Supports KL25Z and KL46Z

Dependents:   CubicHand

Fork of Multi_WS2811 by Ned Konz

Optimised to use far less RAM than the original.

Capable of running up to 8 strings of 240 LEDs each with plenty of RAM to spare on the KL46Z.

Should run at least three strings of 240 LEDs on the KL25Z (RAM limited)

Committer:
Tomo2k
Date:
Wed Apr 02 13:22:25 2014 +0000
Revision:
7:58623ad7f310
Parent:
3:2b5b03a3c0a5
Updated comments, parameter names and added example usage

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bikeNomad 0:a8535703f23b 1 #include <mbed.h>
bikeNomad 0:a8535703f23b 2
bikeNomad 0:a8535703f23b 3 #ifndef __included_colors_h
bikeNomad 0:a8535703f23b 4 #define __included_colors_h
bikeNomad 0:a8535703f23b 5
Tomo2k 3:2b5b03a3c0a5 6 //! Color Functions
Tomo2k 3:2b5b03a3c0a5 7 class Colors
Tomo2k 3:2b5b03a3c0a5 8 {
Tomo2k 3:2b5b03a3c0a5 9 public :
Tomo2k 3:2b5b03a3c0a5 10 /**
Tomo2k 3:2b5b03a3c0a5 11 * Converts the components of a color, as specified by the HSB
Tomo2k 3:2b5b03a3c0a5 12 * model, to an equivalent set of values for the default RGB model.
Tomo2k 3:2b5b03a3c0a5 13 * <p>
Tomo2k 3:2b5b03a3c0a5 14 * The <code>saturation</code> and <code>brightness</code> components
Tomo2k 3:2b5b03a3c0a5 15 * should be floating-point values between zero and one
Tomo2k 3:2b5b03a3c0a5 16 * (numbers in the range 0.0-1.0). The <code>hue</code> component
Tomo2k 3:2b5b03a3c0a5 17 * can be any floating-point number. The floor of this number is
Tomo2k 3:2b5b03a3c0a5 18 * subtracted from it to create a fraction between 0 and 1. This
Tomo2k 3:2b5b03a3c0a5 19 * fractional number is then multiplied by 360 to produce the hue
Tomo2k 3:2b5b03a3c0a5 20 * angle in the HSB color model.
Tomo2k 3:2b5b03a3c0a5 21 * <p>
Tomo2k 3:2b5b03a3c0a5 22 * The integer that is returned by <code>HSBtoRGB</code> encodes the
Tomo2k 3:2b5b03a3c0a5 23 * value of a color in bits 0-23 of an integer value that is the same
Tomo2k 3:2b5b03a3c0a5 24 * format used by the method {@link #getRGB() <code>getRGB</code>}.
Tomo2k 3:2b5b03a3c0a5 25 * This integer can be supplied as an argument to the
Tomo2k 3:2b5b03a3c0a5 26 * <code>Color</code> constructor that takes a single integer argument.
Tomo2k 3:2b5b03a3c0a5 27 * @param hue the hue component of the color
Tomo2k 3:2b5b03a3c0a5 28 * @param saturation the saturation of the color
Tomo2k 3:2b5b03a3c0a5 29 * @param brightness the brightness of the color
Tomo2k 3:2b5b03a3c0a5 30 * @return the RGB value of the color with the indicated hue,
Tomo2k 3:2b5b03a3c0a5 31 * saturation, and brightness.
Tomo2k 3:2b5b03a3c0a5 32 */
Tomo2k 3:2b5b03a3c0a5 33 static void HSBtoRGB(float hue, float saturation, float brightness, uint8_t *pr, uint8_t *pg, uint8_t *pb);
bikeNomad 0:a8535703f23b 34
Tomo2k 3:2b5b03a3c0a5 35 /**
Tomo2k 3:2b5b03a3c0a5 36 * Converts the components of a color, as specified by the default RGB
Tomo2k 3:2b5b03a3c0a5 37 * model, to an equivalent set of values for hue, saturation, and
Tomo2k 3:2b5b03a3c0a5 38 * brightness that are the three components of the HSB model.
Tomo2k 3:2b5b03a3c0a5 39 * <p>
Tomo2k 3:2b5b03a3c0a5 40 * If the <code>hsbvals</code> argument is <code>null</code>, then a
Tomo2k 3:2b5b03a3c0a5 41 * new array is allocated to return the result. Otherwise, the method
Tomo2k 3:2b5b03a3c0a5 42 * returns the array <code>hsbvals</code>, with the values put into
Tomo2k 3:2b5b03a3c0a5 43 * that array.
Tomo2k 3:2b5b03a3c0a5 44 * @param r the red component of the color
Tomo2k 3:2b5b03a3c0a5 45 * @param g the green component of the color
Tomo2k 3:2b5b03a3c0a5 46 * @param b the blue component of the color
Tomo2k 3:2b5b03a3c0a5 47 * @param hsbvals the array used to return the
Tomo2k 3:2b5b03a3c0a5 48 * three HSB values, or <code>null</code>
Tomo2k 3:2b5b03a3c0a5 49 * @return an array of three elements containing the hue, saturation,
Tomo2k 3:2b5b03a3c0a5 50 * and brightness (in that order), of the color with
Tomo2k 3:2b5b03a3c0a5 51 * the indicated red, green, and blue components.
Tomo2k 3:2b5b03a3c0a5 52 */
Tomo2k 3:2b5b03a3c0a5 53 static float* RGBtoHSB(uint8_t r, uint8_t g, uint8_t b, float* hsbvals);
Tomo2k 3:2b5b03a3c0a5 54
Tomo2k 3:2b5b03a3c0a5 55 };
bikeNomad 0:a8535703f23b 56
bikeNomad 0:a8535703f23b 57 #endif