Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** FAST LED Blend tester */
- #include <FastLED.h>
- #define LED_PIN 6
- #define COLOR_ORDER GRB
- #define CHIPSET WS2811
- #define NUM_LEDS 100
- #define HALF_LEDS 50
- #define BRIGHTNESS 255
- #define FRAMES_PER_SECOND 100
- CRGB leds[NUM_LEDS];
- CRGB ledsPrev[NUM_LEDS];
- CRGB ledsNext[NUM_LEDS];
- CRGBPalette16 gPal;
- CRGB currentColor;
- bool tweenBool = false;
- void setup() {
- Serial.begin(57600);
- Serial.println("resetting");
- // sanity delay
- FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness( BRIGHTNESS );
- // This first palette is the basic 'black body radiation' colors,
- // which run from black to red to bright yellow to white.
- gPal = RainbowColors_p;
- currentColor = ColorFromPalette( gPal, random8());
- // FastLED.setDither( 0 );
- tweenBool = true;
- delay(3000);
- Serial.println("Blend Testing FASTLED 3.01");
- Serial.println();
- }
- void loop()
- {
- if (tweenBool) {
- fill_solid(&(ledsNext[0]),50, CRGB( 1,5, 0));
- fill_solid(&(ledsPrev[0]),50, CRGB( 3, 60, 1));
- fill_solid(&(leds[0]),50, CRGB( 0, 0, 0));
- Serial.print("Blend From");
- Serial.print(" R:");
- Serial.print(ledsPrev[20].r);
- Serial.print(" G:");
- Serial.print(ledsPrev[20].g);
- Serial.print(" B:");
- Serial.println(ledsPrev[20].b);
- Serial.print("Blend To");
- Serial.print(" R:");
- Serial.print(ledsNext[20].r);
- Serial.print(" G:");
- Serial.print(ledsNext[20].g);
- Serial.print(" B:");
- Serial.println(ledsNext[20].b);
- Serial.println();
- for (int i = 0; i <= 255; i++) {
- tween2Next(i);
- }
- Serial.println();
- Serial.print("Blend Next");
- Serial.print(" R:");
- Serial.print(ledsNext[20].r);
- Serial.print(" G:");
- Serial.print(ledsNext[20].g);
- Serial.print(" B:");
- Serial.println(ledsNext[20].b);
- Serial.println();
- tweenBool = false;
- }
- }
- void tween2Next( int frameC) {
- for (int i = 0; i< HALF_LEDS; i++)
- {
- leds[i] = blend(ledsPrev[i],ledsNext[i],frameC);
- }
- printLED(20,frameC);
- }
- void printLED(int ledIndex, int frameC) {
- Serial.print("Blend %");
- Serial.print(frameC);
- Serial.print(" - R:");
- Serial.print(leds[ledIndex].r);
- Serial.print(" G:");
- Serial.print(leds[ledIndex].g);
- Serial.print(" B:");
- Serial.println(leds[ledIndex].b);
- }
Advertisement
Add Comment
Please, Sign In to add comment