diff options
author | Ben Isaacs <75862+ben-xo@users.noreply.github.com> | 2021-08-01 14:36:35 +0300 |
---|---|---|
committer | Ben Isaacs <75862+ben-xo@users.noreply.github.com> | 2021-08-01 14:36:35 +0300 |
commit | a57d1f3c3899b2eced6fc3940d03e1c7f5d6966b (patch) | |
tree | 3bac98598ce102425d1a160f35557f9a2a9b6b97 | |
parent | 9072e07ce68fa60027909131a251b33d74727fde (diff) |
Tweak Controller::showLeds() to infer reversal from negative strip length
Example usage:
```
Show forward:
FastLED[0].setLeds(&leds[0], STRIP_LENGTH);
FastLED.show();
Show in reverse:
FastLED[0].setLeds(&leds[STRIP_LENGTH-1], -STRIP_LENGTH);
FastLED.show();
```
-rw-r--r-- | src/controller.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/controller.h b/src/controller.h index fe32d70d..1616eb91 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 = -3; + } showPixels(pixels); } |