Working version without LEDs

Dependencies:   mbed WS2812

Voici le dernier schéma de cablage (version du 08/02/2020)

https://os.mbed.com/media/uploads/max_ence/schemarobot_fev2020.pdf

Committer:
elab
Date:
Sat May 30 09:31:57 2020 +0000
Revision:
1:69b5d8f0ba9c
Parent:
0:0e577ce96b2f
pour eLab;

Who changed what in which revision?

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