diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2014-03-16 13:43:30 +0400 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2014-03-16 13:43:30 +0400 |
commit | 4c8c94514f46d9cf944d6bec8d64180ae02b5d38 (patch) | |
tree | fe3565442b8758b4d5d08a46126c0aeb3badbd3c | |
parent | 4f74b580304eb04b007a22457b4981360d620f5e (diff) |
* Move controller linkage to linked list, get rid of constant array of controllers
* Perform memory usage trimming on avr code and code across the board
* Tweak template instantiations for clockless chipsets to get rid of spurious globals that were never being used.
-rw-r--r-- | FastLED.cpp | 64 | ||||
-rw-r--r-- | FastLED.h | 127 | ||||
-rw-r--r-- | block_clockless.h | 6 | ||||
-rw-r--r-- | clockless2.h | 8 | ||||
-rw-r--r-- | clockless_arm_k20.h | 6 | ||||
-rw-r--r-- | clockless_arm_sam.h | 6 | ||||
-rw-r--r-- | clockless_avr.h | 201 | ||||
-rw-r--r-- | clockless_trinket.h | 35 | ||||
-rw-r--r-- | controller.h | 127 | ||||
-rw-r--r-- | delay.h | 20 | ||||
-rw-r--r-- | dmx.h | 20 | ||||
-rw-r--r-- | examples/Cylon/Cylon.ino | 6 | ||||
-rw-r--r-- | fastpin.h | 17 | ||||
-rw-r--r-- | pixeltypes.h | 2 |
14 files changed, 208 insertions, 437 deletions
diff --git a/FastLED.cpp b/FastLED.cpp index 076bac21..2b5d7698 100644 --- a/FastLED.cpp +++ b/FastLED.cpp @@ -9,13 +9,15 @@ CFastLED & FastSPI_LED = LEDS; CFastLED & FastSPI_LED2 = LEDS; CFastLED & FastLED = LEDS; -uint32_t CRGB::Squant = ((uint32_t)((__TIME__[4]-'0') * 28))<<16 | ((__TIME__[6]-'0')*50)<<8 | ((__TIME__[7]-'0')*28); +CLEDController *CLEDController::m_pHead = NULL; +CLEDController *CLEDController::m_pTail = NULL; + +// uint32_t CRGB::Squant = ((uint32_t)((__TIME__[4]-'0') * 28))<<16 | ((__TIME__[6]-'0')*50)<<8 | ((__TIME__[7]-'0')*28); CFastLED::CFastLED() { // clear out the array of led controllers - m_nControllers = NUM_CONTROLLERS; + // m_nControllers = 0; m_Scale = 255; - memset8(m_Controllers, 0, m_nControllers * sizeof(CControllerInfo)); } CLEDController &CFastLED::addLeds(CLEDController *pLed, @@ -24,46 +26,24 @@ CLEDController &CFastLED::addLeds(CLEDController *pLed, int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0; int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset; - int target = -1; - - // Figure out where to put the new led controller - for(int i = 0; i < m_nControllers; i++) { - if(m_Controllers[i].pLedController == NULL) { - target = i; - break; - } - } - - // if we have a spot, use it! - if(target != -1) { - m_Controllers[target].pLedController = pLed; - m_Controllers[target].pLedData = data; - m_Controllers[target].nOffset = nOffset; - m_Controllers[target].nLeds = nLeds; - pLed->init(); - } - + pLed->init(); + pLed->setLeds(data + nOffset, nLeds); return *pLed; } void CFastLED::show(uint8_t scale) { - for(int i = 0; i < m_nControllers; i++) { - if(m_Controllers[i].pLedController != NULL) { - m_Controllers[i].pLedController->show(m_Controllers[i].pLedData + m_Controllers[i].nOffset, - m_Controllers[i].nLeds, scale); - } else { - return; - } + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->showLeds(scale); + pCur = pCur->next(); } } void CFastLED::showColor(const struct CRGB & color, uint8_t scale) { - for(int i = 0; i < m_nControllers; i++) { - if(m_Controllers[i].pLedController != NULL) { - m_Controllers[i].pLedController->showColor(color, m_Controllers[i].nLeds, scale); - } else { - return; - } + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->showColor(color, scale); + pCur = pCur->next(); } } @@ -71,20 +51,18 @@ void CFastLED::clear(boolean writeData) { if(writeData) { showColor(CRGB(0,0,0), 0); } - clearData(); + clearData(); } void CFastLED::clearData() { - for(int i = 0; i < m_nControllers; i++) { - if(m_Controllers[i].pLedData != NULL) { - memset8((void*)m_Controllers[i].pLedData, 0, sizeof(struct CRGB) * m_Controllers[i].nLeds); - } else { - return; - } + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->clearLedData(); + pCur = pCur->next(); } } void CFastLED::delay(unsigned long ms) { unsigned long start = millis(); - while((millis()-start) < ms) { LEDS.show(); } + while((millis()-start) < ms) { show(); } } @@ -18,22 +18,41 @@ enum ESPIChipsets { }; enum EClocklessChipsets { - DMX, - TM1809, - TM1804, - TM1803, - WS2811, - WS2812, - WS2812B, - UCS1903, - UCS1903B, - WS2811_400, - NEOPIXEL, - GW6205, - GW6205_400, - TM1829 + DMX + // TM1809, + // TM1804, + // TM1803, + // WS2811, + // WS2812, + // WS2812B, + // UCS1903, + // UCS1903B, + // WS2811_400, + // // NEOPIXEL, + // GW6205, + // GW6205_400, + // TM1829 }; +template<uint8_t DATA_PIN> class NEOPIXEL : public WS2811Controller800Khz<DATA_PIN, GRB> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class WS2812 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class WS2812B : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {}; +template<uint8_t DATA_PIN, EOrder RGB_ORDER> class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {}; + +// template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(20)> class LPD8806 : public LPD8806Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {}; +// template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(1)> class WS2801 : public WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {}; +// template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(15)> class P9813 : public P9813Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {}; +// template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint8_t SPI_SPEED = DATA_RATE_MHZ(16)> class SM16716 : public SM16716Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {}; + enum EBlockChipsets { WS2811_PORTC }; @@ -45,23 +64,15 @@ enum EBlockChipsets { #endif class CFastLED { - struct CControllerInfo { - CLEDController *pLedController; - const struct CRGB *pLedData; - int nLeds; - int nOffset; - }; - - CControllerInfo m_Controllers[NUM_CONTROLLERS]; - int m_nControllers; + // int m_nControllers; uint8_t m_Scale; public: CFastLED(); - CLEDController &addLeds(CLEDController *pLed, const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0); + static CLEDController &addLeds(CLEDController *pLed, const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0); - template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { 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); } @@ -69,7 +80,7 @@ public: } } - template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER > CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER > static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { 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); } @@ -88,67 +99,59 @@ public: } #ifdef SPI_DATA - template<ESPIChipsets CHIPSET> CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + template<ESPIChipsets CHIPSET> static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset); } - template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset); } - template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE> CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE> static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset); } #endif + template<template<uint8_t DATA_PIN> class CHIPSET, uint8_t DATA_PIN> + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET<DATA_PIN> c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER> + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET<DATA_PIN, RGB_ORDER> c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN> + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET<DATA_PIN, RGB> c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + +#ifdef FASTSPI_USE_DMX_SIMPLE template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN> - CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { switch(CHIPSET) { -#ifdef FASTSPI_USE_DMX_SIMPLE case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } -#endif - case TM1829: { static TM1829Controller800Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case TM1804: - case TM1809: { static TM1809Controller800Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case TM1803: { static TM1803Controller400Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case UCS1903: { static UCS1903Controller400Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case UCS1903B: { static UCS1903BController800Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case WS2812: - case WS2812B: - case WS2811: { static WS2811Controller800Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case NEOPIXEL: { static WS2811Controller800Khz<DATA_PIN, GRB> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case WS2811_400: { static WS2811Controller400Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case GW6205: { static GW6205Controller800Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case GW6205_400: { static GW6205Controller400Khz<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } } } template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER> - CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { -#ifdef FASTSPI_USE_DMX_SIMPLE case DMX: {static DMXController<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } -#endif - case TM1829: { static TM1829Controller800Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case TM1804: - case TM1809: { static TM1809Controller800Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case TM1803: { static TM1803Controller400Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case UCS1903: { static UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case UCS1903B: { static UCS1903BController800Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case WS2812: - case WS2812B: - case NEOPIXEL: - case WS2811: { static WS2811Controller800Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case WS2811_400: { static WS2811Controller400Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case GW6205: { static GW6205Controller800Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } - case GW6205_400: { static GW6205Controller400Khz<DATA_PIN, RGB_ORDER> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } } } +#endif #ifdef HAS_BLOCKLESS template<EBlockChipsets CHIPSET, int NUM_LANES> - CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CLEDController &addLeds(const struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { switch(CHIPSET) { case WS2811_PORTC: return addLeds(new BlockClocklessController<NUM_LANES, NS(350), NS(350), NS(550)>(), data, nLedsOrOffset, nLedsIfOffset); } diff --git a/block_clockless.h b/block_clockless.h index 350e0d65..d561239c 100644 --- a/block_clockless.h +++ b/block_clockless.h @@ -90,7 +90,7 @@ public: // showRGBInternal<0, false>(nLeds, scale, (const byte*)&data); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); savedClock.restore(); sei(); @@ -107,7 +107,7 @@ public: showRGBInternal<0, true>(nLeds); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); savedClock.restore(); sei(); @@ -125,7 +125,7 @@ public: showRGBInternal<1, true>(nLeds, scale, (const byte*)rgbdata); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); savedClock.restore(); sei(); diff --git a/clockless2.h b/clockless2.h index 68e6477a..c48cde5d 100644 --- a/clockless2.h +++ b/clockless2.h @@ -48,7 +48,7 @@ public: showRGBInternal<0, false>(nLeds, scale, (const byte*)&data, (const byte*)&data); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); @@ -61,7 +61,7 @@ public: showRGBInternal<0, true>(nLeds, scale, (const byte*)rgbdata, (const byte*)rgbdata); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); @@ -74,7 +74,7 @@ public: showRGBInternal<0, true>(nLeds, scale, (const byte*)rgbdata, (const byte*)rgbdata2 ); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); @@ -88,7 +88,7 @@ public: showRGBInternal<1, true>(nLeds, scale, (const byte*)rgbdata); // Adjust the timer - long microsTaken = CLKS_TO_MICROS(nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); diff --git a/clockless_arm_k20.h b/clockless_arm_k20.h index 2ab6d27a..59905d45 100644 --- a/clockless_arm_k20.h +++ b/clockless_arm_k20.h @@ -31,7 +31,7 @@ public: showRGBInternal(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); @@ -44,7 +44,7 @@ public: showRGBInternal(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); @@ -59,7 +59,7 @@ public: // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); MS_COUNTER += (microsTaken / 1000); sei(); mWait.mark(); diff --git a/clockless_arm_sam.h b/clockless_arm_sam.h index c7781970..3d0f9264 100644 --- a/clockless_arm_sam.h +++ b/clockless_arm_sam.h @@ -43,7 +43,7 @@ public: showRGBInternal(PixelController<RGB_ORDER>(data, nLeds, scale, getDither())); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (TOTAL)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (TOTAL)); long millisTaken = (microsTaken / 1000); savedClock.restore(); do { TimeTick_Increment(); } while(--millisTaken > 0); @@ -64,7 +64,7 @@ public: showRGBInternal(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (TOTAL)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (TOTAL)); long millisTaken = (microsTaken / 1000); savedClock.restore(); do { TimeTick_Increment(); } while(--millisTaken > 0); @@ -81,7 +81,7 @@ public: showRGBInternal(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (TOTAL)); + long microsTaken = nLeds * CLKS_TO_MICROS(24 * (TOTAL)); long millisTaken = (microsTaken / 1000); savedClock.restore(); do { TimeTick_Increment(); } while(--millisTaken > 0); diff --git a/clockless_avr.h b/clockless_avr.h deleted file mode 100644 index 887188b3..00000000 --- a/clockless_avr.h +++ /dev/null @@ -1,201 +0,0 @@ -#ifndef __CLOCKLESS_AVR_H -#define __CLOCKLESS_AVR_H - -#ifdef FASTLED_AVR - -// Definition for a single channel clockless controller for the avr family of chips, like those used in -// the arduino and teensy 2.x. Note that there is a special case for hardware-mul-less versions of the avr, -// which are tracked in clockless_trinket.h -template <uint8_t DATA_PIN, int T1, int T2, int T3, EOrder RGB_ORDER = RGB, int XTRA0 = 0, bool FLIP = false, int WAIT_TIME = 50> -class ClocklessController : public CLEDController { - typedef typename FastPin<DATA_PIN>::port_ptr_t data_ptr_t; - typedef typename FastPin<DATA_PIN>::port_t data_t; - - data_t mPinMask; - data_ptr_t mPort; - CMinWait<WAIT_TIME> mWait; -public: - virtual void init() { - FastPin<DATA_PIN>::setOutput(); - mPinMask = FastPin<DATA_PIN>::mask(); - mPort = FastPin<DATA_PIN>::port(); - } - - template <int N, int ADJ>inline static void bitSetLast(register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t b) { - // First cycle - SET_HI; // 1 clock cycle if using out, 2 otherwise - delaycycles<T1 - (AVR_PIN_CYCLES(DATA_PIN) + 1)>(); // 1st cycle length minus 1 clock for out, 1 clock for sbrs - __asm__ __volatile__ ("sbrs %0, %1" :: "r" (b), "M" (N) :); // 1 clock for check (+1 if skipping, next op is also 1 clock) - - // Second cycle - SET_LO; // 1/2 clock cycle if using out - delaycycles<T2 - AVR_PIN_CYCLES(DATA_PIN)>(); // 2nd cycle length minus 1/2 clock for out - - // Third cycle - SET_LO; // 1/2 clock cycle if using out - delaycycles<T3 - (AVR_PIN_CYCLES(DATA_PIN) + ADJ)>(); // 3rd cycle length minus 7 clocks for out, loop compare, jump, next uint8_t load - } - - virtual void clearLeds(int nLeds) { - showColor(CRGB(0, 0, 0), nLeds, 0); - } - - // set all the leds on the controller to a given color - virtual void showColor(const struct CRGB & data, int nLeds, uint8_t scale = 255) { - mWait.wait(); - cli(); - - showRGBInternal<0, false>(nLeds, scale, (const byte*)&data); - - // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); - sei(); - mWait.mark(); - } - - virtual void show(const struct CRGB *rgbdata, int nLeds, uint8_t scale = 255) { - mWait.wait(); - cli(); - - showRGBInternal<0, true>(nLeds, scale, (const byte*)rgbdata); - - // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); - sei(); - mWait.mark(); - } - -#ifdef SUPPORT_ARGB - virtual void show(const struct CARGB *rgbdata, int nLeds, uint8_t scale = 255) { - mWait.wait(); - cli(); - - showRGBInternal<1, true>((long)nLeds, scale, (const byte*)rgbdata); - - // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)nLeds * 8 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); - sei(); - mWait.mark(); - } -#endif - - // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then - // gcc will use register Y for the this pointer. - template<int SKIP, bool ADVANCE> static void showRGBInternal(register int nLeds, register uint8_t scale, register const byte *rgbdata) { - register byte *data = (byte*)rgbdata; - register data_ptr_t port = FastPin<DATA_PIN>::port(); - nLeds *= (3 + SKIP); - register uint8_t *end = data + nLeds; - register data_t hi = FastPin<DATA_PIN>::hival(); - register data_t lo = FastPin<DATA_PIN>::loval();; - *port = lo; - - register uint8_t b; - - if(ADVANCE) { - b = data[SKIP + RGB_BYTE0(RGB_ORDER)]; - } else { - b = rgbdata[SKIP + RGB_BYTE0(RGB_ORDER)]; - } - b = scale8_LEAVING_R1_DIRTY(b, scale); - - register uint8_t c; - register uint8_t d; - while(data < end) { - for(register byte x=5; x; x--) { - bitSetLast<7, 4>(port, hi, lo, b); - b <<= 1; - } - delaycycles<1>(); - // Leave an extra 2 clocks for the next byte load - bitSetLast<7, 1>(port, hi, lo, b); - delaycycles<1>(); - - // Leave an extra 4 clocks for the scale - bitSetLast<6, 6>(port, hi, lo, b); - if(ADVANCE) { - c = data[SKIP + RGB_BYTE1(RGB_ORDER)]; - } else { - c = rgbdata[SKIP + RGB_BYTE1(RGB_ORDER)]; - delaycycles<1>(); - } - INLINE_SCALE(c, scale); - bitSetLast<5, 1>(port, hi, lo, b); - - if(XTRA0 > 0) { - for(register byte x=XTRA0; x; x--) { - bitSetLast<4,4>(port, hi, lo, b); - b <<=1; - } - delaycycles<1>(); - } - - for(register byte x=5; x; x--) { - bitSetLast<7, 4>(port, hi, lo, c); - c <<= 1; - } - delaycycles<1>(); - // Leave an extra 2 clocks for the next byte load - bitSetLast<7, 1>(port, hi, lo, c); - delaycycles<1>(); - - // Leave an extra 4 clocks for the scale - bitSetLast<6, 6>(port, hi, lo, c); - if(ADVANCE) { - d = data[SKIP + RGB_BYTE2(RGB_ORDER)]; - } else { - d = rgbdata[SKIP + RGB_BYTE2(RGB_ORDER)]; - delaycycles<1>(); - } - INLINE_SCALE(d, scale); - bitSetLast<5, 1>(port, hi, lo, c); - - if(XTRA0 > 0) { - for(register byte x=XTRA0; x; x--) { - bitSetLast<4,4>(port, hi, lo, c); - c <<=1; - } - delaycycles<1>(); - } - - for(register byte x=5; x; x--) { - bitSetLast<7, 4>(port, hi, lo, c); - c <<= 1; - } - delaycycles<1>(); - // Leave an extra 2 clocks for the next byte load - bitSetLast<7, 2>(port, hi, lo, d); - data += (SKIP + 3); - // Leave an extra 4 clocks for the scale - bitSetLast<6, 6>(port, hi, lo, d); - if(ADVANCE) { - b = data[SKIP + RGB_BYTE0(RGB_ORDER)]; - } else { - b = rgbdata[SKIP + RGB_BYTE0(RGB_ORDER)]; - delaycycles<1>(); - } - INLINE_SCALE(b, scale); - - if(XTRA0 > 0) { - bitSetLast<5, 1>(port, hi, lo, d); - for(register byte x=XTRA0-1; x; x--) { - bitSetLast<4,4>(port, hi, lo, d); - d <<=1; - } - delaycycles<1>(); - bitSetLast<4,6>(port,hi,lo,d); - } else { - bitSetLast<5,6>(port, hi, lo, d); - } - - } - cleanup_R1(); - } -}; -#endif - -#endif - diff --git a/clockless_trinket.h b/clockless_trinket.h index dea96997..83cd2e84 100644 --- a/clockless_trinket.h +++ b/clockless_trinket.h @@ -68,37 +68,38 @@ public: } virtual void clearLeds(int nLeds) { - static CRGB zeros(0,0,0); - showRGBInternal_AdjTime(PixelController<RGB_ORDER>(zeros, nLeds, zeros, getDither())); + CRGB zeros(0,0,0); + showAdjTime((uint8_t*)&zeros, nLeds, zeros, false, 0); } // set all the leds on the controller to a given color virtual void showColor(const struct CRGB & rgbdata, int nLeds, CRGB scale) { - showRGBInternal_AdjTime(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); + showAdjTime((uint8_t*)&rgbdata, nLeds, scale, false, 0); } virtual void show(const struct CRGB *rgbdata, int nLeds, CRGB scale) { - showRGBInternal_AdjTime(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); + showAdjTime((uint8_t*)rgbdata, nLeds, scale, true, 0); } #ifdef SUPPORT_ARGB virtual void show(const struct CARGB *rgbdata, int nLeds, CRGB scale) { - showRGBInternal_AdjTime(PixelController<RGB_ORDER>(rgbdata, nLeds, scale, getDither())); + showAdjTime((uint8_t*)rgbdata, nLeds, scale, true, 1); } #endif - void __attribute__ ((noinline)) showRGBInternal_AdjTime(PixelController<RGB_ORDER> pixels) { + void showAdjTime(const uint8_t *data, int nLeds, CRGB & scale, bool advance, int skip) { mWait.wait(); cli(); + + PixelController<RGB_ORDER> pixels(data, nLeds, scale, getDither(), advance, skip); showRGBInternal(pixels); // Adjust the timer - long microsTaken = CLKS_TO_MICROS((long)pixels.mLen * 24 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); + uint16_t microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3)); + MS_COUNTER += (microsTaken >> 10); sei(); mWait.mark(); } - #define USE_ASM_MACROS // The variables that our various asm statemetns use. The same block of variables needs to be declared for @@ -109,11 +110,11 @@ public: [b0] "+a" (b0), \ [b1] "+a" (b1), \ [b2] "+a" (b2), \ + [scale_base] "+a" (scale_base), \ + [loopvar] "+a" (loopvar), \ [d0] "+r" (d0), \ [d1] "+r" (d1), \ - [d2] "+r" (d2), \ - [scale_base] "+a" (scale_base), \ - [loopvar] "+a" (loopvar) \ + [d2] "+r" (d2) \ : /* use variables */ \ [ADV] "r" (advanceBy), \ [hi] "r" (hi), \ @@ -202,11 +203,12 @@ public: // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then // gcc will use register Y for the this pointer. - static void __attribute__ ((noinline)) showRGBInternal(PixelController<RGB_ORDER> & pixels) { + static void __attribute__ ((always_inline)) showRGBInternal(PixelController<RGB_ORDER> & pixels) { uint8_t *data = (uint8_t*)pixels.mData; - - data_t mask = FastPin<DATA_PIN>::mask(); data_ptr_t port = FastPin<DATA_PIN>::port(); + data_t mask = FastPin<DATA_PIN>::mask(); + uint8_t scale_base = 0; + // register uint8_t *end = data + nLeds; data_t hi = *port | mask; data_t lo = *port & ~mask; @@ -221,7 +223,6 @@ public: b0 = pixels.loadAndScale0(); // pull the dithering/adjustment values out of the pixels object for direct asm access - uint8_t scale_base = 0; uint8_t advanceBy = pixels.advanceBy(); uint16_t count = pixels.mLen; @@ -247,7 +248,7 @@ public: ADJDITHER2(d0,e0); ADJDITHER2(d1,e1); ADJDITHER2(d2,e2); - CLC1; + // Sum of the clock counts across each row should be 10 for 8Mhz, WS2811 // The values in the D1/D2/D3 indicate how many cycles the previous column takes // to allow things to line back up. diff --git a/controller.h b/controller.h index 1156f9e9..ee2e6d62 100644 --- a/controller.h +++ b/controller.h @@ -14,10 +14,9 @@ // operator byte *(struct CRGB[] arr) { return (byte*)arr; } -enum EDitherMode { - DISABLE = 0x00, - BINARY_DITHER = 0x01 -}; +#define DISABLE_DITHER 0x00 +#define BINARY_DITHER 0x01 +typedef uint8_t EDitherMode; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -32,9 +31,15 @@ enum EDitherMode { /// directly at all class CLEDController { protected: + friend class CFastLED; + const CRGB *m_Data; + CLEDController *m_pNext; CRGB m_ColorCorrection; CRGB m_ColorTemperature; EDitherMode m_DitherMode; + int m_nLeds; + static CLEDController *m_pHead; + static CLEDController *m_pTail; // set all the leds on the controller to a given color virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) = 0; @@ -48,23 +53,19 @@ protected: virtual void show(const struct CARGB *data, int nLeds, CRGB scale) = 0; #endif public: - CLEDController() : m_ColorCorrection(UncorrectedColor), m_ColorTemperature(UncorrectedTemperature) {} + CLEDController() : m_Data(NULL), m_ColorCorrection(UncorrectedColor), m_ColorTemperature(UncorrectedTemperature), m_DitherMode(BINARY_DITHER), m_nLeds(0) { + m_pNext = NULL; + if(m_pHead==NULL) { m_pHead = this; } + if(m_pTail != NULL) { m_pTail->m_pNext = this; } + m_pTail = this; + } // initialize the LED controller virtual void init() = 0; - // reset any internal state to a clean point - virtual void reset() { init(); } - // clear out/zero out the given number of leds. virtual void clearLeds(int nLeds) = 0; - // is the controller ready to write data out - virtual bool ready() { return true; } - - // wait until the controller is ready to write data out - virtual void wait() { return; } - // show function w/integer brightness, will scale for color correction and temperature void show(const struct CRGB *data, int nLeds, uint8_t brightness) { show(data, nLeds, getAdjustment(brightness)); @@ -75,6 +76,19 @@ public: showColor(data, nLeds, getAdjustment(brightness)); } + // show function using the "attached to this controller" led data + void showLeds(uint8_t brightness=255) { + show(m_Data, m_nLeds, getAdjustment(brightness)); + } + + void showColor(const struct CRGB & data, uint8_t brightness=255) { + showColor(data, m_nLeds, getAdjustment(brightness)); + } + + // navigating the list of controllers + static CLEDController *head() { return m_pHead; } + CLEDController *next() { return m_pNext; } + #ifdef SUPPORT_ARGB // as above, but every 4th uint8_t is assumed to be alpha channel data, and will be skipped void show(const struct CARGB *data, int nLeds, uint8_t brightness) { @@ -82,8 +96,20 @@ public: } #endif - inline CLEDController & setDither(EDitherMode = BINARY_DITHER) { m_DitherMode = BINARY_DITHER; return *this; } - inline EDitherMode getDither() { return m_DitherMode; } + CLEDController & setLeds(const CRGB *data, int nLeds) { + m_Data = data; + m_nLeds = nLeds; + return *this; + } + + void clearLedData() { + if(m_Data) { + memset8((void*)m_Data, 0, sizeof(struct CRGB) * m_nLeds); + } + } + + inline CLEDController & setDither(uint8_t ditherMode = BINARY_DITHER) { m_DitherMode = ditherMode; return *this; } + inline uint8_t getDither() { return m_DitherMode; } CLEDController & setCorrection(CRGB correction) { m_ColorCorrection = correction; return *this; } CLEDController & setCorrection(LEDColorCorrection correction) { m_ColorCorrection = correction; return *this; } @@ -94,46 +120,23 @@ public: CRGB getTemperature() { return m_ColorTemperature; } CRGB getAdjustment(uint8_t scale) { - // if(1) return scale; - uint32_t r = 0; - uint32_t g = 0; - uint32_t b = 0; - - if(m_ColorCorrection.r > 0 && m_ColorTemperature.r > 0 && scale > 0) { - r = ((uint32_t)m_ColorCorrection.r+1) * ((uint32_t)m_ColorTemperature.r+1) * scale; - r /= 0x10000L; - } - if(m_ColorCorrection.g > 0 && m_ColorTemperature.g > 0 && scale > 0) { - g = ((uint32_t)m_ColorCorrection.g+1) * ((uint32_t)m_ColorTemperature.g+1) * scale; - g /= 0x10000L; + // if(1) return CRGB(scale,scale,scale); + CRGB adj(0,0,0); + + if(scale > 0) { + for(uint8_t i = 0; i < 3; i++) { + uint8_t cc = m_ColorCorrection.raw[i]; + uint8_t ct = m_ColorTemperature.raw[i]; + if(cc > 0 && ct > 0) { + uint32_t work = (((uint32_t)cc)+1) * (((uint32_t)ct)+1) * scale; + work /= 0x10000L; + adj.raw[i] = work & 0xFF; + } + } } - if(m_ColorCorrection.b > 0 && m_ColorTemperature.b > 0 && scale > 0) { - b = ((uint32_t)m_ColorCorrection.b+1) * ((uint32_t)m_ColorTemperature.b+1) * scale; - b /= 0x10000L; - } - - // static int done = 0; - // if(!done) { - // done = 1; - // Serial.print("Correction: "); - // Serial.print(m_ColorCorrection.r); Serial.print(" "); - // Serial.print(m_ColorCorrection.g); Serial.print(" "); - // Serial.print(m_ColorCorrection.b); Serial.println(" "); - // Serial.print("Temperature: "); - // Serial.print(m_ColorTemperature.r); Serial.print(" "); - // Serial.print(m_ColorTemperature.g); Serial.print(" "); - // Serial.print(m_ColorTemperature.b); Serial.println(" "); - // Serial.print("Scale: "); - // Serial.print(scale.r); Serial.print(" "); - // Serial.print(scale.g); Serial.print(" "); - // Serial.print(scale.b); Serial.println(" "); - // Serial.print("Combined: "); - // Serial.print(r); Serial.print(" "); Serial.print(g); Serial.print(" "); Serial.print(b); Serial.println(); - // } - return CRGB(r,g,b); + return adj; } - }; // Pixel controller class. This is the class that we use to centralize pixel access in a block of data, including @@ -141,12 +144,12 @@ public: // centralize 8/12/16 conversions here as well. template<EOrder RGB_ORDER> struct PixelController { + const uint8_t *mData; + int mLen; uint8_t d[3]; uint8_t e[3]; - const uint8_t *mData; CRGB mScale; uint8_t mAdvance; - int mLen; PixelController(const PixelController & other) { d[0] = other.d[0]; @@ -161,25 +164,31 @@ struct PixelController { mLen = other.mLen; } - PixelController(const CRGB *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)d), mScale(s), mLen(len) { + PixelController(const uint8_t *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER, bool advance=true, uint8_t skip=0) : mData(d), mLen(len), mScale(s) { + enable_dithering(dither); + mData += skip; + mAdvance = (advance) ? 3+skip : 0; + } + + PixelController(const CRGB *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)d), mLen(len), mScale(s) { enable_dithering(dither); mAdvance = 3; } - PixelController(const CRGB &d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)&d), mScale(s), mLen(len) { + PixelController(const CRGB &d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)&d), mLen(len), mScale(s) { enable_dithering(dither); mAdvance = 0; } #ifdef SUPPORT_ARGB - PixelController(const CARGB &d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)&d), mScale(s), mLen(len) { + PixelController(const CARGB &d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)&d), mLen(len), mScale(s) { enable_dithering(dither); // skip the A in CARGB mData += 1; mAdvance = 0; } - PixelController(const CARGB *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)d), mScale(s), mLen(len) { + PixelController(const CARGB *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)d), mLen(len), mScale(s) { enable_dithering(dither); // skip the A in CARGB mData += 1; @@ -1,6 +1,24 @@ #ifndef __INC_DELAY_H #define __INC_DELAY_H +// Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet +// this should make sure that chipsets that have +template<int WAIT> class CMinWait { + uint16_t mLastMicros; +public: + CMinWait() { mLastMicros = 0; } + + void wait() { + uint16_t diff; + do { + diff = (micros() & 0xFFFF) - mLastMicros; + } while(diff < WAIT); + } + + void mark() { mLastMicros = micros() & 0xFFFF; } +}; + + //////////////////////////////////////////////////////////////////////////////////////////// // // Clock cycle counted delay loop @@ -85,7 +103,7 @@ template<> __attribute__((always_inline)) inline void delaycycles<5>() {NOP2;NOP // #define NS(_NS) (_NS / (1000 / (F_CPU / 1000000L))) #if 1 || (F_CPU < 96000000) #define NS(_NS) ( (_NS * (F_CPU / 1000000L))) / 1000 -#define CLKS_TO_MICROS(_CLKS) ((long)(_CLKS)) / (F_CPU / 1000000L) +#define CLKS_TO_MICROS(_CLKS) ((_CLKS)) / (F_CPU / 1000000L) #else #define NS(_NS) ( (_NS * (F_CPU / 2000000L))) / 1000 #define CLKS_TO_MICROS(_CLKS) ((long)(_CLKS)) / (F_CPU / 2000000L) @@ -11,9 +11,6 @@ public: // initialize the LED controller virtual void init() { DmxSimple.usePin(DATA_PIN); } - // reset any internal state to a clean point - virtual void reset() { init(); } - // clear out/zero out the given number of leds. virtual void clearLeds(int nLeds) { int count = min(nLeds * 3, DMX_SIZE); @@ -48,13 +45,6 @@ public: // as above, but every 4th uint8_t is assumed to be alpha channel data, and will be skipped virtual void show(const struct CARGB *data, int nLeds, uint8_t scale = 255) = 0; #endif - - // is the controller ready to write data out - virtual bool ready() { return true; } - - // wait until the controller is ready to write data out - virtual void wait() { return; } - }; #elif defined(FASTSPI_USE_DMX_SERIAL) @@ -64,9 +54,6 @@ public: // initialize the LED controller virtual void init() { DMXSerial.init(DMXController); } - // reset any internal state to a clean point - virtual void reset() { init(); } - // clear out/zero out the given number of leds. virtual void clearLeds(int nLeds) { int count = min(nLeds * 3, DMX_SIZE); @@ -101,13 +88,6 @@ public: // as above, but every 4th uint8_t is assumed to be alpha channel data, and will be skipped virtual void show(const struct CARGB *data, int nLeds, uint8_t scale = 255) = 0; #endif - - // is the controller ready to write data out - virtual bool ready() { return true; } - - // wait until the controller is ready to write data out - virtual void wait() { return; } - }; #endif diff --git a/examples/Cylon/Cylon.ino b/examples/Cylon/Cylon.ino index 443b84d6..dfb6ed78 100644 --- a/examples/Cylon/Cylon.ino +++ b/examples/Cylon/Cylon.ino @@ -6,7 +6,7 @@ // For led chips like Neopixels, which have a data line, ground, and power, you just // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, // ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN -#define DATA_PIN 2 +#define DATA_PIN 6 #define CLOCK_PIN 13 // Define the array of leds @@ -26,7 +26,7 @@ void loop() { // now that we've shown the leds, reset the i'th led to black leds[i] = CRGB::Black; // Wait a little bit before we loop around and do it again - delay(300); + delay(30); } // Now go in the other direction. @@ -38,6 +38,6 @@ void loop() { // now that we've shown the leds, reset the i'th led to black leds[i] = CRGB::Black; // Wait a little bit before we loop around and do it again - delay(300); + delay(30); } } @@ -5,23 +5,6 @@ #define NO_PIN 255 -// Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet -// this should make sure that chipsets that have -template<int WAIT> class CMinWait { - long mLastMicros; -public: - CMinWait() { mLastMicros = 0; } - - void wait() { - long diff = micros() - mLastMicros; - if(diff > 0 && diff < WAIT) { - delayMicroseconds(WAIT - diff); - } - } - - void mark() { mLastMicros = micros(); } -}; - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Pin access class - needs to tune for various platforms (naive fallback solution?) diff --git a/pixeltypes.h b/pixeltypes.h index 67689b12..663c37bd 100644 --- a/pixeltypes.h +++ b/pixeltypes.h @@ -560,7 +560,7 @@ struct CRGB { Yellow=0xFFFF00, YellowGreen=0x9ACD32 } HTMLColorCode; - static uint32_t Squant; + // static uint32_t Squant; }; |