From a57d1f3c3899b2eced6fc3940d03e1c7f5d6966b Mon Sep 17 00:00:00 2001 From: Ben Isaacs <75862+ben-xo@users.noreply.github.com> Date: Sun, 1 Aug 2021 12:36:35 +0100 Subject: 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(); ``` --- src/controller.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 pixels(data, nLeds, scale, getDither()); + PixelController 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); } -- cgit v1.2.3