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:
authorMark Kriegsman <1334634+kriegsman@users.noreply.github.com>2022-01-02 20:08:53 +0300
committerGitHub <noreply@github.com>2022-01-02 20:08:53 +0300
commitf1caccbcc5570f991297c8a3912f817331c1154e (patch)
tree2997f0d317e9ea9170d5dd058ffe03fa8194b0a7
parent049c016d6b3ac210c65064952c057a8d63043f7d (diff)
parentd8096fdfe2457ffd570689d05fc602fb8711e4d8 (diff)
Merge pull request #1270 from ben-xo/feature/avr-clockless-trinket-negative-advanceBy
Feature/avr clockless trinket negative advance by
-rw-r--r--src/controller.h6
-rw-r--r--src/platforms/avr/clockless_trinket.h12
2 files changed, 12 insertions, 6 deletions
diff --git a/src/controller.h b/src/controller.h
index fe32d70d..7b7a7cf9 100644
--- a/src/controller.h
+++ b/src/controller.h
@@ -404,7 +404,11 @@ protected:
///@param nLeds the number of leds being written out
///@param scale the rgb scaling to apply to each led before writing it out
virtual void show(const struct CRGB *data, int nLeds, CRGB scale) {
- PixelController<RGB_ORDER, LANES, MASK> pixels(data, nLeds, scale, getDither());
+ PixelController<RGB_ORDER, LANES, MASK> pixels(data, nLeds < 0 ? -nLeds : nLeds, scale, getDither());
+ if(nLeds < 0) {
+ // nLeds < 0 implies that we want to show them in reverse
+ pixels.mAdvance = -pixels.mAdvance;
+ }
showPixels(pixels);
}
diff --git a/src/platforms/avr/clockless_trinket.h b/src/platforms/avr/clockless_trinket.h
index 45143d91..49de3b91 100644
--- a/src/platforms/avr/clockless_trinket.h
+++ b/src/platforms/avr/clockless_trinket.h
@@ -248,13 +248,13 @@ protected:
#define PRESCALEB4(D) asm __volatile__("brcc L_%=\n\tldi %[scale_base], 0xFF\n\tL_%=:\n\tneg %[" #D "]\n\tCLC" ASM_VARS);
// Clamp for prescale, increment data, since we won't ever wrap 65k, this also effectively clears carry for us
-#define PSBIDATA4(D) asm __volatile__("brcc L_%=\n\tldi %[scale_base], 0xFF\n\tL_%=:\n\tadd %A[data], %[ADV]\n\tadc %B[data], __zero_reg__\n\t" ASM_VARS);
+#define PSBIDATA4(D) asm __volatile__("brcc L_%=\n\tldi %[scale_base], 0xFF\n\tL_%=:\n\tadd %A[data], %A[ADV]\n\tadc %B[data], %B[ADV]\n\t" ASM_VARS);
#else
#define PRESCALE4(D) _dc<4>(loopvar);
#define PRESCALEA2(D) _dc<2>(loopvar);
#define PRESCALEB4(D) _dc<4>(loopvar);
-#define PSBIDATA4(D) asm __volatile__( "add %A[data], %[ADV]\n\tadc %B[data], __zero_reg__\n\trjmp .+0\n\t" ASM_VARS );
+#define PSBIDATA4(D) asm __volatile__( "add %A[data], %A[ADV]\n\tadc %B[data], %B[ADV]\n\trjmp .+0\n\t" ASM_VARS );
#endif
// 2 cycles - perform one step of the scaling (if a given bit is set in scale, add scale-base to the scratch space)
@@ -306,8 +306,8 @@ protected:
#define DONE asm __volatile__("2:" ASM_VARS );
// 2 cycles - increment the data pointer
-#define IDATA2 asm __volatile__("add %A[data], %[ADV]\n\tadc %B[data], __zero_reg__\n\t" ASM_VARS );
-#define IDATACLC3 asm __volatile__("add %A[data], %[ADV]\n\tadc %B[data], __zero_reg__\n\t" _CLC1 ASM_VARS );
+#define IDATA2 asm __volatile__("add %A[data], %A[ADV]\n\tadc %B[data], %B[ADV]\n\t" ASM_VARS );
+#define IDATACLC3 asm __volatile__("add %A[data], %A[ADV]\n\tadc %B[data], %B[ADV]\n\t" _CLC1 ASM_VARS );
// 1 cycle mov
#define _MOV1(B1, B2) "mov %[" #B1 "], %[" #B2 "]\n\t"
@@ -375,7 +375,9 @@ protected:
pixels.preStepFirstByteDithering();
// pull the dithering/adjustment values out of the pixels object for direct asm access
- uint8_t advanceBy = pixels.advanceBy();
+
+ // even though advanceBy is only an int8, we cast it to int16 for sign extension in case it's negative.
+ int16_t advanceBy = pixels.advanceBy();
uint16_t count = pixels.mLen;
uint8_t s0 = pixels.mScale.raw[RO(0)];