dmf3030

FastLED 3.1 blend serial print

Jan 30th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. /** FAST LED Blend tester */
  2.  
  3.  
  4. #include <FastLED.h>
  5.  
  6. #define LED_PIN 6
  7. #define COLOR_ORDER GRB
  8. #define CHIPSET WS2811
  9. #define NUM_LEDS 100
  10. #define HALF_LEDS 50
  11. #define BRIGHTNESS 255
  12. #define FRAMES_PER_SECOND 100
  13.  
  14.  
  15. CRGB leds[NUM_LEDS];
  16. CRGB ledsPrev[NUM_LEDS];
  17. CRGB ledsNext[NUM_LEDS];
  18. CRGBPalette16 gPal;
  19. CRGB currentColor;
  20.  
  21. bool tweenBool = false;
  22.  
  23.  
  24. void setup() {
  25.  
  26. Serial.begin(57600);
  27. Serial.println("resetting");
  28. // sanity delay
  29. FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  30. FastLED.setBrightness( BRIGHTNESS );
  31.  
  32. // This first palette is the basic 'black body radiation' colors,
  33. // which run from black to red to bright yellow to white.
  34.  
  35. gPal = RainbowColors_p;
  36. currentColor = ColorFromPalette( gPal, random8());
  37. // FastLED.setDither( 0 );
  38. tweenBool = true;
  39.  
  40. delay(3000);
  41. Serial.println("Blend Testing FASTLED 3.01");
  42. Serial.println();
  43. }
  44.  
  45.  
  46. void loop()
  47. {
  48. if (tweenBool) {
  49. fill_solid(&(ledsNext[0]),50, CRGB( 1,5, 0));
  50. fill_solid(&(ledsPrev[0]),50, CRGB( 3, 60, 1));
  51. fill_solid(&(leds[0]),50, CRGB( 0, 0, 0));
  52.  
  53. Serial.print("Blend From");
  54. Serial.print(" R:");
  55. Serial.print(ledsPrev[20].r);
  56. Serial.print(" G:");
  57. Serial.print(ledsPrev[20].g);
  58. Serial.print(" B:");
  59. Serial.println(ledsPrev[20].b);
  60. Serial.print("Blend To");
  61. Serial.print(" R:");
  62. Serial.print(ledsNext[20].r);
  63. Serial.print(" G:");
  64. Serial.print(ledsNext[20].g);
  65. Serial.print(" B:");
  66. Serial.println(ledsNext[20].b);
  67. Serial.println();
  68.  
  69. for (int i = 0; i <= 255; i++) {
  70. tween2Next(i);
  71.  
  72. }
  73. Serial.println();
  74. Serial.print("Blend Next");
  75. Serial.print(" R:");
  76. Serial.print(ledsNext[20].r);
  77. Serial.print(" G:");
  78. Serial.print(ledsNext[20].g);
  79. Serial.print(" B:");
  80. Serial.println(ledsNext[20].b);
  81. Serial.println();
  82. tweenBool = false;
  83. }
  84. }
  85.  
  86.  
  87. void tween2Next( int frameC) {
  88. for (int i = 0; i< HALF_LEDS; i++)
  89. {
  90. leds[i] = blend(ledsPrev[i],ledsNext[i],frameC);
  91. }
  92.  
  93. printLED(20,frameC);
  94.  
  95. }
  96.  
  97. void printLED(int ledIndex, int frameC) {
  98.  
  99. Serial.print("Blend %");
  100. Serial.print(frameC);
  101. Serial.print(" - R:");
  102. Serial.print(leds[ledIndex].r);
  103. Serial.print(" G:");
  104. Serial.print(leds[ledIndex].g);
  105. Serial.print(" B:");
  106. Serial.println(leds[ledIndex].b);
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment