Can anyone advise a way to reverse the direction of the leds? They always seem to ‘travel’ towards the bottom end.
marmil
(Marc Miller)
October 4, 2018, 6:20pm
2
How you do it might depend a bit on the code. Please put your code on http://gist.github.com and share the link.
Here’s two examples of patterns that can be reversed.
//***************************************************************
// Three moving pixels example
// Uses modulo, %, to make pixel position "loop" around and
// stay in valid pixel range.
//
// Marc Miller, Feb 2015. Updated Jan 2016.
//***************************************************************
#include "FastLED.h"
#define LED_TYPE NEOPIXEL // Strip type: NEOPIXEL, APA102, LPD8806, etc.
#define DATA_PIN 6
//#define CLOCK_PIN 13
#define NUM_LEDS 12
//#define COLOR_ORDER BGR
#define MASTER_BRIGHTNESS 100 // Master brightness (Range is 0-255)
CRGB leds[NUM_LEDS];
int16_t positionRed = 0; // Set initial start position of Red pixel
int16_t positionWhite = 4; // Set initial start position of White pixel
This file has been truncated. show original
//***************************************************************
// Marquee fun (v3)
// Pixel position down the strip comes from this formula:
// pos = spacing * (i-1) + spacing
// i starts at 0 and is incremented by +1 up to NUM_LEDS/spacing.
//
// Marc Miller, May 2016
// Updated June 2018 - reordered some stuff and small bug fix.
//***************************************************************
#include "FastLED.h"
#define LED_TYPE LPD8806
#define NUM_LEDS 32
#define COLOR_ORDER GRB
//#define LED_TYPE APA102
//#define NUM_LEDS 39
//#define COLOR_ORDER BGR
#define DATA_PIN 11
This file has been truncated. show original
Here’s a routine that has a direction change variable:
/* matrix_pal_demo
*
* Originally By: funkboxing LED
*
* Modified a LOT by: Andrew Tuline
*
* Date: July, 2015
*
* Various coloured characters going up/down the strand, a la 'The Matrix'. This highly modified version uses non-blocking
* delays as well as colorPalette lookups and other variables such as direction, speed and background colours.
*
*/
#include "FastLED.h" // FastLED library.
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
// Fixed definitions cannot change on the fly.
This file has been truncated. show original
That being said, different animations may require this to be done differently. For example, if I were doing sine waves down the strand, then this wouldn’t work at all.
marmil
(Marc Miller)
October 4, 2018, 6:22pm
4
It also might be something as simple as this:
change
leds[i] = …
to
leds[ (NUM_LEDS-1) - i ] = …
The easy way to physically flip you LED strip
If you are using For Loops, then you could initialize with the max array value and count down, instead of counting up? Or change arrange indexes to do something like leds[NUM_LEDS-i] = …