-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradient2.h
61 lines (57 loc) · 1.59 KB
/
Gradient2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef GRADIENT2_H
#define GRADIENT2_H
#include "iLampAnimation.h"
#include "Lamp.h"
#include "FastLED.h"
class Gradient2 : public iLampAnimation
{
public:
Gradient2(Lamp* thelamp) : iLampAnimation (thelamp){
}
int itterate()
{
// CRGB col2;
uint8_t leds = lamp->getNumLeds();
if(grad > 5) {
grad = 0;
}
// if(blend_step < 255) {
// for(uint8_t i = 0; i < leds; i++) {
// uint8_t h = map(i, 0, leds, s_hues[grad], e_hues[grad]);
// CRGB color = CRGB(255, 255, 255);
// color.setHue(h);
//
// //fract8 blenda = constrain((blend_step/255), 0, 0.99609375); //0.99609375;
// fract8 blenda = 0.25;
// col2 = blend(lamp->getLed(i), color, blenda);
// lamp->setLed(i, color);
// //lamp->setLed(i, color);
// }
// Serial.println(col2.red);
// blend_step++;
// Serial.print("blend step: ");
// Serial.println(blend_step);
// lamp->render();
// return 10;
// }
// else{
for(uint8_t i = 0; i < leds; i++) {
uint8_t h = map(i, 0, leds, s_hues[grad], e_hues[grad]);
lamp->setLed(i, CHSV(h, 255, 255));
}
lamp->render();
grad++;
// //stay on one gradient for a while
// //set the blend steps back to default
// blend_step = 1;
return 5000;
// }
// return 5000;
}
protected:
uint8_t s_hues[6] = {255, 0, 96, 96, 160, 160};
uint8_t e_hues[6] = {217, 38, 58, 134, 122, 198};
uint8_t grad = 0;
uint8_t blend_step = 1;
};
#endif // GRADIENT2_H