Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* * * * * * * * * * * * * * * * * * * *
- Updated script from https://www.reddit.com/r/FastLED/comments/1f253qz/
- (1) for low-value HSV throughout the color spectrum, and
- (2) when representing white at increasingly low brightnesses.
- The first animation sets LEDs to incrimental (color) HSV values (starting at 1), then cycles hue at consistant brightness.
- The second animation sets LEDs to incrimental (white) HSV values (starting at 1), then incrimetally dims brightness.
- The default values provided values are spectificly for Waveshare's "ESP32-S3-Matrix", wich has an onboard 8x8 RGB matrix.
- * * * * * * * * * * * * * * * * * * * * */
- #include <FastLED.h>
- #define NUM_LEDS 64 // 8x8 matrix, but this doesn't do anything 2D
- #define LED_TYPE WS2811 // Just a guess, but it seems to work(?)
- #define PIN_ORDER RGB // If set to "ESP32S3 Dev Module", otherwise try "GRB"
- #define DATA_PIN 14 // Not SPI; no CLOCK_PIN
- #define BRIGHTNESS 64 // Board spec cautions against setting over 50 ~ like previous script, max is 64
- #define DITHER BINARY_DITHER // BINARY_DITHER | DISABLE_DITHER ~ Note: here "dither" means "temporal dither"
- #define CORRECTION UncorrectedColor // Color correction - not sure what other option makes more sense | TypicalSMD5050
- #define ANIMATE_FOR 10 // Time in seconds to view each animation before switching
- #define STEP 1 // Incremental change of hue and brightness
- #define PAUSE 15 // Time to view each color/brigtness step in ms
- CRGB leds[NUM_LEDS];
- static uint8_t delta = 0;
- static bool color_test = true;
- void setup() {
- setCpuFrequencyMhz(240);
- // delay(3000); // This isn't needed for this board(?)
- FastLED.addLeds
- <LED_TYPE, DATA_PIN, RGB>
- (leds, NUM_LEDS)
- .setCorrection(CORRECTION)
- .setDither(DITHER);
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- EVERY_N_SECONDS(ANIMATE_FOR) swapAnimation();
- color_test ? cycleColor() : cycleBrightness(); // Call animation
- FastLED.show();
- FastLED.delay(PAUSE);
- delta += STEP;
- }
- void swapAnimation() {
- color_test = !color_test; // Swap animations
- delta = 0; // Reset to start of whatever animation
- if (color_test) FastLED.setBrightness(BRIGHTNESS); // Reset to preset BRIGHTNESS if testing colors
- else for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(0,0,i * 4 + 1); // Only need to write to leds once if testing brightness
- }
- void cycleColor() { // Cycle through color spectrum
- for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(delta,255,i * 4 + 1);
- }
- void cycleBrightness() { // Cycle through _valid_ brightnesses
- if (delta >= BRIGHTNESS) delta = 0;
- FastLED.setBrightness(BRIGHTNESS - delta);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement