-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathringrunner.h
More file actions
56 lines (44 loc) · 816 Bytes
/
ringrunner.h
File metadata and controls
56 lines (44 loc) · 816 Bytes
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
#ifndef RINGRUNNER_H
#define RINGRUNNER_H
#include "animation.h"
class RingRunner : public Animation {
public:
RingRunner()
{
position = 0;
current_color = CRGB::Blue;//fix later
}
void mirror_leds(CRGB *leds)
{
for(int i=0; i<NUM_LEDS/2;i++)
{
leds[NUM_LEDS-1-i] = leds[i];
}
}
void step()
{
leds[position] = CRGB::Black;
//index position of lit LED
if(position == NUM_LEDS/2)
{
position = 0;
current_color = CHSV(random(255),random(255),random(255));
}
else
{
position++;
}
// load the CRGB values into led, mirror around the middle
leds[position] = current_color;
mirror_leds(leds);
FastLED.show();
delay(100);
}
private:
int position;
CRGB current_color;
};
Animation * ringrunner_factory() {
return new RingRunner();
}
#endif