Last active
October 22, 2018 21:27
-
-
Save marmilicious/fc188ac003817bd72af5cc5a7ddcb31a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Info posted for this post: | |
https://plus.google.com/101381095273549449891/posts/FqmG6S4rjpz | |
Another option (that uses a bit more memory) is to use a second array (let's call it leds_display) that | |
you copy your leds data to with the offset before displaying. So it the top of your program you will | |
have two CRGB arrays: | |
CRGB leds[NUM_LEDS]; //working array | |
CRGB leds_display[NUM_LEDS]; //array that gets displayed | |
And in setup for your addLeds line use leds_show instead of leds: | |
FastLED.addLeds<WS2812B, 11, RGB>(leds_show, NUM_LEDS); //(using leds_show, not leds) | |
And create a function like this: | |
// function to copy leds to leds_display and offset pixel position | |
void offset_pixels() { | |
for (uint16_t i=0; i<NUM_LEDS; i++) { | |
leds_show[i] = leds[(i+400) % NUM_LEDS]; //offset by 400 | |
} | |
} | |
Then code way as normal... | |
And always call the copy and offset function right before you call show(). | |
offset_pixels(); //always call right before show() | |
FastLED.show(); //display pixels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment