diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2013-12-04 08:02:49 +0400 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2013-12-04 08:02:49 +0400 |
commit | d989d5da755c60e6f43d65b108180c07e651188e (patch) | |
tree | 4cf882ea2b44eb256e22ca9097c67fd1c71ee285 | |
parent | 3d7fe8c7015b41746d4b5ea774663cc4af5129ac (diff) |
Reduce code size even further
-rw-r--r-- | clockless_trinket.h | 38 | ||||
-rw-r--r-- | fastpin.h | 4 |
2 files changed, 13 insertions, 29 deletions
diff --git a/clockless_trinket.h b/clockless_trinket.h index 6fa6ddb8..168ba670 100644 --- a/clockless_trinket.h +++ b/clockless_trinket.h @@ -45,53 +45,38 @@ class ClocklessController_Trinket : 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(); } virtual void clearLeds(int nLeds) { - showColor(CRGB(0, 0, 0), nLeds, 0); + static byte zeros[3] = {0,0,0}; + showRGBInternal_AdjTime(0, false, nLeds, 0, zeros); } // 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 * 24 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); - sei(); - mWait.mark(); + showRGBInternal_AdjTime(0, false, nLeds, scale, (const byte*)&data); } 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 * 24 * (T1 + T2 + T3)); - MS_COUNTER += (microsTaken / 1000); - sei(); - mWait.mark(); + showRGBInternal_AdjTime(0, true, nLeds, scale, (const byte*)rgbdata); } #ifdef SUPPORT_ARGB virtual void show(const struct CARGB *rgbdata, int nLeds, uint8_t scale = 255) { + showRGBInternal_AdjTime(1, true, nLeds, scale, (const byte*)rgbdata); + } +#endif + + void __attribute__ ((noinline)) showRGBInternal_AdjTime(int skip, bool advance, int nLeds, uint8_t scale, const byte *rgbdata) { mWait.wait(); cli(); - showRGBInternal<1, true>(nLeds, scale, (const byte*)rgbdata); + showRGBInternal(skip, advance, nLeds, scale, rgbdata); + // Adjust the timer long microsTaken = CLKS_TO_MICROS((long)nLeds * 24 * (T1 + T2 + T3)); @@ -99,7 +84,6 @@ public: sei(); mWait.mark(); } -#endif #define USE_ASM_MACROS @@ -17,8 +17,8 @@ public: void wait() { long diff = micros() - mLastMicros; - if(diff < WAIT) { - delayMicroseconds(WAIT - diff); + while(diff < WAIT) { + diff = micros() - mLastMicros; } } |