12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- ///////////////////////// FastLED ///////////////////////////////////////
- void beatSyncPalette() {
-
- uint8_t speed = beatsin8(BPM,0,255);
- uint8_t speed2 = beatsin8(1.5 * BPM,0,255);
- CRGB color = blend(ColorFromPalette( palette_SOLEIL,0 , 255), ColorFromPalette( palette_MER,0 , 255), speed);
- color = blend(color, ColorFromPalette( palette_FLAMINGO,0 , 255), speed2);
- fill_solid(lustre_currentPalette, 16, color);
- // Serial.println("beat");
- }
- 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 = constrain(currentBrightness + step, 0, 255) ;}
- //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) ;
- if (palette_MOVE) {
- if (random8(100) > 20) {
- int timer = millis();
- int delta = 2 * led_move * (sin8( timer / 9 )) * (sin8(timer / 7 )) / 65536 ; //- led_move/2
- FastLED[0].showLeds(lustre_currentBrightness - delta) ;
- //Serial.println(lustre_currentBrightness - delta);
- }
-
- }
- else {
- lustre_currentBrightness = FadingBrightness( 0, lustre_currentBrightness, lustre_targetBrightness ,lustre_stepBrightness);
- // Serial.println(lustre_currentBrightness);
- }
-
-
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- nblendPaletteTowardPalette(table_currentPalette, table_targetPalette, 48);
- FillLEDsFromPaletteColors(tableLeds,NUM_LEDS_TABLE, table_currentPalette, 0);
- table_currentBrightness = FadingBrightness( 1, table_currentBrightness, table_targetBrightness ,table_stepBrightness);
- Serial.println(table_currentBrightness);
- }
- /////////////////////////////// DIMMER //////////////////////////////////////
- byte percent2PWM ( byte valueIn ) {
- return map (valueIn, 0, 100, 14, 92);
- }
|