Yet another WS2812 driver, uses the BusrtSPI library. Less features than the PixelArray library but I felt like making my own version.
An alternative WS2811/2812 (NeoPixel) driver using the BusrtSPI library.
Credit for the inspiration goes to Jacob Bramley for his pixelArray library that can be found here: http://developer.mbed.org/users/JacobBramley/code/PixelArray/
This version was written mainly to help me understand what was going on rather than to overcome any shortcomings in the other library and as such it lacks some features (800kHz only, no callback on each pixel etc...)
Connect the SPI output to the LED data input, other SPI pins are unused.
Note: The voltage thresholds between the LEDs and mbed devices are on paper incompatible. The datasheet for the WS2812 indicated that running at 5V it requires 4V on Din to count it as a high (the threshold is 0.8*the supply voltage). Most mbeds are lucky to output much over 3.1V. In reality things normally work OK but it depends on the mBed and batch to batch variations in the LEDs, I've seen some combinations that start to fail at an LED supply voltage of 4.4V or more. If something odd is going on try dropping the LED power supply voltage, they run fine down to 4V.
History
Update to fix issues with 16bit brightness support.
2016-11-23, by AndyA [Wed, 23 Nov 2016 09:41:48 +0000] rev 5
Update to fix issues with 16bit brightness support.
2016-11-22, by AndyA [Tue, 22 Nov 2016 15:14:42 +0000] rev 4
Added 16bit colour support
2014-11-12, by AndyA [Wed, 12 Nov 2014 16:43:33 +0000] rev 3
Added 16bit colour support
remove excess cut and paste;
2014-11-07, by AndyA [Fri, 07 Nov 2014 09:25:52 +0000] rev 2
remove excess cut and paste;
Added comments/documentation
2014-11-06, by AndyA [Thu, 06 Nov 2014 17:11:43 +0000] rev 1
Added comments/documentation
Initial commit. Seems to work for me, needs more comments/documentaion
2014-11-05, by AndyA [Wed, 05 Nov 2014 16:47:48 +0000] rev 0
Initial commit. Seems to work for me, needs more comments/documentaion