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 MMA8451Q
Fork of WS2811 by
WS2812.h
- Committer:
- bikeNomad
- Date:
- 2013-12-05
- Revision:
- 15:331e139672b5
File content as of revision 15:331e139672b5:
// 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

Generic WS2811/WS2812