WS2812
Diff: WS2812.cpp
- Revision:
- 3:adfd3b002caa
- Parent:
- 1:aadbf08c62a2
--- 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++) {