WS2812
Revision 3:adfd3b002caa, committed 2021-12-13
- Comitter:
- villemejane
- Date:
- Mon Dec 13 08:57:11 2021 +0000
- Parent:
- 2:6e647820f587
- Commit message:
- WS2812
Changed in this revision
WS2812.cpp | Show annotated file Show diff for this revision Revisions of this file |
WS2812.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/WS2812.cpp Thu Feb 12 20:24:15 2015 +0000 +++ b/WS2812.cpp Mon Dec 13 08:57:11 2021 +0000 @@ -1,12 +1,22 @@ #include "WS2812.h" -WS2812::WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow) : __gpo(pin) +int FRAME_SIZE, TYPE_BANDEAU; + +WS2812::WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow, int typeBandeau) : __gpo(pin) { __size = size; __transmitBuf = new bool[size * FRAME_SIZE]; __use_II = OFF; __II = 0xFF; // set global intensity to full __outPin = pin; + if(typeBandeau == 0){ + TYPE_BANDEAU = 3; + FRAME_SIZE = 3 * FRAME_SIZE_LED; + } + else{ + TYPE_BANDEAU = 4; + FRAME_SIZE = 4 * FRAME_SIZE_LED; + } // Default values designed for K64f. Assumes GPIO toggle takes ~0.4us setDelays(zeroHigh, zeroLow, oneHigh, oneLow); @@ -57,7 +67,7 @@ } // Apply the scaling factor to each othe colour components - for (int clr = 0; clr < 3; clr++) { + for (int clr = 0; clr < TYPE_BANDEAU; clr++) { agrb[clr] = ((agrb[clr] * sf) >> 8); for (int j = 0; j < 8; j++) {
--- a/WS2812.h Thu Feb 12 20:24:15 2015 +0000 +++ b/WS2812.h Mon Dec 13 08:57:11 2021 +0000 @@ -21,7 +21,9 @@ #include "mbed.h" -#define FRAME_SIZE 24 +#define TYPE_BANDEAU_NEO 4 +#define TYPE_BANDEAU_NONO 3 +#define FRAME_SIZE_LED 8 //!Library for the WS2812 RGB LED with integrated controller /*! @@ -43,7 +45,7 @@ * @param oneLow How many NOPs to insert to ensure T1L is properly generated. See library description for more information. * */ - WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow); + WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow, int typeBandeau = 0); /*! Destroys instance.