Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Multi_WS2811 mbed
Fork of Multi_WS2811_test by
Diff: WS2812.h
- Revision:
- 15:331e139672b5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WS2812.h Thu Dec 05 15:12:47 2013 +0000
@@ -0,0 +1,42 @@
+// Mbed library to control WS2801-based RGB LED Strips
+// some portions (c) 2011 Jelmer Tiete
+// This library is ported from the Arduino implementation of Adafruit Industries
+// found at: http://github.com/adafruit/LPD8806
+// and their strips: http://www.adafruit.com/products/306
+// Released under the MIT License: http://mbed.org/license/mit
+//
+/*****************************************************************************/
+
+// Heavily modified by Jas Strong, 2012-10-04
+// Changed to use a virtual base class and to use software SPI.
+
+#include "mbed.h"
+#include "LedStrip.h"
+#ifndef MBED_WS2811_H
+#define MBED_WS2811_H
+
+#ifdef TARGET_KL25Z
+#define MOSI_DEFAULT PTD2
+#define SCLK_DEFAULT PTC5
+#else
+#endif
+
+class WS2812 : public LedStrip
+{
+public:
+ WS2812(int n, PinName mosi = MOSI_DEFAULT, PinName sclk = SCLK_DEFAULT);
+ virtual void begin(void);
+ virtual void show(void);
+ virtual void blank(void);
+
+private:
+ SPI spi; // to do actual communication
+
+ Timer guardtime;
+ uint32_t bogocal;
+
+ void write(uint8_t byte);
+ void writebit(bool bit);
+ void celldelay(void);
+};
+#endif
\ No newline at end of file
