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
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

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.
WS2812.h@15:331e139672b5, 2013-12-05 (annotated)
- Committer:
- bikeNomad
- Date:
- Thu Dec 05 15:12:47 2013 +0000
- Revision:
- 15:331e139672b5
inlined bit writes
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bikeNomad | 15:331e139672b5 | 1 | // Mbed library to control WS2801-based RGB LED Strips |
| bikeNomad | 15:331e139672b5 | 2 | // some portions (c) 2011 Jelmer Tiete |
| bikeNomad | 15:331e139672b5 | 3 | // This library is ported from the Arduino implementation of Adafruit Industries |
| bikeNomad | 15:331e139672b5 | 4 | // found at: http://github.com/adafruit/LPD8806 |
| bikeNomad | 15:331e139672b5 | 5 | // and their strips: http://www.adafruit.com/products/306 |
| bikeNomad | 15:331e139672b5 | 6 | // Released under the MIT License: http://mbed.org/license/mit |
| bikeNomad | 15:331e139672b5 | 7 | // |
| bikeNomad | 15:331e139672b5 | 8 | /*****************************************************************************/ |
| bikeNomad | 15:331e139672b5 | 9 | |
| bikeNomad | 15:331e139672b5 | 10 | // Heavily modified by Jas Strong, 2012-10-04 |
| bikeNomad | 15:331e139672b5 | 11 | // Changed to use a virtual base class and to use software SPI. |
| bikeNomad | 15:331e139672b5 | 12 | |
| bikeNomad | 15:331e139672b5 | 13 | #include "mbed.h" |
| bikeNomad | 15:331e139672b5 | 14 | #include "LedStrip.h" |
| bikeNomad | 15:331e139672b5 | 15 | #ifndef MBED_WS2811_H |
| bikeNomad | 15:331e139672b5 | 16 | #define MBED_WS2811_H |
| bikeNomad | 15:331e139672b5 | 17 | |
| bikeNomad | 15:331e139672b5 | 18 | #ifdef TARGET_KL25Z |
| bikeNomad | 15:331e139672b5 | 19 | #define MOSI_DEFAULT PTD2 |
| bikeNomad | 15:331e139672b5 | 20 | #define SCLK_DEFAULT PTC5 |
| bikeNomad | 15:331e139672b5 | 21 | #else |
| bikeNomad | 15:331e139672b5 | 22 | #endif |
| bikeNomad | 15:331e139672b5 | 23 | |
| bikeNomad | 15:331e139672b5 | 24 | class WS2812 : public LedStrip |
| bikeNomad | 15:331e139672b5 | 25 | { |
| bikeNomad | 15:331e139672b5 | 26 | public: |
| bikeNomad | 15:331e139672b5 | 27 | WS2812(int n, PinName mosi = MOSI_DEFAULT, PinName sclk = SCLK_DEFAULT); |
| bikeNomad | 15:331e139672b5 | 28 | virtual void begin(void); |
| bikeNomad | 15:331e139672b5 | 29 | virtual void show(void); |
| bikeNomad | 15:331e139672b5 | 30 | virtual void blank(void); |
| bikeNomad | 15:331e139672b5 | 31 | |
| bikeNomad | 15:331e139672b5 | 32 | private: |
| bikeNomad | 15:331e139672b5 | 33 | SPI spi; // to do actual communication |
| bikeNomad | 15:331e139672b5 | 34 | |
| bikeNomad | 15:331e139672b5 | 35 | Timer guardtime; |
| bikeNomad | 15:331e139672b5 | 36 | uint32_t bogocal; |
| bikeNomad | 15:331e139672b5 | 37 | |
| bikeNomad | 15:331e139672b5 | 38 | void write(uint8_t byte); |
| bikeNomad | 15:331e139672b5 | 39 | void writebit(bool bit); |
| bikeNomad | 15:331e139672b5 | 40 | void celldelay(void); |
| bikeNomad | 15:331e139672b5 | 41 | }; |
| bikeNomad | 15:331e139672b5 | 42 | #endif |
Ned Konz


Generic WS2811/WS2812