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:
authorDaniel Garcia <danielgarcia@gmail.com>2014-03-17 00:28:09 +0400
committerDaniel Garcia <danielgarcia@gmail.com>2014-03-17 00:28:09 +0400
commit1138f9611224ff6579e90264c0cf0e0d4feac3d5 (patch)
tree5debd13a19be39bd265a5148bf07ae0aac99df49
parent3daf11b508da67a47c481623305f4e1194da257b (diff)
still unused code for ATTiny version of scale8, to get rid of calls to mul. Add ability to modify FastLED.h to disable color correction and/or dithering (with program space savings)
-rw-r--r--FastLED.h3
-rw-r--r--clockless_trinket.h2
-rw-r--r--controller.h7
-rw-r--r--lib8tion.h28
4 files changed, 37 insertions, 3 deletions
diff --git a/FastLED.h b/FastLED.h
index 1fe8acdb..6f335a1e 100644
--- a/FastLED.h
+++ b/FastLED.h
@@ -1,6 +1,9 @@
#ifndef __INC_FASTSPI_LED2_H
#define __INC_FASTSPI_LED2_H
+// #define NO_CORRECTION 1
+// #define NO_DITHERING 1
+
#include "controller.h"
#include "fastpin.h"
#include "fastspi.h"
diff --git a/clockless_trinket.h b/clockless_trinket.h
index 83cd2e84..7d99cbd9 100644
--- a/clockless_trinket.h
+++ b/clockless_trinket.h
@@ -95,8 +95,10 @@ public:
showRGBInternal(pixels);
// Adjust the timer
+#if !defined(NO_CORRECTION) || (NO_CORRECTION == 0)
uint16_t microsTaken = nLeds * CLKS_TO_MICROS(24 * (T1 + T2 + T3));
MS_COUNTER += (microsTaken >> 10);
+#endif
sei();
mWait.mark();
}
diff --git a/controller.h b/controller.h
index ee2e6d62..cc9cd88e 100644
--- a/controller.h
+++ b/controller.h
@@ -120,7 +120,9 @@ public:
CRGB getTemperature() { return m_ColorTemperature; }
CRGB getAdjustment(uint8_t scale) {
- // if(1) return CRGB(scale,scale,scale);
+#if defined(NO_CORRECTION) && (NO_CORRECTION==1)
+ return CRGB(scale,scale,scale);
+#else
CRGB adj(0,0,0);
if(scale > 0) {
@@ -136,6 +138,7 @@ public:
}
return adj;
+#endif
}
};
@@ -197,6 +200,7 @@ struct PixelController {
#endif
void init_binary_dithering() {
+#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
static byte R = 0;
R++;
@@ -218,6 +222,7 @@ struct PixelController {
d[i] = scale8(Q, e[i]);
if(e[i]) e[i]--;
}
+#endif
}
// Do we have n pixels left to process?
diff --git a/lib8tion.h b/lib8tion.h
index d197b5a1..a2e70fe4 100644
--- a/lib8tion.h
+++ b/lib8tion.h
@@ -430,8 +430,31 @@ LIB8STATIC uint8_t sub8( uint8_t i, uint8_t j)
LIB8STATIC uint8_t scale8( uint8_t i, fract8 scale)
{
#if SCALE8_C == 1
- return ((int)i * (int)(scale) ) >> 8;
+ return
+ ((int)i * (int)(scale) ) >> 8;
#elif SCALE8_AVRASM == 1
+#if defined(LIB8_ATTINY)
+ uint8_t work=0;
+ uint8_t cnt=0x80;
+ asm volatile(
+ "LOOP_%=: \n\t"
+ /*" sbrc %[scale], 0 \n\t"
+ " add %[work], %[i] \n\t"
+ " ror %[work] \n\t"
+ " lsr %[scale] \n\t"
+ " clc \n\t"*/
+ " sbrc %[scale], 0 \n\t"
+ " add %[work], %[i] \n\t"
+ " ror %[work] \n\t"
+ " lsr %[scale] \n\t"
+ " lsr %[cnt] \n\t"
+ "brcc LOOP_%="
+ : [work] "+r" (work), [cnt] "+r" (cnt)
+ : [scale] "r" (scale), [i] "r" (i)
+ :
+ );
+ return work;
+#else
asm volatile(
/* Multiply 8-bit i * 8-bit scale, giving 16-bit r1,r0 */
"mul %0, %1 \n\t"
@@ -446,6 +469,7 @@ LIB8STATIC uint8_t scale8( uint8_t i, fract8 scale)
/* Return the result */
return i;
+#endif
#else
#error "No implementation for scale8 available."
#endif
@@ -459,7 +483,7 @@ LIB8STATIC uint8_t scale8( uint8_t i, fract8 scale)
// several additional cycles.
LIB8STATIC uint8_t scale8_video( uint8_t i, fract8 scale)
{
-#if SCALE8_C == 1
+#if SCALE8_C == 1 || defined(LIB8_ATTINY)
uint8_t j = (((int)i * (int)scale) >> 8) + (i?1:0);
// uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
// uint8_t j = (i == 0) ? 0 : (((int)i * (int)(scale) ) >> 8) + nonzeroscale;