fastLed.ino 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ///////////////////////// FastLED ///////////////////////////////////////
  2. void beatSyncPalette() {
  3. uint8_t speed = beatsin8(6,0,255);
  4. CRGB color = blend(CRGB::Aqua, CRGB::Orange, speed);
  5. fill_solid(lustre_currentPalette, 16, color);
  6. }
  7. void FillLEDsFromPaletteColors( CRGB leds[], int NUM_LED, CRGBPalette16 palette, uint8_t colorIndex){
  8. uint8_t brightness = 255;
  9. for( int i = 0; i < NUM_LED; i++) {
  10. leds[i] = ColorFromPalette( palette, colorIndex + sin8(i*16), 255);
  11. colorIndex += 3;
  12. }
  13. }
  14. float FadingBrightness (int FastLEDindex, float currentBrightness, float targetBrightness, int step) {
  15. //if (currentBrightness != targetBrightness) { currentBrightness += step ;}
  16. if ( (step > 0 && currentBrightness < targetBrightness) || (step < 0 && currentBrightness > targetBrightness) ) { currentBrightness += step ;}
  17. //else Serial.println("fade done");
  18. //Serial.println(currentBrightness);
  19. FastLED[FastLEDindex].showLeds((int)currentBrightness) ;
  20. return currentBrightness ;
  21. }
  22. void updateLeds(){
  23. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  24. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  25. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  26. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  27. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  28. nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
  29. if(palette_BEAT) {
  30. beatSyncPalette();
  31. }
  32. FillLEDsFromPaletteColors(lustreLeds,NUM_LEDS_LUSTRE, lustre_currentPalette, 0);
  33. // uint8_t secondHand = (millis() / 10) ;
  34. lustre_currentBrightness = FadingBrightness( 0, lustre_currentBrightness, lustre_targetBrightness ,lustre_stepBrightness);
  35. }
  36. /////////////////////////////// DIMMER //////////////////////////////////////
  37. byte percent2PWM ( byte valueIn ) {
  38. return map (valueIn, 0, 100, 14, 92);
  39. }