From ece5e1bcf147fd812c8c29898813d3f0341eae88 Mon Sep 17 00:00:00 2001 From: "danielgarcia@gmail.com" Date: Fri, 1 Nov 2013 19:11:59 +0000 Subject: Make inline scaling for clockless chipsets work on ATTiny --- clockless.h | 20 ++++++++++++++------ preview_changes.txt | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/clockless.h b/clockless.h index 26ff8262..55a88f10 100644 --- a/clockless.h +++ b/clockless.h @@ -31,6 +31,14 @@ # endif #endif +// Scaling macro choice +#if defined(LIB8_ATTINY) +# define INLINE_SCALE(B, SCALE) delaycycles<3> +# warning "No hardware multiply, inline brightness scaling disabled" +#else +# define INLINE_SCALE(B, SCALE) B = scale8_LEAVING_R1_DIRTY(B, SCALE) +#endif + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Base template for clockless controllers. These controllers have 3 control points in their cycle for each bit. The first point @@ -181,14 +189,14 @@ public: write8Bits(port, hi, lo, b); b = ((ADVANCE)?data:rgbdata)[SKIP + RGB_BYTE1(RGB_ORDER)]; - b = scale8(b, scale); + INLINE_SCALE(b, scale); delaycycles(); // 1 store, 2 load, 1 mul, 1 shift, // Write second byte write8Bits(port, hi, lo, b); b = ((ADVANCE)?data:rgbdata)[SKIP + RGB_BYTE2(RGB_ORDER)]; - b = scale8(b, scale); + INLINE_SCALE(b, scale); data += 3 + SKIP; if((RGB_ORDER & 0070) == 0) { @@ -201,7 +209,7 @@ public: write8Bits(port, hi, lo, b); b = ((ADVANCE)?data:rgbdata)[SKIP + RGB_BYTE0(RGB_ORDER)]; - b = scale8(b, scale); + INLINE_SCALE(b, scale); delaycycles(); // 1 store, 2 load (with increment), 1 mul, 1 shift, 1 cmp, 1 branch backwards, 1 movim }; @@ -253,7 +261,7 @@ public: c = rgbdata[SKIP + RGB_BYTE1(RGB_ORDER)]; delaycycles<1>(); } - c = scale8_LEAVING_R1_DIRTY(c, scale); + INLINE_SCALE(c, scale); bitSetLast<5, 1>(port, hi, lo, b); for(register byte x=5; x; x--) { @@ -273,7 +281,7 @@ public: d = rgbdata[SKIP + RGB_BYTE2(RGB_ORDER)]; delaycycles<1>(); } - d = scale8_LEAVING_R1_DIRTY(d, scale); + INLINE_SCALE(d, scale); bitSetLast<5, 1>(port, hi, lo, c); for(register byte x=5; x; x--) { @@ -292,7 +300,7 @@ public: b = rgbdata[SKIP + RGB_BYTE0(RGB_ORDER)]; delaycycles<1>(); } - b = scale8_LEAVING_R1_DIRTY(b, scale); + INLINE_SCALE(b, scale); bitSetLast<5, 6>(port, hi, lo, d); } cleanup_R1(); diff --git a/preview_changes.txt b/preview_changes.txt index f46c99f8..5ef705cf 100644 --- a/preview_changes.txt +++ b/preview_changes.txt @@ -1,5 +1,6 @@ Post-Release Candidate 4 * Gemma and Trinket: HSV2RGB works, LED drivers not yet +* Update LED drivers to punt on inline scaling on gemma/trinket Release Candidate 4 * Added NEOPIXEL as a synonym for WS2811 -- cgit v1.2.3