Test program for my Multi_WS2811 library that started out as a fork of heroic/WS2811. My library uses hardware DMA on the FRDM-KL25Z to drive up to 16 strings of WS2811 or WS2812 LEDs in parallel.

Dependencies:   Multi_WS2811 mbed MMA8451Q

Fork of WS2811 by Heroic Robotics

NOTE: I have accidentally pushed changes for another fork of this program that I used in the recent Georgetown Carnival Power Tool Races. When I get some time, I will restore the test program to its original glory.

You can see my power tool racer (Nevermore's Revenge) here

/media/uploads/bikeNomad/img_0482.jpg

This tests my FRDM-KL25Z multi-string WS2811/WS2812 library. It uses the accelerometer to change the rainbow phase on two strings of LEDs as well as the touch sense to change brightness.

A video of this program in operation is here.

Here is the library that I developed to run the LEDs:

Import libraryMulti_WS2811

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.

Committer:
bikeNomad
Date:
Fri Dec 06 06:58:12 2013 +0000
Revision:
19:600deef36348
added HSB/RGB conversions; removed unnecessary virtuals

Who changed what in which revision?

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