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:
authordanielgarcia@gmail.com <danielgarcia@gmail.com@4ad4ec5c-605d-bd5c-5796-512c9b60011b>2013-06-01 13:11:56 +0400
committerdanielgarcia@gmail.com <danielgarcia@gmail.com@4ad4ec5c-605d-bd5c-5796-512c9b60011b>2013-06-01 13:11:56 +0400
commit4644b6f769e2da7c74aa03ac778df8ff62a9d1a1 (patch)
tree005d047f07a6087419b1fcc2b2ebd5b14172447b
parent38fc7c315e29885fa74dc2ca27114c90a8f77d1b (diff)
Checking in the TCL work code in case someone wants it - builds, no testing yet, though
-rw-r--r--FastSPI_LED2.h5
-rw-r--r--chipsets.h69
-rw-r--r--examples/Fast2Dev/Fast2Dev.ino6
-rw-r--r--fastspi_avr.h2
-rw-r--r--fastspi_bitbang.h2
5 files changed, 81 insertions, 3 deletions
diff --git a/FastSPI_LED2.h b/FastSPI_LED2.h
index c601be3b..83c37aaa 100644
--- a/FastSPI_LED2.h
+++ b/FastSPI_LED2.h
@@ -13,7 +13,8 @@
enum ESPIChipsets {
LPD8806,
WS2801,
- SM16716
+ SM16716,
+ P9813
};
enum EClocklessChipsets {
@@ -48,6 +49,7 @@ public:
case LPD8806: return addLeds(new LPD8806Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
case WS2801: return addLeds(new WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
case SM16716: return addLeds(new SM16716Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
+ case P9813: return addLeds(new P9813Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
}
}
@@ -56,6 +58,7 @@ public:
case LPD8806: return addLeds(new LPD8806Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE>(), data, nLedsOrOffset, nLedsIfOffset);
case WS2801: return addLeds(new WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE>(), data, nLedsOrOffset, nLedsIfOffset);
case SM16716: return addLeds(new SM16716Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE>(), data, nLedsOrOffset, nLedsIfOffset);
+ case P9813: return addLeds(new P9813Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE>(), data, nLedsOrOffset, nLedsIfOffset);
}
}
diff --git a/chipsets.h b/chipsets.h
index 999fda1f..3656bcd5 100644
--- a/chipsets.h
+++ b/chipsets.h
@@ -140,6 +140,75 @@ public:
#endif
};
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// P9813 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_MHZ(24)>
+class P9813Controller : public CLEDController {
+ typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
+ SPI mSPI;
+ CMinWait<24> mWaitDelay;
+
+ void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
+
+ inline void writeLed(const struct CRGB & data, uint8_t scale) __attribute__((always_inline)) {
+ // prep the byte
+ register uint8_t r = scale8(data[RGB_BYTE0(RGB_ORDER)], scale);
+ register uint8_t g = scale8(data[RGB_BYTE1(RGB_ORDER)], scale);
+ register uint8_t b = scale8(data[RGB_BYTE2(RGB_ORDER)], scale);
+
+ register uint8_t top = 0xC0 | (~b & 0xC0) >> 2 | (~g & 0xC0) >> 4 | (~r & 0xC0);
+ mSPI.writeByte(top); mSPI.writeByte(b); mSPI.writeByte(g); mSPI.writeByte(r);
+ }
+
+public:
+ P9813Controller() {}
+
+ virtual void init() {
+ mSPI.init();
+ }
+
+ virtual void clearLeds(int nLeds) {
+ showColor(CRGB(0,0,0), nLeds);
+ }
+
+ virtual void showColor(const struct CRGB & data, int nLeds, uint8_t scale = 255) {
+ mSPI.select();
+
+ writeBoundary();
+ while(nLeds--) {
+ writeLed(data, scale);
+ }
+ writeBoundary();
+
+ mSPI.waitFully();
+ mSPI.release();
+ mWaitDelay.mark();
+ }
+
+ virtual void show(const struct CRGB *data, int nLeds, uint8_t scale) {
+ mSPI.select();
+
+ writeBoundary();
+ for(int i = 0; i < nLeds; i++) {
+ writeLed(data[i], scale);
+ }
+ writeBoundary();
+
+ mSPI.release();
+ }
+
+#ifdef SUPPORT_ARGB
+ virtual void show(const struct CRGB *data, int nLeds, uint8_t scale) {
+ mWaitDelay.wait();
+ mSPI.template writeBytes3<1, RGB_ORDER>((byte*)data, nLeds * 4, scale);
+ mWaitDelay.mark();
+ }
+#endif
+};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
diff --git a/examples/Fast2Dev/Fast2Dev.ino b/examples/Fast2Dev/Fast2Dev.ino
index a64b7890..68ac5e3f 100644
--- a/examples/Fast2Dev/Fast2Dev.ino
+++ b/examples/Fast2Dev/Fast2Dev.ino
@@ -18,7 +18,7 @@
#define NUM_LEDS 150
-struct CRGB leds[NUM_LEDS];
+CRGB leds[NUM_LEDS];
void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
@@ -33,7 +33,9 @@ void setup() {
// LEDS.addLeds<UCS1903, 13>(leds, NUM_LEDS);
// LEDS.addLeds<TM1803, 13>(leds, NUM_LEDS);
- LEDS.addLeds<LPD8806>(leds, NUM_LEDS)->clearLeds(300);
+ LEDS.addLeds<P9813>(leds, NUM_LEDS);
+
+ // LEDS.addLeds<LPD8806>(leds, NUM_LEDS);
// LEDS.addLeds<WS2801>(leds, NUM_LEDS);
// LEDS.addLeds<SM16716>(leds, NUM_LEDS);
diff --git a/fastspi_avr.h b/fastspi_avr.h
index 1b056ba1..af116cab 100644
--- a/fastspi_avr.h
+++ b/fastspi_avr.h
@@ -46,6 +46,8 @@ public:
static void writeBytePostWait(uint8_t b) __attribute__((always_inline)) { UDR0 = b; wait(); }
static void writeByte(uint8_t b) __attribute__((always_inline)) { wait(); UDR0 = b; }
+ static void writeWord(uint16_t w) __attribute__((always_inline)) { writeByte(w>>8); writeByte(w&0xFF); }
+
template <uint8_t BIT> inline static void writeBit(uint8_t b) {
if(b && (1 << BIT)) {
FastPin<_DATA_PIN>::hi();
diff --git a/fastspi_bitbang.h b/fastspi_bitbang.h
index b9fba8a8..4be8dd2c 100644
--- a/fastspi_bitbang.h
+++ b/fastspi_bitbang.h
@@ -45,6 +45,8 @@ public:
static void writeByteNoWait(uint8_t b) __attribute__((always_inline)) { writeByte(b); }
static void writeBytePostWait(uint8_t b) __attribute__((always_inline)) { writeByte(b); wait(); }
+ static void writeWord(uint16_t w) __attribute__((always_inline)) { writeByte(w>>8); writeByte(w&0xFF); }
+
// naive writeByte implelentation, simply calls writeBit on the 8 bits in the byte.
static void writeByte(uint8_t b) __attribute__((always_inline)) {
writeBit<7>(b);