Advertisement
atuline

ColorPal

Jun 19th, 2015
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. /* ColorPal
  2.  
  3. By: Mark Kriegsman
  4.  
  5. Modified by: Andrew Tuline
  6.  
  7. This is a stripped down version of Mark Kriegsman's ColorPalette.ino.
  8.  
  9. */
  10.  
  11.  
  12. #include "FastLED.h"
  13.  
  14. #define LED_DT     12
  15. #define LED_CK     11
  16. #define NUM_LEDS    8
  17. #define BRIGHTNESS  16
  18. #define LED_TYPE    WS2812B
  19. #define COLOR_ORDER GRB
  20. CRGB leds[NUM_LEDS];
  21.  
  22.  
  23. int indexinc = 3;
  24. uint8_t brightness = 64;
  25. uint8_t updates_per_second = 30;
  26.  
  27. CRGBPalette16 currentPalette;
  28. TBlendType    currentBlending;
  29.  
  30.  
  31. void setup() {
  32.   delay(1000);                                                                // power-up safety delay
  33.   FastLED.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);             // WS2812B
  34. //  FastLED.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS);   // WS2801 or APA102
  35.   FastLED.setBrightness(BRIGHTNESS);
  36.  
  37.   currentPalette = OceanColors_p;
  38.   //currentPalette = RainbowColors_p;  
  39.   //currentPalette = HeatColors_p;
  40.   //currentPalette = PartyColors_p;
  41.   //currentPalette = CloudColors_p;
  42.   //currentPalette = RainbowStripeColors_p;
  43.   //currentPalette = ForestColors_p;
  44.  
  45. /*  currentPalette = CRGBPalette16(
  46.     0x000008,  0x0000010,  0x000018,  0x000020, 0x000028, 0x000030, 0x000038,  0x000040,
  47.     0x000040,  0x0000038,  0x000030,  0x000028, 0x000020, 0x000018, 0x000010,  0x000008 );
  48. */
  49.  
  50.   currentBlending = BLEND;  
  51. } //setup()
  52.  
  53.  
  54. void loop() {
  55.   static uint8_t startIndex = 0;
  56.   startIndex+=1;
  57.   FillLEDsFromPaletteColors(startIndex);
  58.   FastLED.show();
  59.   FastLED.delay(1000/updates_per_second);
  60. } //loop()
  61.  
  62. void FillLEDsFromPaletteColors(uint8_t colorIndex) {
  63.   for (int i = 0; i < NUM_LEDS; i++) {
  64.     leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
  65.     colorIndex += indexinc;
  66.   }
  67. } //FillLEDsFromPaletteColors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement