1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- ///////////////////////// FastLED ///////////////////////////////////////
- void beatSyncPalette() {
-
- uint8_t speed = beatsin8(6,0,255);
- CRGB color = blend(CRGB::Aqua, CRGB::Orange, speed);
- fill_solid(lustre_currentPalette, 16, color);
- }
- void FillLEDsFromPaletteColors( CRGB leds[], int NUM_LED, CRGBPalette16 palette, uint8_t colorIndex){
- uint8_t brightness = 255;
- for( int i = 0; i < NUM_LED; i++) {
- leds[i] = ColorFromPalette( palette, colorIndex + sin8(i*16), 255);
- colorIndex += 3;
- }
- }
- float FadingBrightness (int FastLEDindex, float currentBrightness, float targetBrightness, int step) {
- //if (currentBrightness != targetBrightness) { currentBrightness += step ;}
- if ( (step > 0 && currentBrightness < targetBrightness) || (step < 0 && currentBrightness > targetBrightness) ) { currentBrightness += step ;}
- //else Serial.println("fade done");
- //Serial.println(currentBrightness);
- FastLED[FastLEDindex].showLeds((int)currentBrightness) ;
- return currentBrightness ;
- }
- void updateLeds(){
-
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- nblendPaletteTowardPalette(lustre_currentPalette, lustre_targetPalette, 48);
- if(palette_BEAT) {
- beatSyncPalette();
- }
- FillLEDsFromPaletteColors(lustreLeds,NUM_LEDS_LUSTRE, lustre_currentPalette, 0);
- // uint8_t secondHand = (millis() / 10) ;
- lustre_currentBrightness = FadingBrightness( 0, lustre_currentBrightness, lustre_targetBrightness ,lustre_stepBrightness);
- }
- /////////////////////////////// DIMMER //////////////////////////////////////
- byte percent2PWM ( byte valueIn ) {
- return map (valueIn, 0, 100, 14, 92);
- }
|