-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoMode.h
51 lines (43 loc) · 1000 Bytes
/
DemoMode.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
#ifndef DEMO_MODE_H_INCLUDED
#define DEMO_MODE_H_INCLUDED
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#include "Buttons.h"
enum class DemoState {
CHASE_FORWARD,
CHASE_BACKWARD,
THEATER_CHASE,
FLASH,
FADE,
RAINBOW,
RANDOM_TUNE
};
#define RANDOM_TUNE_LENGTH 4
class DemoMode {
private:
Adafruit_NeoPixel *strip;
Buttons *buttons;
DemoState state;
uint32_t startedAt;
uint32_t transitionAt;
uint32_t delayUntil;
uint32_t colorsByIndex[4];
int16_t position;
int16_t direction;
uint8_t tune[RANDOM_TUNE_LENGTH];
private:
void chase();
void theaterChase(uint32_t c);
void flash();
void rainbowCycle();
void delayAndCheck(uint32_t ms);
void generateRandomTune();
uint32_t wheel(byte position);
public:
DemoMode(Adafruit_NeoPixel *strip, Buttons *buttons);
void tick();
void start() {
startedAt = millis();
}
};
#endif