-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patterns.h
50 lines (39 loc) · 1.24 KB
/
Patterns.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
#ifndef _PATTERNS_H
#define _PATTERNS_H
#include "BasicPatterns.h"
#include "DemoPatterns.h"
#include "FirePattern.h"
extern uint8_t currentPatternIndex = 0;
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
typedef void (*Pattern)();
typedef Pattern PatternList[];
typedef struct {
Pattern pattern;
String name;
} PatternAndName;
typedef PatternAndName PatternAndNameList[];
// Add new patterns here
extern PatternAndNameList patterns = {
{ ring, "Ring" },
{ ring_two, "Ring Type 2" },
{ huefade, "Hue Fade" },
{ rainbow, "Rainbow" },
// { rainbowWithGlitter, "Rainbow with Glitter" },
{ fire2012, "Fire" },
{ confetti, "Confetti" },
{ juggle, "Juggle" },
{ white, "Set to White"},
{ red, "Set to Red"},
{ blue, "Set to Blue"},
{ green, "Set to Green"}
};
extern const uint8_t patternCount = ARRAY_SIZE(patterns);
void setPattern(uint8_t value) {
if (value >= patternCount)
value = patternCount - 1;
currentPatternIndex = value;
EEPROM.write(0, currentPatternIndex);
EEPROM.commit();
Serial.printf("Pattern: %d\n", currentPatternIndex);
}
#endif