fastLed.ino 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. ///////////////////////// FastLED ///////////////////////////////////////
  2. void FillLEDsFromPaletteColors( CRGB leds[], int NUM_LED, CRGBPalette16 palette, uint8_t colorIndex){
  3. uint8_t brightness = 255;
  4. for( int i = 0; i < NUM_LED; i++) {
  5. leds[i] = ColorFromPalette( palette, colorIndex + sin8(i*16), 255);
  6. colorIndex += 3;
  7. }
  8. }
  9. byte FadingBrightness (int FastLEDindex, byte currentBrightness, byte targetBrightness, int step) {
  10. if (currentBrightness != targetBrightness) { currentBrightness += step ;}
  11. else Serial.println("fade done");
  12. FastLED[FastLEDindex].showLeds(currentBrightness) ;
  13. return currentBrightness ;
  14. }
  15. void updateLeds(){
  16. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  17. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  18. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  19. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  20. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  21. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  22. FillLEDsFromPaletteColors(lustreLeds,NUM_LEDS_LUSTRE, lustre_currentPalette, 0);
  23. // uint8_t secondHand = (millis() / 10) ;
  24. lustre_currentBrightness = FadingBrightness( 0, lustre_currentBrightness ,255,1);
  25. }