Advertisement
atuline

CHSV colour based palettes.

May 21st, 2020
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. /*
  2. * Just a FastLED palette demonstration.
  3. */
  4.  
  5.  
  6. #include <FastLED.h> // FastLED library.
  7.  
  8. #define LED_DT 12 // Serial data pin for WS2812 or WS2801.
  9. #define COLOR_ORDER GRB // Are they GRB for WS2812 and GBR for APA102
  10. #define LED_TYPE WS2812 // What kind of strip are you using? WS2812, APA102. . .
  11. #define NUM_LEDS 40 // Number of LED's.
  12. uint8_t max_bright = 128; // Overall brightness definition. It can be changed on the fly.
  13.  
  14. struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
  15.  
  16. TBlendType currentBlending = LINEARBLEND;
  17.  
  18. CRGBPalette16 test_pal = CRGBPalette16(CHSV( 120, 255, 25), CHSV( 20, 25, 55), CHSV( 30, 255, 105), CHSV( 40, 255, 155),
  19. CHSV( 90, 255, 205), CHSV( 110, 255, 255), CHSV( 178, 255, 255), CHSV( 210, 55, 155),
  20. CHSV( 220, 255, 255), CHSV( 230, 255, 255), CHSV( 140, 55, 55), CHSV( 245, 255, 255),
  21. CHSV( 246, 255, 255), CHSV( 247, 155, 55), CHSV( 250, 255, 255), CHSV( 252, 255, 255));
  22.  
  23.  
  24. void setup() {
  25. delay(1000);
  26. LEDS.addLeds<LED_TYPE, LED_DT,COLOR_ORDER>(leds, NUM_LEDS);
  27. FastLED.setBrightness(max_bright);
  28. }
  29.  
  30.  
  31. void loop() {
  32. bettertest();
  33. FastLED.show();
  34. }
  35.  
  36.  
  37. void bettertest() {
  38. uint8_t i = millis()/16;
  39. fill_palette (leds, NUM_LEDS, i, 1, test_pal,255 , LINEARBLEND);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement