diff options
author | Ryan <fauxpark@gmail.com> | 2020-12-16 14:24:42 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 14:24:42 +1100 |
commit | 37fb14f1b5cbcb0e5ff60abc9152073635234ba4 (patch) | |
tree | 31b12eb9ee9450ee5f5cf5a3da290e3c4bd81c41 | |
parent | 3925ff534251f44bc21848b5509415c1e41ff419 (diff) | |
download | qmk_firmware-37fb14f1b5cbcb0e5ff60abc9152073635234ba4.tar.gz qmk_firmware-37fb14f1b5cbcb0e5ff60abc9152073635234ba4.zip |
CLI-ify rgblight_breathing_table_calc.c (#11174)
Co-authored-by: Takeshi ISHII <2170248+mtei@users.noreply.github.com>
Co-authored-by: Zach White <skullydazed@drpepper.org>
-rw-r--r-- | docs/cli_commands.md | 10 | ||||
-rw-r--r-- | lib/python/qmk/cli/generate/__init__.py | 1 | ||||
-rw-r--r-- | lib/python/qmk/cli/generate/rgb_breathe_table.py | 79 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 7 | ||||
-rw-r--r-- | quantum/rgblight_breathe_table.h | 563 | ||||
-rw-r--r-- | util/rgblight_breathing_table_calc.c | 49 |
6 files changed, 203 insertions, 506 deletions
diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 69df82f95..71c803bc2 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md | |||
@@ -296,6 +296,16 @@ This command allows you to generate QMK documentation locally. It can be uses fo | |||
296 | qmk generate-docs | 296 | qmk generate-docs |
297 | ``` | 297 | ``` |
298 | 298 | ||
299 | ## `qmk generate-rgb-breathe-table` | ||
300 | |||
301 | This command generates a lookup table (LUT) header file for the [RGB Lighting](feature_rgblight.md) feature's breathing animation. Place this file in your keyboard or keymap directory as `rgblight_breathe_table.h` to override the default LUT in `quantum/`. | ||
302 | |||
303 | **Usage**: | ||
304 | |||
305 | ``` | ||
306 | qmk generate-rgb-breathe-table [-q] [-o OUTPUT] [-m MAX] [-c CENTER] | ||
307 | ``` | ||
308 | |||
299 | ## `qmk kle2json` | 309 | ## `qmk kle2json` |
300 | 310 | ||
301 | This command allows you to convert from raw KLE data to QMK Configurator JSON. It accepts either an absolute file path, or a file name in the current directory. By default it will not overwrite `info.json` if it is already present. Use the `-f` or `--force` flag to overwrite. | 311 | This command allows you to convert from raw KLE data to QMK Configurator JSON. It accepts either an absolute file path, or a file name in the current directory. By default it will not overwrite `info.json` if it is already present. Use the `-f` or `--force` flag to overwrite. |
diff --git a/lib/python/qmk/cli/generate/__init__.py b/lib/python/qmk/cli/generate/__init__.py index 13bd1f091..f9585bfb5 100644 --- a/lib/python/qmk/cli/generate/__init__.py +++ b/lib/python/qmk/cli/generate/__init__.py | |||
@@ -1,2 +1,3 @@ | |||
1 | from . import api | 1 | from . import api |
2 | from . import docs | 2 | from . import docs |
3 | from . import rgb_breathe_table | ||
diff --git a/lib/python/qmk/cli/generate/rgb_breathe_table.py b/lib/python/qmk/cli/generate/rgb_breathe_table.py new file mode 100644 index 000000000..e1c5423ee --- /dev/null +++ b/lib/python/qmk/cli/generate/rgb_breathe_table.py | |||
@@ -0,0 +1,79 @@ | |||
1 | """Generate rgblight_breathe_table.h | ||
2 | """ | ||
3 | import math | ||
4 | from argparse import ArgumentTypeError | ||
5 | |||
6 | from milc import cli | ||
7 | |||
8 | import qmk.path | ||
9 | |||
10 | |||
11 | def breathing_center(value): | ||
12 | value = float(value) | ||
13 | if value >= 1 and value <= 2.7: | ||
14 | return value | ||
15 | else: | ||
16 | raise ArgumentTypeError('Breathing center must be between 1 and 2.7') | ||
17 | |||
18 | |||
19 | def breathing_max(value): | ||
20 | value = int(value) | ||
21 | if value in range(0, 256): | ||
22 | return value | ||
23 | else: | ||
24 | raise ArgumentTypeError('Breathing max must be between 0 and 255') | ||
25 | |||
26 | |||
27 | @cli.argument('-c', '--center', arg_only=True, type=breathing_center, default=1.85, help='The breathing center value, from 1 to 2.7. Default: 1.85') | ||
28 | @cli.argument('-m', '--max', arg_only=True, type=breathing_max, default=255, help='The breathing maximum value, from 0 to 255. Default: 255') | ||
29 | @cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') | ||
30 | @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help='Quiet mode, only output error messages') | ||
31 | @cli.subcommand('Generates an RGB Light breathing table header.') | ||
32 | def generate_rgb_breathe_table(cli): | ||
33 | """Generate a rgblight_breathe_table.h file containing a breathing LUT for RGB Lighting (Underglow) feature. | ||
34 | """ | ||
35 | breathe_values = [0] * 256 | ||
36 | for pos in range(0, 256): | ||
37 | breathe_values[pos] = (int)((math.exp(math.sin((pos/255) * math.pi)) - cli.args.center / math.e) * (cli.args.max / (math.e - 1 / math.e))) # noqa: yapf insists there be no whitespace around / | ||
38 | |||
39 | values_template = '' | ||
40 | for s in range(0, 3): | ||
41 | step = 1 << s | ||
42 | |||
43 | values_template += '#if RGBLIGHT_BREATHE_TABLE_SIZE == {}\n'.format(256 >> s) | ||
44 | |||
45 | for pos in range(0, 256, step): | ||
46 | values_template += ' ' if pos % 8 == 0 else '' | ||
47 | values_template += '0x{:02X}'.format(breathe_values[pos]) | ||
48 | values_template += ',' if (pos + step) < 256 else '' | ||
49 | values_template += '\n' if (pos+step) % 8 == 0 else ' ' # noqa: yapf insists there be no whitespace around + | ||
50 | |||
51 | values_template += '#endif' | ||
52 | values_template += '\n\n' if s < 2 else '' | ||
53 | |||
54 | table_template = '''#pragma once | ||
55 | |||
56 | #define RGBLIGHT_EFFECT_BREATHE_TABLE | ||
57 | |||
58 | // clang-format off | ||
59 | |||
60 | // Breathing center: {0:.2f} | ||
61 | // Breathing max: {1:d} | ||
62 | |||
63 | const uint8_t PROGMEM rgblight_effect_breathe_table[] = {{ | ||
64 | {2} | ||
65 | }}; | ||
66 | |||
67 | static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table); | ||
68 | '''.format(cli.args.center, cli.args.max, values_template) | ||
69 | |||
70 | if cli.args.output: | ||
71 | cli.args.output.parent.mkdir(parents=True, exist_ok=True) | ||
72 | if cli.args.output.exists(): | ||
73 | cli.args.output.replace(cli.args.output.name + '.bak') | ||
74 | cli.args.output.write_text(table_template) | ||
75 | |||
76 | if not cli.args.quiet: | ||
77 | cli.log.info('Wrote header to %s.', cli.args.output) | ||
78 | else: | ||
79 | print(table_template) | ||
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 99ec59608..08e80f2c9 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
@@ -190,3 +190,10 @@ def test_clean(): | |||
190 | result = check_subcommand('clean', '-a') | 190 | result = check_subcommand('clean', '-a') |
191 | check_returncode(result) | 191 | check_returncode(result) |
192 | assert result.stdout.count('done') == 2 | 192 | assert result.stdout.count('done') == 2 |
193 | |||
194 | |||
195 | def test_generate_rgb_breathe_table(): | ||
196 | result = check_subcommand("generate-rgb-breathe-table", "-c", "1.2", "-m", "127") | ||
197 | check_returncode(result) | ||
198 | assert 'Breathing center: 1.2' in result.stdout | ||
199 | assert 'Breathing max: 127' in result.stdout | ||
diff --git a/quantum/rgblight_breathe_table.h b/quantum/rgblight_breathe_table.h index a438332bd..30245318b 100644 --- a/quantum/rgblight_breathe_table.h +++ b/quantum/rgblight_breathe_table.h | |||
@@ -1,468 +1,117 @@ | |||
1 | #ifndef RGBLIGHT_EFFECT_BREATHE_TABLE | 1 | #pragma once |
2 | |||
2 | #define RGBLIGHT_EFFECT_BREATHE_TABLE | 3 | #define RGBLIGHT_EFFECT_BREATHE_TABLE |
3 | 4 | ||
4 | const uint8_t rgblight_effect_breathe_table[] PROGMEM = { | 5 | // clang-format off |
5 | /* #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 */ | 6 | |
6 | /* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */ | 7 | // Breathing center: 1.85 |
8 | // Breathing max: 255 | ||
7 | 9 | ||
10 | const uint8_t PROGMEM rgblight_effect_breathe_table[] = { | ||
8 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 256 | 11 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 256 |
9 | 0x22, | 12 | 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2C, |
10 | 0x23, | 13 | 0x2D, 0x2F, 0x30, 0x32, 0x33, 0x35, 0x36, 0x38, |
11 | 0x25, | 14 | 0x3A, 0x3B, 0x3D, 0x3E, 0x40, 0x42, 0x43, 0x45, |
12 | 0x26, | 15 | 0x47, 0x49, 0x4A, 0x4C, 0x4E, 0x50, 0x51, 0x53, |
13 | 0x28, | 16 | 0x55, 0x57, 0x59, 0x5A, 0x5C, 0x5E, 0x60, 0x62, |
14 | 0x29, | 17 | 0x64, 0x66, 0x68, 0x69, 0x6B, 0x6D, 0x6F, 0x71, |
15 | 0x2a, | 18 | 0x73, 0x75, 0x77, 0x79, 0x7B, 0x7D, 0x7F, 0x81, |
16 | 0x2c, | 19 | 0x83, 0x85, 0x87, 0x89, 0x8A, 0x8C, 0x8E, 0x90, |
17 | 0x2d, | 20 | 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E, 0x9F, |
18 | 0x2f, | 21 | 0xA1, 0xA3, 0xA5, 0xA7, 0xA8, 0xAA, 0xAC, 0xAE, |
19 | 0x30, | 22 | 0xAF, 0xB1, 0xB3, 0xB4, 0xB6, 0xB8, 0xB9, 0xBB, |
20 | 0x32, | 23 | 0xBC, 0xBE, 0xBF, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, |
21 | 0x33, | 24 | 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xD0, |
22 | 0x35, | 25 | 0xD1, 0xD2, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, |
23 | 0x36, | 26 | 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDA, 0xDB, 0xDB, |
24 | 0x38, | 27 | 0xDB, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDD, 0xDD, |
25 | 0x3a, | 28 | 0xDD, 0xDD, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB, |
26 | 0x3b, | 29 | 0xDB, 0xDB, 0xDA, 0xDA, 0xD9, 0xD9, 0xD8, 0xD7, |
27 | 0x3d, | 30 | 0xD7, 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD2, 0xD1, |
28 | 0x3e, | 31 | 0xD0, 0xCE, 0xCD, 0xCC, 0xCB, 0xCA, 0xC9, 0xC7, |
29 | 0x40, | 32 | 0xC6, 0xC5, 0xC3, 0xC2, 0xC1, 0xBF, 0xBE, 0xBC, |
30 | 0x42, | 33 | 0xBB, 0xB9, 0xB8, 0xB6, 0xB4, 0xB3, 0xB1, 0xAF, |
31 | 0x43, | 34 | 0xAE, 0xAC, 0xAA, 0xA8, 0xA7, 0xA5, 0xA3, 0xA1, |
32 | 0x45, | 35 | 0x9F, 0x9E, 0x9C, 0x9A, 0x98, 0x96, 0x94, 0x92, |
33 | 0x47, | 36 | 0x90, 0x8E, 0x8C, 0x8A, 0x89, 0x87, 0x85, 0x83, |
34 | 0x49, | 37 | 0x81, 0x7F, 0x7D, 0x7B, 0x79, 0x77, 0x75, 0x73, |
35 | 0x4a, | 38 | 0x71, 0x6F, 0x6D, 0x6B, 0x69, 0x68, 0x66, 0x64, |
36 | 0x4c, | 39 | 0x62, 0x60, 0x5E, 0x5C, 0x5A, 0x59, 0x57, 0x55, |
37 | 0x4e, | 40 | 0x53, 0x51, 0x50, 0x4E, 0x4C, 0x4A, 0x49, 0x47, |
38 | 0x50, | 41 | 0x45, 0x43, 0x42, 0x40, 0x3E, 0x3D, 0x3B, 0x3A, |
39 | 0x51, | 42 | 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2D, |
40 | 0x53, | 43 | 0x2C, 0x2A, 0x29, 0x28, 0x26, 0x25, 0x23, 0x22 |
41 | 0x55, | 44 | #endif |
42 | 0x57, | ||
43 | 0x59, | ||
44 | 0x5a, | ||
45 | 0x5c, | ||
46 | 0x5e, | ||
47 | 0x60, | ||
48 | 0x62, | ||
49 | 0x64, | ||
50 | 0x66, | ||
51 | 0x68, | ||
52 | 0x69, | ||
53 | 0x6b, | ||
54 | 0x6d, | ||
55 | 0x6f, | ||
56 | 0x71, | ||
57 | 0x73, | ||
58 | 0x75, | ||
59 | 0x77, | ||
60 | 0x79, | ||
61 | 0x7b, | ||
62 | 0x7d, | ||
63 | 0x7f, | ||
64 | 0x81, | ||
65 | 0x83, | ||
66 | 0x85, | ||
67 | 0x87, | ||
68 | 0x89, | ||
69 | 0x8a, | ||
70 | 0x8c, | ||
71 | 0x8e, | ||
72 | 0x90, | ||
73 | 0x92, | ||
74 | 0x94, | ||
75 | 0x96, | ||
76 | 0x98, | ||
77 | 0x9a, | ||
78 | 0x9c, | ||
79 | 0x9e, | ||
80 | 0x9f, | ||
81 | 0xa1, | ||
82 | 0xa3, | ||
83 | 0xa5, | ||
84 | 0xa7, | ||
85 | 0xa8, | ||
86 | 0xaa, | ||
87 | 0xac, | ||
88 | 0xae, | ||
89 | 0xaf, | ||
90 | 0xb1, | ||
91 | 0xb3, | ||
92 | 0xb4, | ||
93 | 0xb6, | ||
94 | 0xb8, | ||
95 | 0xb9, | ||
96 | 0xbb, | ||
97 | 0xbc, | ||
98 | 0xbe, | ||
99 | 0xbf, | ||
100 | 0xc1, | ||
101 | 0xc2, | ||
102 | 0xc3, | ||
103 | 0xc5, | ||
104 | 0xc6, | ||
105 | 0xc7, | ||
106 | 0xc9, | ||
107 | 0xca, | ||
108 | 0xcb, | ||
109 | 0xcc, | ||
110 | 0xcd, | ||
111 | 0xce, | ||
112 | 0xd0, | ||
113 | 0xd1, | ||
114 | 0xd2, | ||
115 | 0xd2, | ||
116 | 0xd3, | ||
117 | 0xd4, | ||
118 | 0xd5, | ||
119 | 0xd6, | ||
120 | 0xd7, | ||
121 | 0xd7, | ||
122 | 0xd8, | ||
123 | 0xd9, | ||
124 | 0xd9, | ||
125 | 0xda, | ||
126 | 0xda, | ||
127 | 0xdb, | ||
128 | 0xdb, | ||
129 | 0xdb, | ||
130 | 0xdc, | ||
131 | 0xdc, | ||
132 | 0xdc, | ||
133 | 0xdc, | ||
134 | 0xdc, | ||
135 | 0xdd, | ||
136 | 0xdd, | ||
137 | 0xdd, | ||
138 | 0xdd, | ||
139 | 0xdc, | ||
140 | 0xdc, | ||
141 | 0xdc, | ||
142 | 0xdc, | ||
143 | 0xdc, | ||
144 | 0xdb, | ||
145 | 0xdb, | ||
146 | 0xdb, | ||
147 | 0xda, | ||
148 | 0xda, | ||
149 | 0xd9, | ||
150 | 0xd9, | ||
151 | 0xd8, | ||
152 | 0xd7, | ||
153 | 0xd7, | ||
154 | 0xd6, | ||
155 | 0xd5, | ||
156 | 0xd4, | ||
157 | 0xd3, | ||
158 | 0xd2, | ||
159 | 0xd2, | ||
160 | 0xd1, | ||
161 | 0xd0, | ||
162 | 0xce, | ||
163 | 0xcd, | ||
164 | 0xcc, | ||
165 | 0xcb, | ||
166 | 0xca, | ||
167 | 0xc9, | ||
168 | 0xc7, | ||
169 | 0xc6, | ||
170 | 0xc5, | ||
171 | 0xc3, | ||
172 | 0xc2, | ||
173 | 0xc1, | ||
174 | 0xbf, | ||
175 | 0xbe, | ||
176 | 0xbc, | ||
177 | 0xbb, | ||
178 | 0xb9, | ||
179 | 0xb8, | ||
180 | 0xb6, | ||
181 | 0xb4, | ||
182 | 0xb3, | ||
183 | 0xb1, | ||
184 | 0xaf, | ||
185 | 0xae, | ||
186 | 0xac, | ||
187 | 0xaa, | ||
188 | 0xa8, | ||
189 | 0xa7, | ||
190 | 0xa5, | ||
191 | 0xa3, | ||
192 | 0xa1, | ||
193 | 0x9f, | ||
194 | 0x9e, | ||
195 | 0x9c, | ||
196 | 0x9a, | ||
197 | 0x98, | ||
198 | 0x96, | ||
199 | 0x94, | ||
200 | 0x92, | ||
201 | 0x90, | ||
202 | 0x8e, | ||
203 | 0x8c, | ||
204 | 0x8a, | ||
205 | 0x89, | ||
206 | 0x87, | ||
207 | 0x85, | ||
208 | 0x83, | ||
209 | 0x81, | ||
210 | 0x7f, | ||
211 | 0x7d, | ||
212 | 0x7b, | ||
213 | 0x79, | ||
214 | 0x77, | ||
215 | 0x75, | ||
216 | 0x73, | ||
217 | 0x71, | ||
218 | 0x6f, | ||
219 | 0x6d, | ||
220 | 0x6b, | ||
221 | 0x69, | ||
222 | 0x68, | ||
223 | 0x66, | ||
224 | 0x64, | ||
225 | 0x62, | ||
226 | 0x60, | ||
227 | 0x5e, | ||
228 | 0x5c, | ||
229 | 0x5a, | ||
230 | 0x59, | ||
231 | 0x57, | ||
232 | 0x55, | ||
233 | 0x53, | ||
234 | 0x51, | ||
235 | 0x50, | ||
236 | 0x4e, | ||
237 | 0x4c, | ||
238 | 0x4a, | ||
239 | 0x49, | ||
240 | 0x47, | ||
241 | 0x45, | ||
242 | 0x43, | ||
243 | 0x42, | ||
244 | 0x40, | ||
245 | 0x3e, | ||
246 | 0x3d, | ||
247 | 0x3b, | ||
248 | 0x3a, | ||
249 | 0x38, | ||
250 | 0x36, | ||
251 | 0x35, | ||
252 | 0x33, | ||
253 | 0x32, | ||
254 | 0x30, | ||
255 | 0x2f, | ||
256 | 0x2d, | ||
257 | 0x2c, | ||
258 | 0x2a, | ||
259 | 0x29, | ||
260 | 0x28, | ||
261 | 0x26, | ||
262 | 0x25, | ||
263 | 0x23, | ||
264 | 0x22 | ||
265 | #endif /* 256 bytes table */ | ||
266 | 45 | ||
267 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 128 | 46 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 128 |
268 | 0x22, | 47 | 0x22, 0x25, 0x28, 0x2A, |
269 | 0x25, | 48 | 0x2D, 0x30, 0x33, 0x36, |
270 | 0x28, | 49 | 0x3A, 0x3D, 0x40, 0x43, |
271 | 0x2a, | 50 | 0x47, 0x4A, 0x4E, 0x51, |
272 | 0x2d, | 51 | 0x55, 0x59, 0x5C, 0x60, |
273 | 0x30, | 52 | 0x64, 0x68, 0x6B, 0x6F, |
274 | 0x33, | 53 | 0x73, 0x77, 0x7B, 0x7F, |
275 | 0x36, | 54 | 0x83, 0x87, 0x8A, 0x8E, |
276 | 0x3a, | 55 | 0x92, 0x96, 0x9A, 0x9E, |
277 | 0x3d, | 56 | 0xA1, 0xA5, 0xA8, 0xAC, |
278 | 0x40, | 57 | 0xAF, 0xB3, 0xB6, 0xB9, |
279 | 0x43, | 58 | 0xBC, 0xBF, 0xC2, 0xC5, |
280 | 0x47, | 59 | 0xC7, 0xCA, 0xCC, 0xCE, |
281 | 0x4a, | 60 | 0xD1, 0xD2, 0xD4, 0xD6, |
282 | 0x4e, | 61 | 0xD7, 0xD9, 0xDA, 0xDB, |
283 | 0x51, | 62 | 0xDB, 0xDC, 0xDC, 0xDD, |
284 | 0x55, | 63 | 0xDD, 0xDC, 0xDC, 0xDC, |
285 | 0x59, | 64 | 0xDB, 0xDA, 0xD9, 0xD8, |
286 | 0x5c, | 65 | 0xD7, 0xD5, 0xD3, 0xD2, |
287 | 0x60, | 66 | 0xD0, 0xCD, 0xCB, 0xC9, |
288 | 0x64, | 67 | 0xC6, 0xC3, 0xC1, 0xBE, |
289 | 0x68, | 68 | 0xBB, 0xB8, 0xB4, 0xB1, |
290 | 0x6b, | 69 | 0xAE, 0xAA, 0xA7, 0xA3, |
291 | 0x6f, | 70 | 0x9F, 0x9C, 0x98, 0x94, |
292 | 0x73, | 71 | 0x90, 0x8C, 0x89, 0x85, |
293 | 0x77, | 72 | 0x81, 0x7D, 0x79, 0x75, |
294 | 0x7b, | 73 | 0x71, 0x6D, 0x69, 0x66, |
295 | 0x7f, | 74 | 0x62, 0x5E, 0x5A, 0x57, |
296 | 0x83, | 75 | 0x53, 0x50, 0x4C, 0x49, |
297 | 0x87, | 76 | 0x45, 0x42, 0x3E, 0x3B, |
298 | 0x8a, | 77 | 0x38, 0x35, 0x32, 0x2F, |
299 | 0x8e, | 78 | 0x2C, 0x29, 0x26, 0x23 |
300 | 0x92, | 79 | #endif |
301 | 0x96, | ||
302 | 0x9a, | ||
303 | 0x9e, | ||
304 | 0xa1, | ||
305 | 0xa5, | ||
306 | 0xa8, | ||
307 | 0xac, | ||
308 | 0xaf, | ||
309 | 0xb3, | ||
310 | 0xb6, | ||
311 | 0xb9, | ||
312 | 0xbc, | ||
313 | 0xbf, | ||
314 | 0xc2, | ||
315 | 0xc5, | ||
316 | 0xc7, | ||
317 | 0xca, | ||
318 | 0xcc, | ||
319 | 0xce, | ||
320 | 0xd1, | ||
321 | 0xd2, | ||
322 | 0xd4, | ||
323 | 0xd6, | ||
324 | 0xd7, | ||
325 | 0xd9, | ||
326 | 0xda, | ||
327 | 0xdb, | ||
328 | 0xdb, | ||
329 | 0xdc, | ||
330 | 0xdc, | ||
331 | 0xdd, | ||
332 | 0xdd, | ||
333 | 0xdc, | ||
334 | 0xdc, | ||
335 | 0xdc, | ||
336 | 0xdb, | ||
337 | 0xda, | ||
338 | 0xd9, | ||
339 | 0xd8, | ||
340 | 0xd7, | ||
341 | 0xd5, | ||
342 | 0xd3, | ||
343 | 0xd2, | ||
344 | 0xd0, | ||
345 | 0xcd, | ||
346 | 0xcb, | ||
347 | 0xc9, | ||
348 | 0xc6, | ||
349 | 0xc3, | ||
350 | 0xc1, | ||
351 | 0xbe, | ||
352 | 0xbb, | ||
353 | 0xb8, | ||
354 | 0xb4, | ||
355 | 0xb1, | ||
356 | 0xae, | ||
357 | 0xaa, | ||
358 | 0xa7, | ||
359 | 0xa3, | ||
360 | 0x9f, | ||
361 | 0x9c, | ||
362 | 0x98, | ||
363 | 0x94, | ||
364 | 0x90, | ||
365 | 0x8c, | ||
366 | 0x89, | ||
367 | 0x85, | ||
368 | 0x81, | ||
369 | 0x7d, | ||
370 | 0x79, | ||
371 | 0x75, | ||
372 | 0x71, | ||
373 | 0x6d, | ||
374 | 0x69, | ||
375 | 0x66, | ||
376 | 0x62, | ||
377 | 0x5e, | ||
378 | 0x5a, | ||
379 | 0x57, | ||
380 | 0x53, | ||
381 | 0x50, | ||
382 | 0x4c, | ||
383 | 0x49, | ||
384 | 0x45, | ||
385 | 0x42, | ||
386 | 0x3e, | ||
387 | 0x3b, | ||
388 | 0x38, | ||
389 | 0x35, | ||
390 | 0x32, | ||
391 | 0x2f, | ||
392 | 0x2c, | ||
393 | 0x29, | ||
394 | 0x26, | ||
395 | 0x23 | ||
396 | #endif /* 128 bytes table */ | ||
397 | 80 | ||
398 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 64 | 81 | #if RGBLIGHT_BREATHE_TABLE_SIZE == 64 |
399 | 0x22, | 82 | 0x22, 0x28, |
400 | 0x28, | 83 | 0x2D, 0x33, |
401 | 0x2d, | 84 | 0x3A, 0x40, |
402 | 0x33, | 85 | 0x47, 0x4E, |
403 | 0x3a, | 86 | 0x55, 0x5C, |
404 | 0x40, | 87 | 0x64, 0x6B, |
405 | 0x47, | 88 | 0x73, 0x7B, |
406 | 0x4e, | 89 | 0x83, 0x8A, |
407 | 0x55, | 90 | 0x92, 0x9A, |
408 | 0x5c, | 91 | 0xA1, 0xA8, |
409 | 0x64, | 92 | 0xAF, 0xB6, |
410 | 0x6b, | 93 | 0xBC, 0xC2, |
411 | 0x73, | 94 | 0xC7, 0xCC, |
412 | 0x7b, | 95 | 0xD1, 0xD4, |
413 | 0x83, | 96 | 0xD7, 0xDA, |
414 | 0x8a, | 97 | 0xDB, 0xDC, |
415 | 0x92, | 98 | 0xDD, 0xDC, |
416 | 0x9a, | 99 | 0xDB, 0xD9, |
417 | 0xa1, | 100 | 0xD7, 0xD3, |
418 | 0xa8, | 101 | 0xD0, 0xCB, |
419 | 0xaf, | 102 | 0xC6, 0xC1, |
420 | 0xb6, | 103 | 0xBB, 0xB4, |
421 | 0xbc, | 104 | 0xAE, 0xA7, |
422 | 0xc2, | 105 | 0x9F, 0x98, |
423 | 0xc7, | 106 | 0x90, 0x89, |
424 | 0xcc, | 107 | 0x81, 0x79, |
425 | 0xd1, | 108 | 0x71, 0x69, |
426 | 0xd4, | 109 | 0x62, 0x5A, |
427 | 0xd7, | 110 | 0x53, 0x4C, |
428 | 0xda, | 111 | 0x45, 0x3E, |
429 | 0xdb, | 112 | 0x38, 0x32, |
430 | 0xdc, | 113 | 0x2C, 0x26 |
431 | 0xdd, | 114 | #endif |
432 | 0xdc, | ||
433 | 0xdb, | ||
434 | 0xd9, | ||
435 | 0xd7, | ||
436 | 0xd3, | ||
437 | 0xd0, | ||
438 | 0xcb, | ||
439 | 0xc6, | ||
440 | 0xc1, | ||
441 | 0xbb, | ||
442 | 0xb4, | ||
443 | 0xae, | ||
444 | 0xa7, | ||
445 | 0x9f, | ||
446 | 0x98, | ||
447 | 0x90, | ||
448 | 0x89, | ||
449 | 0x81, | ||
450 | 0x79, | ||
451 | 0x71, | ||
452 | 0x69, | ||
453 | 0x62, | ||
454 | 0x5a, | ||
455 | 0x53, | ||
456 | 0x4c, | ||
457 | 0x45, | ||
458 | 0x3e, | ||
459 | 0x38, | ||
460 | 0x32, | ||
461 | 0x2c, | ||
462 | 0x26 | ||
463 | #endif /* 64 bytes table */ | ||
464 | }; | 115 | }; |
465 | 116 | ||
466 | static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table); | 117 | static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table); |
467 | |||
468 | #endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */ | ||
diff --git a/util/rgblight_breathing_table_calc.c b/util/rgblight_breathing_table_calc.c deleted file mode 100644 index fc4d49ea5..000000000 --- a/util/rgblight_breathing_table_calc.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | // | ||
2 | // calculate rgblight_effect_breathe_table[] values | ||
3 | // | ||
4 | // this is host program for quantum/rgblight.c:void rgblight_effect_breathing(); | ||
5 | // | ||
6 | // example: | ||
7 | // $ edit util/rgblight_breathing_table_calc.c | ||
8 | // $ cc -o util/rgblight_breathing_table_calc util/rgblight_breathing_table_calc.c | ||
9 | // $ ./util/rgblight_breathing_table_calc > keyboards/KEYBOARD_NAME/keymaps/KEYMAP_NAME/rgblight_breathe_table.h | ||
10 | // | ||
11 | #include <stdio.h> | ||
12 | #include <math.h> | ||
13 | #include <stdint.h> | ||
14 | |||
15 | /// customize breeathing effect part /////////////////////////// | ||
16 | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7 | ||
17 | #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 | ||
18 | //////////////////////////////////////////////////////////////// | ||
19 | |||
20 | int main(void) { | ||
21 | int pos, step; | ||
22 | int table[256]; | ||
23 | for (pos = 0; pos < 256; pos ++ ) { | ||
24 | table[pos] = (uint8_t)( | ||
25 | (exp(sin((pos/255.0)*M_PI))- RGBLIGHT_EFFECT_BREATHE_CENTER/M_E) | ||
26 | * (RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)) | ||
27 | ); | ||
28 | } | ||
29 | printf("#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE\n"); | ||
30 | printf("#define RGBLIGHT_EFFECT_BREATHE_TABLE\n\n"); | ||
31 | printf("const uint8_t rgblight_effect_breathe_table[] PROGMEM = {\n"); | ||
32 | printf(" /* #define RGBLIGHT_EFFECT_BREATHE_CENTER %.2f */\n", RGBLIGHT_EFFECT_BREATHE_CENTER); | ||
33 | printf(" /* #define RGBLIGHT_EFFECT_BREATHE_MAX %d */\n", RGBLIGHT_EFFECT_BREATHE_MAX); | ||
34 | |||
35 | for (int s = 0, step = (1<<s); s < 3 ; s += 1, step = (1<<s) ) { | ||
36 | printf("\n #if RGBLIGHT_BREATHE_TABLE_SIZE == %d\n", | ||
37 | s == 0 ? 256:(s== 1 ? 128: 64)); | ||
38 | for (pos = 0; pos < 256; pos += step ) { | ||
39 | printf(" 0x%x%s", table[pos], (pos+step)>=256?"":"," ); | ||
40 | if ((pos+step) % 8 == 0) | ||
41 | printf("\n"); | ||
42 | } | ||
43 | printf(" #endif /* %d bytes table */\n", s == 0 ? 256:(s== 1 ? 128: 64)); | ||
44 | } | ||
45 | printf("};\n"); | ||
46 | printf("\nstatic const int table_scale = 256/sizeof(rgblight_effect_breathe_table);\n"); | ||
47 | printf("\n#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */\n"); | ||
48 | return 0; | ||
49 | } | ||