From d989d5da755c60e6f43d65b108180c07e651188e Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Tue, 3 Dec 2013 20:02:49 -0800 Subject: Reduce code size even further --- clockless_trinket.h | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'clockless_trinket.h') 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::port_ptr_t data_ptr_t; typedef typename FastPin::port_t data_t; - data_t mPinMask; - data_ptr_t mPort; CMinWait mWait; public: virtual void init() { FastPin::setOutput(); - mPinMask = FastPin::mask(); - mPort = FastPin::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 -- cgit v1.2.3