eLab Team / Mbed 2 deprecated AutomaticDispenser

Dependencies:   mbed AsyncBuzzerLib X_NUCLEO_53L1A1_mbed WS2812

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LED_WS2812.h Source File

LED_WS2812.h

00001 
00002 #ifndef LED_WS2812_H
00003 #define LED_WS2812_H
00004 
00005 #include "mbed.h"
00006 #include "WS2812.h"
00007 #include "PixelArray.h"
00008 
00009 /*
00010 #define ZERO_HIGH  250.0
00011 #define ZERO_LOW  1000.0
00012 #define ONE_HIGH  1000.0
00013 #define ONE_LOW   250.0
00014 */
00015 #define ZERO_HIGH  200.0
00016 #define ZERO_LOW  800.0
00017 #define ONE_HIGH  800.0
00018 #define ONE_LOW   200.0
00019 
00020  typedef enum _LED_COLORS {
00021         BLUE        = 0x0000FF,
00022         LIGHTBLUE   = 0x00FFF6,
00023         RED         = 0xFF0000,
00024         ORANGE      = 0xFF3500,
00025         GREEN       = 0X00FF00,
00026         BLACK       = 0X000000,
00027         WHITE       = 0XFFFFFF,
00028         PURPLE      = 0XFF00FF,
00029         PINK        = 0XFF84A3,
00030         YELLOW      = 0XFFFF00,
00031         DARK_YELLOW      = 0X555500,
00032         DEFAULT     = 0x000000
00033     } LED_COLORS;
00034     
00035 class LED_WS2812
00036 {
00037 public:
00038     LED_WS2812(PinName _PinOut,  int _nbLeds);
00039     ~LED_WS2812();
00040     void SetColor(LED_COLORS _color, int position);
00041     void SetColor(unsigned int _color, int position);
00042     void SetColor(unsigned int _color);
00043     void SetColor(LED_COLORS _color);
00044     void ResetColor();
00045     void SetIntensity(float perCent);
00046  
00047     void InsertColor(unsigned int _color);
00048     void InsertColor(unsigned int _color, float brightness);
00049     void InsertColorNtimes(int N, unsigned int _color, float brightness);  
00050     void InsertColorNtimes(int N, unsigned int _color);
00051 
00052     void InsertColor(LED_COLORS _color);
00053     void InsertColor(LED_COLORS _color, float brightness);
00054     void InsertColorNtimes(int N, LED_COLORS _color, float brightness);  
00055     void InsertColorNtimes(int N, LED_COLORS _color);
00056 
00057     void StartRotation(float interval); // interval in s
00058     void StopRotation();  // 
00059     void Rotate(); // One Rotation
00060     
00061     void StartBlink(float interval); // interval in s
00062     void StopBlink();  //
00063     void Blink(); // One Rotation
00064       
00065 private:
00066     void __writeBuf(int z);
00067     void __insert2buf();
00068     void __insertColor(unsigned int _color, int _intensity);
00069 
00070     WS2812 *ws;
00071     int nbLeds;
00072     PixelArray *pxArray;
00073     int nbInsert;
00074     PixelArray *pxInsert;
00075     Ticker  LEDSystemTick;    // System Callback for Rotation
00076     Ticker  LEDBlinkSystemTick;    // System Callback for Rotation
00077     bool rotationState;
00078    bool blinkState;
00079     int rotationPosition;
00080     bool blinkONOFF; // ON = true, OFF = false
00081     int intensity;
00082 };
00083 
00084 #endif