-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinybee_patterns.h
153 lines (128 loc) · 3.46 KB
/
tinybee_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#define PALETTE_CYCLE_TIME 2500
//--------------------------------------------------------------------------------------------------
// palettes
//--------------------------------------------------------------------------------------------------
DEFINE_GRADIENT_PALETTE( Mode_Yalda_gp ) {
0, 0, 0, 0,
40, 0x3B, 0, 0x72,
80, 0, 0, 0,
120, 0x19, 0x29, 0x70,
160, 0, 0, 0,
200, 0, 0x8B, 0x7B,
255, 0, 0, 0
};
DEFINE_GRADIENT_PALETTE( Green_Purple_gp ) {
0, 0, 0, 0,
32, 0, 127, 0,
64, 0, 0, 0,
96, 127, 0, 127,
128, 0, 0, 0,
160, 0, 127, 0,
192, 0, 0, 0,
224, 127, 0, 127,
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( Orange_Blue_gp ) {
0, 0, 0, 0,
32, 0, 0, 128,
64, 0, 0, 0,
96, 128, 128, 0,
128, 0, 0, 0,
160, 0, 0, 128,
192, 0, 0, 0,
224, 128, 128, 0,
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( Rainbow1_gp ) {
0, 0, 0, 0,
32, 255, 0, 0, // Red
64, 0, 0, 0,
96, 171, 85, 0, // Orange
128, 0, 0, 0,
160, 171,171, 0, // Yellow
192, 0, 0, 0,
224, 171, 85, 0, // Orange
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( Rainbow2_gp ) {
0, 0, 0, 0,
32, 0, 0xCE1, 0xD1, // Turquoise
64, 0, 0, 0,
96, 0,255, 0, // Green
128, 0, 0, 0,
160, 0,171, 85, // Aqua
192, 0, 0, 0,
224, 0,255, 0, // Green
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( Rainbow3_gp ) {
0, 0, 0, 0,
32, 0,171, 85, // Aqua
64, 0, 0, 0,
96, 0, 0,255, // Blue
128, 0, 0, 0,
160, 85, 0,171, // Purple
192, 0, 0, 0,
224, 0, 0,255, // Blue
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( Rainbow4_gp ) {
0, 0, 0, 0,
32, 85, 0,171, // Purple
64, 0, 0, 0,
96, 171, 0, 85, // Pink
128, 0, 0, 0,
160, 255, 0, 0, // Red
192, 0, 0, 0,
224, 171, 0, 85, // Pink
255, 0, 0, 0,
};
DEFINE_GRADIENT_PALETTE( My_Rainbow_gp ) {
0, 255, 0, 0, // Red
32, 171,171, 0, // Yellow
64, 0, 0, 0,
96, 0,255, 0, // Green
128, 0,171, 85, // Aqua
160, 0, 0,255, // Blue
192, 0, 0, 0,
224, 85, 0,171, // Purple
255, 255, 0, 0 // and back to Red
};
const TProgmemRGBGradientPalettePtr g_palettes[] = {
Green_Purple_gp,
Orange_Blue_gp,
Rainbow1_gp,
Rainbow2_gp,
Rainbow3_gp,
Rainbow4_gp,
};
const uint8_t g_palette_count =
sizeof( g_palettes) / sizeof( TProgmemRGBGradientPalettePtr );
void FillLEDsFromPaletteColors(CRGBPalette16 &palette, uint8_t colorIndex, uint8_t step) {
for( int i = 0; i < NUM_LEDS; i++, colorIndex+=step) {
leds[i] = ColorFromPalette( palette, colorIndex, 255, LINEARBLEND);
}
}
uint8_t g_current_palette_number = 0;
CRGBPalette16 g_current_palette( CRGB::Black);
// HACK no memory for another palette so reuse the LED buffer
CRGBPalette16 *g_target_palette = (CRGBPalette16 *)&leds;
uint8_t g_palette_offset = 0;
uint32_t g_last_palette_time = 0;
int moving_palette() {
if (g_now - g_last_palette_time > PALETTE_CYCLE_TIME) {
g_current_palette_number = addmod8( g_current_palette_number, 1, g_palette_count);
g_last_palette_time = g_now;
}
g_palette_offset++;
*g_target_palette = g_palettes[g_current_palette_number];
nblendPaletteTowardPalette( g_current_palette, *g_target_palette, 24);
FillLEDsFromPaletteColors(g_current_palette, g_palette_offset, 7);
return 0;
}
int mode_yalda() {
g_palette_offset++;
g_current_palette = Mode_Yalda_gp;
FillLEDsFromPaletteColors(g_current_palette, g_palette_offset, 9);
return 0;
}