FastLED
3.9.7
Loading...
Searching...
No Matches
color_mapper.cpp
1
2
3
#include <Arduino.h>
4
5
6
#include <stdint.h>
7
8
9
#include "./color_mapper.h"
10
11
#include "./color.h"
12
#include "./util.h"
13
14
// Serves as the pallet for selecting a color.
15
struct
ColorScheme
{
16
ColorScheme
(
const
ColorHSV
& c0,
17
const
ColorHSV
& c1,
18
const
ColorHSV
& c2,
19
const
ColorHSV
& c3,
20
const
ColorHSV
& c4,
21
const
ColorHSV
& c5,
22
const
ColorHSV
& c6,
23
const
ColorHSV
& c7,
24
const
ColorHSV
& c8,
25
const
ColorHSV
& c9,
26
const
ColorHSV
& c10,
27
const
ColorHSV
& c11) {
28
data[0] = c0;
29
data[1] = c1;
30
data[2] = c2;
31
data[3] = c3;
32
data[4] = c4;
33
data[5] = c5;
34
data[6] = c6;
35
data[7] = c7;
36
data[8] = c8;
37
data[9] = c9;
38
data[10] = c10;
39
data[11] = c11;
40
}
41
ColorHSV
data[12];
42
};
43
44
const
ColorScheme
& SelectColorScheme(
int
indx) {
45
static
ColorScheme
color_schemes[] = {
46
47
// Coda
48
ColorScheme
(
49
ColorHSV
(
Color3i
(0xff, 0x00, 0x00)),
// C
50
ColorHSV
(
Color3i
(0x00, 0x80, 0xff)),
// C
51
ColorHSV
(
Color3i
(0xff, 0xff, 0x00)),
// D
52
ColorHSV
(
Color3i
(0x80, 0x00, 0xff)),
// D#
53
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// E
54
ColorHSV
(
Color3i
(0xff, 0x00, 0x80)),
// F
55
ColorHSV
(
Color3i
(0x00, 0xff, 0xff)),
// F#
56
ColorHSV
(
Color3i
(0xff, 0x80, 0x00)),
// G
57
ColorHSV
(
Color3i
(0x00, 0x00, 0xff)),
// G#
58
ColorHSV
(
Color3i
(0x80, 0xff, 0x00)),
// A
59
ColorHSV
(
Color3i
(0xff, 0x00, 0xff)),
// A#
60
ColorHSV
(
Color3i
(0x00, 0xff, 0x80))
61
),
62
63
// Frequency
64
ColorScheme
(
65
ColorHSV
(
Color3i
(0xfc, 0xff, 0x00)),
// C
66
ColorHSV
(
Color3i
(0x00, 0xff, 0x73)),
// C#
67
ColorHSV
(
Color3i
(0x00, 0xa7, 0xff)),
68
ColorHSV
(
Color3i
(0x00, 0x20, 0xff)),
69
ColorHSV
(
Color3i
(0x35, 0x00, 0xff)),
70
ColorHSV
(
Color3i
(0x56, 0x00, 0xb6)),
71
ColorHSV
(
Color3i
(0x4e, 0x00, 0x6c)),
72
ColorHSV
(
Color3i
(0x9f, 0x00, 0x00)),
// G
73
ColorHSV
(
Color3i
(0xdb, 0x00, 0x00)),
74
ColorHSV
(
Color3i
(0xff, 0x36, 0x00)),
// A
75
ColorHSV
(
Color3i
(0xff, 0xc1, 0x00)),
76
ColorHSV
(
Color3i
(0xbf, 0xff, 0x00))
// B
77
),
78
79
// SCRIABIN
80
ColorScheme
(
81
ColorHSV
(
Color3i
(0xff, 0x00, 0x00)),
// C
82
ColorHSV
(
Color3i
(0x8f, 0x00, 0xff)),
// C#
83
ColorHSV
(
Color3i
(0xff, 0xff, 0x00)),
// D
84
ColorHSV
(
Color3i
(0x71, 0x63, 0x95)),
// D#
85
ColorHSV
(
Color3i
(0x4f, 0xa1, 0xc2)),
// E
86
ColorHSV
(
Color3i
(0xc1, 0x01, 0x01)),
// F
87
ColorHSV
(
Color3i
(0x00, 0x00, 0xff)),
// F#
88
ColorHSV
(
Color3i
(0xff, 0x66, 0x00)),
// G
89
ColorHSV
(
Color3i
(0x96, 0x00, 0xff)),
// G#
90
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// A
91
ColorHSV
(
Color3i
(0x71, 0x63, 0x95)),
// A#
92
ColorHSV
(
Color3i
(0x4f, 0xa1, 0xc2))
// B
93
),
94
95
// LUIS BERTRAND CASTEL
96
ColorScheme
(
97
ColorHSV
(
Color3i
(0x00, 0x00, 0xff)),
// C
98
ColorHSV
(
Color3i
(0x0d, 0x98, 0xba)),
// C#
99
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// D
100
ColorHSV
(
Color3i
(0x80, 0x80, 0x00)),
// D#
101
ColorHSV
(
Color3i
(0xff, 0xff, 0x00)),
// E
102
ColorHSV
(
Color3i
(0xff, 0xd7, 0x00)),
// F
103
ColorHSV
(
Color3i
(0xff, 0x5a, 0x00)),
// F#
104
ColorHSV
(
Color3i
(0xff, 0x00, 0x00)),
// G
105
ColorHSV
(
Color3i
(0xdc, 0x14, 0x3c)),
// G#
106
ColorHSV
(
Color3i
(0x8f, 0x00, 0xff)),
// A
107
ColorHSV
(
Color3i
(0x22, 0x00, 0xcd)),
// A#
108
ColorHSV
(
Color3i
(0x5a, 0x00, 0x95))
// B
109
),
110
111
// H VON HELMHOHOLTZ
112
ColorScheme
(
113
ColorHSV
(
Color3i
(0xff, 0xff, 0x06)),
// C
114
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// C#
115
ColorHSV
(
Color3i
(0x21, 0x9e, 0xbd)),
// D
116
ColorHSV
(
Color3i
(0x00, 0x80, 0xff)),
// D#
117
ColorHSV
(
Color3i
(0x6f, 0x00, 0xff)),
// E
118
ColorHSV
(
Color3i
(0x8f, 0x00, 0xff)),
// F
119
ColorHSV
(
Color3i
(0xff, 0x00, 0x00)),
// F#
120
ColorHSV
(
Color3i
(0xff, 0x20, 0x00)),
// G
121
ColorHSV
(
Color3i
(0xff, 0x38, 0x00)),
// G#
122
ColorHSV
(
Color3i
(0xff, 0x3f, 0x00)),
// A
123
ColorHSV
(
Color3i
(0xff, 0x3f, 0x34)),
// A#
124
ColorHSV
(
Color3i
(0xff, 0xa5, 0x00))
// B
125
),
126
127
// ZIEVERINK
128
ColorScheme
(
129
ColorHSV
(
Color3i
(0x9a, 0xcd, 0x32)),
// C
130
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// C#
131
ColorHSV
(
Color3i
(0x00, 0xdd, 0xdd)),
// D
132
ColorHSV
(
Color3i
(0x00, 0x00, 0xff)),
// D#
133
ColorHSV
(
Color3i
(0x6f, 0x00, 0xff)),
// E
134
ColorHSV
(
Color3i
(0x8f, 0x00, 0xff)),
// F
135
ColorHSV
(
Color3i
(0x7f, 0x1a, 0xe5)),
// F#
136
ColorHSV
(
Color3i
(0xbd, 0x00, 0x20)),
// G
137
ColorHSV
(
Color3i
(0xff, 0x00, 0x00)),
// G#
138
ColorHSV
(
Color3i
(0xff, 0x44, 0x00)),
// A
139
ColorHSV
(
Color3i
(0xff, 0xc4, 0x00)),
// A#
140
ColorHSV
(
Color3i
(0xff, 0xff, 0x00))
// B
141
),
142
143
// ROSICRUCIAN ORDER
144
ColorScheme
(
145
ColorHSV
(
Color3i
(0x9a, 0xcd, 0x32)),
// C
146
ColorHSV
(
Color3i
(0x00, 0xff, 0x00)),
// C#
147
ColorHSV
(
Color3i
(0x21, 0x9e, 0xbd)),
// D
148
ColorHSV
(
Color3i
(0x00, 0x00, 0xff)),
// D#
149
ColorHSV
(
Color3i
(0x8a, 0x2b, 0xe2)),
// E
150
ColorHSV
(
Color3i
(0x8b, 0x00, 0xff)),
// F
151
ColorHSV
(
Color3i
(0xf7, 0x53, 0x94)),
// F#
152
ColorHSV
(
Color3i
(0xbd, 0x00, 0x20)),
// G
153
ColorHSV
(
Color3i
(0xee, 0x20, 0x4d)),
// G#
154
ColorHSV
(
Color3i
(0xff, 0x3f, 0x34)),
// A
155
ColorHSV
(
Color3i
(0xff, 0xa5, 0x00)),
// A#
156
ColorHSV
(
Color3i
(0xff, 0xff, 0x00))
// B
157
),
158
};
159
160
static
const
int
n =
sizeof
(color_schemes) /
sizeof
(color_schemes[0]);
161
indx = constrain(indx, 0, n - 1);
162
163
return
color_schemes[indx];
164
};
165
166
const
ColorHSV
SelectColor(
int
midi_note,
float
brightness,
int
color_selector_val) {
167
const
uint8_t fun_note = FundamentalNote(midi_note);
168
const
ColorScheme
& color_scheme = SelectColorScheme(color_selector_val);
169
ColorHSV
color = color_scheme.data[fun_note];
170
color.v_ = brightness;
171
return
color;
172
}
Color3i
Definition
color.h:8
ColorHSV
Definition
color.h:56
ColorScheme
Definition
color_mapper.cpp:15
examples
LuminescentGrand
shared
color_mapper.cpp
Generated on Fri Dec 20 2024 20:54:48 for FastLED by
1.11.0