My Version of The LED_WS2812 Library

Dependencies:   WS2812 PixelArray

Fork of LED_WS2812 by CreaLab

Committer:
garphil
Date:
Wed Feb 15 01:44:53 2017 +0000
Revision:
0:999518b1799b
Child:
1:64e72a25801f
First publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garphil 0:999518b1799b 1
garphil 0:999518b1799b 2 #ifndef LED_WS2812_H
garphil 0:999518b1799b 3 #define LED_WS2812_H
garphil 0:999518b1799b 4
garphil 0:999518b1799b 5 #include "mbed.h"
garphil 0:999518b1799b 6 #include "WS2812.h"
garphil 0:999518b1799b 7 #include "PixelArray.h"
garphil 0:999518b1799b 8
garphil 0:999518b1799b 9
garphil 0:999518b1799b 10 #define ZERO_HIGH 250.0
garphil 0:999518b1799b 11 #define ZERO_LOW 1000.0
garphil 0:999518b1799b 12 #define ONE_HIGH 1000.0
garphil 0:999518b1799b 13 #define ONE_LOW 250.0
garphil 0:999518b1799b 14
garphil 0:999518b1799b 15 typedef enum _LED_COLORS {
garphil 0:999518b1799b 16 BLUE = 0x0000FF,
garphil 0:999518b1799b 17 LIGHTBLUE = 0x00FFF6,
garphil 0:999518b1799b 18 RED = 0xFF0000,
garphil 0:999518b1799b 19 GREEN = 0X00FF00,
garphil 0:999518b1799b 20 BLACK = 0X000000,
garphil 0:999518b1799b 21 WHITE = 0XFFFFFF,
garphil 0:999518b1799b 22 PURPLE = 0XFF00FF,
garphil 0:999518b1799b 23 PINK = 0XFF84A3,
garphil 0:999518b1799b 24 YELLOW = 0XFFFF00,
garphil 0:999518b1799b 25 DARK_YELLOW = 0X555500,
garphil 0:999518b1799b 26 DEFAULT = 0x000000
garphil 0:999518b1799b 27 } LED_COLORS;
garphil 0:999518b1799b 28
garphil 0:999518b1799b 29 class LED_WS2812
garphil 0:999518b1799b 30 {
garphil 0:999518b1799b 31 public:
garphil 0:999518b1799b 32 LED_WS2812(PinName _PinOut, int _nbLeds);
garphil 0:999518b1799b 33 ~LED_WS2812();
garphil 0:999518b1799b 34 void SetColor(unsigned int _color);
garphil 0:999518b1799b 35 void SetColor(LED_COLORS _color);
garphil 0:999518b1799b 36 void ResetColor();
garphil 0:999518b1799b 37 void SetIntensity(float perCent);
garphil 0:999518b1799b 38
garphil 0:999518b1799b 39 void InsertColor(unsigned int _color);
garphil 0:999518b1799b 40 void InsertColor(unsigned int _color, float brightness);
garphil 0:999518b1799b 41 void InsertColorNtimes(int N, unsigned int _color, float brightness);
garphil 0:999518b1799b 42 void InsertColorNtimes(int N, unsigned int _color);
garphil 0:999518b1799b 43
garphil 0:999518b1799b 44 void InsertColor(LED_COLORS _color);
garphil 0:999518b1799b 45 void InsertColor(LED_COLORS _color, float brightness);
garphil 0:999518b1799b 46 void InsertColorNtimes(int N, LED_COLORS _color, float brightness);
garphil 0:999518b1799b 47 void InsertColorNtimes(int N, LED_COLORS _color);
garphil 0:999518b1799b 48
garphil 0:999518b1799b 49 void StartRotation(float interval); // itnerval in ms
garphil 0:999518b1799b 50 void StopRotation(); // interval in ms
garphil 0:999518b1799b 51 void Rotate(); // One Rotation
garphil 0:999518b1799b 52
garphil 0:999518b1799b 53 private:
garphil 0:999518b1799b 54 void __writeBuf(int z);
garphil 0:999518b1799b 55 void __insert2buf();
garphil 0:999518b1799b 56 void __insertColor(unsigned int _color, int _intensity);
garphil 0:999518b1799b 57
garphil 0:999518b1799b 58 WS2812 *ws;
garphil 0:999518b1799b 59 int nbLeds;
garphil 0:999518b1799b 60 PixelArray *pxArray;
garphil 0:999518b1799b 61 int nbInsert;
garphil 0:999518b1799b 62 PixelArray *pxInsert;
garphil 0:999518b1799b 63 Ticker LEDSystemTick; // System Callback for Rotation
garphil 0:999518b1799b 64 bool rotationState;
garphil 0:999518b1799b 65 int rotationPosition;
garphil 0:999518b1799b 66 int intensity;
garphil 0:999518b1799b 67 };
garphil 0:999518b1799b 68
garphil 0:999518b1799b 69 #endif