diff options
author | heX <heX1625616@gmail.com> | 2018-12-17 04:06:54 +0300 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2018-12-25 22:10:41 +0300 |
commit | 334fa8c40b45c602f7d806f30ccbeefec0638e30 (patch) | |
tree | 1d40fd12f1164fd3f6804fe7a7995a3c27d09ab1 | |
parent | 8f2e86434b2bfa4d6178622ca3745a68303f8b00 (diff) |
Add support LPD6803
-rw-r--r-- | FastLED.h | 4 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | chipsets.h | 48 | ||||
-rw-r--r-- | examples/RGBCalibrate/RGBCalibrate.ino | 70 | ||||
-rw-r--r-- | keywords.txt | 1 |
5 files changed, 91 insertions, 35 deletions
@@ -69,6 +69,7 @@ FASTLED_NAMESPACE_BEGIN /// definitions for the spi chipset constants enum ESPIChipsets { + LPD6803, LPD8806, WS2801, WS2803, @@ -218,6 +219,7 @@ public: /// @returns a reference to the added controller template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { + case LPD6803: { static LPD6803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case LPD8806: { static LPD8806Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2801: { static WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2803: { static WS2803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } @@ -231,6 +233,7 @@ public: template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { + case LPD6803: { static LPD6803Controller<DATA_PIN, CLOCK_PIN> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case LPD8806: { static LPD8806Controller<DATA_PIN, CLOCK_PIN> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2801: { static WS2801Controller<DATA_PIN, CLOCK_PIN> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2803: { static WS2803Controller<DATA_PIN, CLOCK_PIN> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } @@ -244,6 +247,7 @@ public: template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { + case LPD6803: { static LPD6803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case LPD8806: { static LPD8806Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2801: { static WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } case WS2803: { static WS2803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } @@ -54,9 +54,10 @@ Here's a list of all the LED chipsets are supported. More details on the led ch * P9813 - aka Cool Neon's Total Control Lighting * DMX - send rgb data out over DMX using arduino DMX libraries * SmartMatrix panels - needs the SmartMatrix library - https://github.com/pixelmatix/SmartMatrix +* LPD6803 - SPI based chpiset, chip CMODE pin must be set to 1 (inside oscillator mode) -LPD6803, HL1606, and "595"-style shift registers are no longer supported by the library. The older Version 1 of the library ("FastSPI_LED") has support for these, but is missing many of the advanced features of current versions and is no longer being maintained. +HL1606, and "595"-style shift registers are no longer supported by the library. The older Version 1 of the library ("FastSPI_LED") has support for these, but is missing many of the advanced features of current versions and is no longer being maintained. ## Supported platforms @@ -143,6 +143,53 @@ protected: template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(25)> class WS2803Controller : public WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {}; +/// LPD6803 controller class (LPD1101). +/// 16 bit (1 bit - const "1", 5 bit - red, 5 bit - green, 5 bit blue). +/// In chip CMODE pin must be set to 1 (inside oscillator mode). +/// Datasheet: https://cdn-shop.adafruit.com/datasheets/LPD6803.pdf +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(12) +template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(12)> +class LPD6803Controller : public CPixelLEDController<RGB_ORDER> { + typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI; + SPI mSPI; + + void startBoundary() { mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); } + +public: + LPD6803Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController<RGB_ORDER> & pixels) { + mSPI.select(); + + startBoundary(); + while(pixels.has(1)) { + register uint16_t command; + command = 0x8000; + command |= (pixels.loadAndScale0() & 0xF8) << 7; // red is the high 5 bits + command |= (pixels.loadAndScale1() & 0xF8) << 2; // green is the middle 5 bits + mSPI.writeByte((command >> 8) & 0xFF); + command |= pixels.loadAndScale2() >> 3 ; // blue is the low 5 bits + mSPI.writeByte(command & 0xFF); + + pixels.stepDithering(); + pixels.advanceData(); + } + //endBoundary(pixels.size()); + mSPI.waitFully(); + mSPI.release(); + } + +}; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // APA102 definition - takes data/clock/select pin values (N.B. should take an SPI definition?) @@ -271,6 +318,7 @@ protected: pixels.stepDithering(); pixels.advanceData(); } + endBoundary(pixels.size()); mSPI.waitFully(); diff --git a/examples/RGBCalibrate/RGBCalibrate.ino b/examples/RGBCalibrate/RGBCalibrate.ino index 8bc4b12b..72e21507 100644 --- a/examples/RGBCalibrate/RGBCalibrate.ino +++ b/examples/RGBCalibrate/RGBCalibrate.ino @@ -1,4 +1,4 @@ -#include <FastLED.h> +#include "FastLED.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -11,12 +11,12 @@ // all explicitly specify the RGB order as RGB) // * Define DATA_PIN to the pin that data is connected to. // * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin -// * Compile/upload/run the sketch +// * Compile/upload/run the sketch -// You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green -// leds, and 3 blue leds. If you see different colors, the count of each color tells you what the +// You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green +// leds, and 3 blue leds. If you see different colors, the count of each color tells you what the // position for that color in the rgb orering should be. So, for example, if you see 1 Blue, and 2 -// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green). +// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green). // You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering // and it should come out correctly, 1 red, 2 green, and 3 blue. @@ -33,38 +33,40 @@ CRGB leds[NUM_LEDS]; void setup() { - // sanity check delay - allows reprogramming if accidently blowing power w/leds - delay(2000); + // sanity check delay - allows reprogramming if accidently blowing power w/leds + delay(2000); - // Uncomment one of the following lines for your leds arrangement. - // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); - // FastLED.setBrightness(CRGB(255,255,255)); - // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS); + // Uncomment one of the following lines for your leds arrangement. + // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); + // FastLED.setBrightness(CRGB(255,255,255)); + // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS); - FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS); + FastLED.addLeds<LPD6803, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); - // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); + // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); } void loop() { - leds[0] = CRGB(255,0,0); - leds[1] = CRGB(0,255,0); - leds[2] = CRGB(0,255,0); - leds[3] = CRGB(0,0,255); - leds[4] = CRGB(0,0,255); - leds[5] = CRGB(0,0,255); - FastLED.show(); - delay(1000); -} + leds[0] = CRGB(255,0,0); + leds[1] = CRGB(0,255,0); + leds[2] = CRGB(0,255,0); + leds[3] = CRGB(0,0,255); + leds[4] = CRGB(0,0,255); + leds[5] = CRGB(0,0,255); + leds[6] = CRGB(0,0,0); + FastLED.show(); + delay(1000); +}
\ No newline at end of file diff --git a/keywords.txt b/keywords.txt index 1c3b8c03..0beb3156 100644 --- a/keywords.txt +++ b/keywords.txt @@ -294,6 +294,7 @@ CRGB::YellowGreen KEYWORD2 ####################################### # Chipsets +LPD6803 LITERAL1 LPD8806 LITERAL1 WS2801 LITERAL1 WS2803 LITERAL1 |