Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Garcia <danielgarcia@gmail.com>2014-07-01 11:32:31 +0400
committerDaniel Garcia <danielgarcia@gmail.com>2014-07-01 11:32:31 +0400
commitcfb8cdd19f46e06044af6ad1ca3cd934dacdcdc1 (patch)
tree8e1a1ccab4ba71ec625a065b1e501486669d676a /chipsets.h
parent7359aaf0fade264d600f5babe5a29818486c14c3 (diff)
parentff644ea5c57f637082b7ba30ab7fe9ba0a5396de (diff)
Merge branch 'FastLED2.1' into parallel
Diffstat (limited to 'chipsets.h')
-rw-r--r--chipsets.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/chipsets.h b/chipsets.h
index ad1962d9..e26d5aad 100644
--- a/chipsets.h
+++ b/chipsets.h
@@ -200,6 +200,86 @@ public:
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> {};
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// APA102 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_KHZ(1200)>
+class APA102Controller : public CLEDController {
+ typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
+ SPI mSPI;
+
+ void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
+
+ inline void writeLed(uint8_t r, uint8_t g, uint8_t b) __attribute__((always_inline)) {
+ mSPI.writeByte(0xFF); mSPI.writeByte(r); mSPI.writeByte(g); mSPI.writeByte(b);
+ }
+
+public:
+ APA102Controller() {}
+
+ virtual void init() {
+ mSPI.init();
+ }
+
+ virtual void clearLeds(int nLeds) {
+ showColor(CRGB(0,0,0), nLeds, CRGB(0,0,0));
+ }
+
+ virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) {
+ PixelController<RGB_ORDER> pixels(data, nLeds, scale, getDither());
+
+ mSPI.select();
+
+ writeBoundary();
+ while(nLeds--) {
+ writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2());
+ pixels.stepDithering();
+ }
+ writeBoundary();
+
+ mSPI.waitFully();
+ mSPI.release();
+ }
+
+ virtual void show(const struct CRGB *data, int nLeds, CRGB scale) {
+ PixelController<RGB_ORDER> pixels(data, nLeds, scale, getDither());
+
+ mSPI.select();
+
+ writeBoundary();
+ for(int i = 0; i < nLeds; i++) {
+ writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2());
+ pixels.advanceData();
+ pixels.stepDithering();
+ }
+ writeBoundary();
+
+ mSPI.release();
+ }
+
+#ifdef SUPPORT_ARGB
+ virtual void show(const struct CRGB *data, int nLeds, CRGB scale) {
+ PixelController<RGB_ORDER> pixels(data, nLeds,, scale, getDither());
+
+ mSPI.select();
+
+ writeBoundary();
+ for(int i = 0; i < nLeds; i++) {
+ writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2());
+ pixels.advanceData();
+ pixels.stepDithering();
+ }
+ writeBoundary();
+
+ mSPI.release();
+ }
+#endif
+};
+
+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// P9813 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
@@ -280,6 +360,7 @@ public:
#endif
};
+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// SM16716 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)