|
10 | 10 | BlendWave::BlendWave(CRGB* neopixels, uint16_t numLEDS) { |
11 | 11 | _neopixels = neopixels; |
12 | 12 | _numLEDS = numLEDS; |
13 | | - |
14 | | - currentPalette = OceanColors_p; |
15 | 13 | } |
16 | 14 |
|
17 | | -void BlendWave::loop() { |
18 | | - int thisPhase = beatsin8(6,-64,64); // Setting phase change for a couple of waves. |
19 | | - int thatPhase = beatsin8(7,-64,64); |
| 15 | +void BlendWave::loop(CRGBPalette16 palette) { |
| 16 | + _currentPalette = palette; |
| 17 | + |
| 18 | + // setting phase change for a couple of waves |
| 19 | + int thisPhase = beatsin8(6, -64, 64); |
| 20 | + int thatPhase = beatsin8(7, -64, 64); |
20 | 21 |
|
21 | | - for (int k=0; k<_numLEDS; k++) { // For each of the LED's in the strand, set a brightness based on a wave as follows: |
| 22 | + // for each of the LED's in the strand, set a brightness based on a wave as follows: |
| 23 | + for (int k=0; k<_numLEDS; k++) { |
22 | 24 |
|
23 | | - int colorIndex = cubicwave8((k*23)+thisPhase)/2 + cos8((k*15)+thatPhase)/2; // Create a wave and add a phase change and add another wave with its own phase change.. Hey, you can even change the frequencies if you wish. |
24 | | - int thisBright = qsuba(colorIndex, beatsin8(7,0,96)); // qsub gives it a bit of 'black' dead space by setting sets a minimum value. If colorIndex < current value of beatsin8(), then bright = 0. Otherwise, bright = colorIndex.. |
| 25 | + // create a wave and add a phase change and add another wave with its own phase change |
| 26 | + int colorIndex = cubicwave8((k*23)+thisPhase)/2 + cos8((k*15)+thatPhase)/2; |
| 27 | + // qsub gives it a bit of 'black' dead space by setting sets a minimum value. |
| 28 | + // If colorIndex < current value of beatsin8(), then bright = 0. Otherwise, bright = colorIndex.. |
| 29 | + int thisBright = qsuba(colorIndex, beatsin8(7,0,96)); |
25 | 30 |
|
26 | | - _neopixels[k] = ColorFromPalette(currentPalette, colorIndex, thisBright, currentBlending); // Let's now add the foreground colour. |
| 31 | + // Add the foreground colour |
| 32 | + _neopixels[k] = ColorFromPalette(_currentPalette, colorIndex, thisBright, _currentBlending); |
27 | 33 | } |
28 | 34 | } |
0 commit comments