-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.htm
590 lines (552 loc) · 28.7 KB
/
index.htm
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap CSS -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" />
<link href="index.css" rel="stylesheet" />
<title>LED Mapper</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-68S25LC05F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-68S25LC05F");
</script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">LED Mapper</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item"></li>
</ul>
<span class="navbar-text">
by Jason Coon
<a href="https://leds.social/@jasoncoon" title="Follow @jasoncoon on Mastodon" rel="noopener noreferrer" target="_blank" class="ms-1"
><i class="bi bi-mastodon"></i></a>
<a href="https://www.instagram.com/jasoncoon/" rel="noopener noreferrer" title="@jasoncoon on Instagram" target="_blank" class="ms-1"
><i class="bi bi-instagram"></i
></a>
<a href="https://www.youtube.com/jasoncoon" rel="noopener noreferrer" title="YouTube" target="_blank" class="ms-1"><i class="bi bi-youtube"></i></a>
<a
href="https://evilgeniuslabs.org"
title="evilgeniuslabs.org"
class="ms-1 me-2 text-decoration-none text-muted"
rel="noopener noreferrer"
target="_blank"
>
of Evil Genius Labs</a
>|
<a
href="https://github.com/jasoncoon/led-mapper"
title="Source code on GitHub"
rel="noopener noreferrer"
target="_blank"
class="ms-1 text-decoration-none text-muted"
>Source Code:</a
>
<a href="https://github.com/jasoncoon/led-mapper" title="Source code on GitHub" rel="noopener noreferrer" target="_blank"
><i class="bi bi-github"></i
></a>
</span>
</div>
</div>
</nav>
<div class="container-fluid">
Instructions, examples, and more information:
<a href="https://github.com/jasoncoon/led-mapper/blob/main/README.md" target="_blank" rel="noopener noreferrer">
https://github.com/jasoncoon/led-mapper/blob/main/README.md
</a>
<div class="card mt-1">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="input-tab" data-bs-toggle="tab" data-bs-target="#input" type="button" role="tab" aria-controls="input" aria-selected="true">1. Input</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="config-tab" data-bs-toggle="tab" data-bs-target="#config" type="button" role="tab" aria-controls="config" aria-selected="false">2. Map Config</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="output-tab" data-bs-toggle="tab" data-bs-target="#output" type="button" role="tab" aria-controls="output" aria-selected="false">3. Output</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="controls-tab" data-bs-toggle="tab" data-bs-target="#controls" type="button" role="tab" aria-controls="controls" aria-selected="false">4. Preview Controls</button>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane fade show active" id="input" role="tabpanel" aria-labelledby="input-tab">
<h6 class="mb-2 text-muted">Choose one of the tabs below and follow the instructions for your selected input method.</h6>
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="layout-input-tab"
data-bs-toggle="tab"
data-bs-target="#layout-input"
type="button"
role="tab"
aria-controls="layout-input"
aria-selected="true"
>
Layout
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="coordinates-input-tab"
data-bs-toggle="tab"
data-bs-target="#coordinates-input"
type="button"
role="tab"
aria-controls="coordinates-input"
aria-selected="false"
>
Coordinates
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="pixelblaze-input-tab"
data-bs-toggle="tab"
data-bs-target="#pixelblaze-input"
type="button"
role="tab"
aria-controls="pixelblaze-input"
aria-selected="false"
>
Pixelblaze Map
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="image-input-tab"
data-bs-toggle="tab"
data-bs-target="#image-input"
type="button"
role="tab"
aria-controls="image-input"
aria-selected="false"
>
Image
</button>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane fade show active" id="layout-input" role="tabpanel" aria-labelledby="layout-input-tab">
<div class="text-muted">
Paste an LED layout copied from
<a href="https://sheets.google.com" target="_blank" rel="noopener noreferrer">Google Sheets</a>
or other spreadsheet in tab-delimited text format, with a unique LED index in each cell. LED indices should start at zero. Cells without an LED should be empty.
</div>
<textarea class="form-control" id="textAreaLayout" rows="7" style="white-space: pre; overflow-wrap: normal; overflow-x: auto;"></textarea
>
<div class="btn-toolbar mt-1" role="toolbar">
<div class="btn-group" role="group">
<button id="buttonParseLayout" type="submit" class="btn btn-sm btn-outline-secondary">Parse Layout</button>
<button id="buttonCopyLayout" type="button" class="btn btn-sm btn-outline-secondary">Copy</button>
<button id="buttonLinkLayout" type="button" class="btn btn-sm btn-outline-secondary">Link</button>
</div>
<div class="input-group ms-2">
<div id="layoutError" class="text-danger"></div>
<div class="invisible input-group-text" id="divCopyLayoutInput"></div>
</div>
</div>
</div>
<div class="tab-pane fade" id="coordinates-input" role="tabpanel" aria-labelledby="coordinates-input-tab">
<div class="text-muted">
Paste coordinates copied from
<a href="https://sheets.google.com" target="_blank" rel="noopener noreferrer">Google Sheets</a>
or other spreadsheet in tab-delimited text format. It should have three columns: index, x, and y, with or without column headers.
</div>
<textarea class="form-control" id="textAreaCoordinates" rows="7"></textarea
>
<div class="btn-toolbar mt-1" role="toolbar">
<div class="btn-group" role="group">
<button id="buttonParseCoordinates" type="submit" class="btn btn-sm btn-outline-secondary">Parse Coordinates</button>
<button id="buttonCopyCoordinates" type="button" class="btn btn-sm btn-outline-secondary">Copy</button>
<button id="buttonLinkCoordinates" type="button" class="btn btn-sm btn-outline-secondary">Link</button>
</div>
<div class="input-group ms-2">
<div class="invisible input-group-text" id="divCopyCoordinatesInput"></div>
</div>
</div>
</div>
<div class="tab-pane fade" id="pixelblaze-input" role="tabpanel" aria-labelledby="pixelblaze-input-tab">
<div class="text-muted">
Paste data from your
<a href="https://www.bhencke.com/mapping-in-pixelblaze" target="_blank" rel="noopener noreferrer">Pixelblaze</a>
Mapper tab or
<a href="http://app.bhencke.com/pixelmap.html" target="_blank" rel="noopener noreferrer">Image mapper</a>
in JSON format. It should have one array of [x,y] per LED, all in an array: [[x1,y1],[x2,y2],...] Whitespace does not matter.
</div>
<textarea class="form-control" id="textAreaPixelblaze" rows="4"></textarea
>
<div class="btn-toolbar mt-1" role="toolbar">
<div class="btn-group" role="group">
<button id="buttonParsePixelblaze" type="submit" class="btn btn-sm btn-outline-secondary">Parse Pixelblaze Map</button>
<button id="buttonCopyPixelblazeInput" type="button" class="btn btn-sm btn-outline-secondary">Copy</button>
<button id="buttonLinkPixelblaze" type="button" class="btn btn-sm btn-outline-secondary">Link</button>
</div>
<div class="input-group ms-2">
<div class="invisible input-group-text" id="divCopyPixelblazeInput"></div>
</div>
</div>
</div>
<div class="tab-pane fade" id="image-input" role="tabpanel" aria-labelledby="image-input-tab">
<div>
<span class="text-muted mr-1">
Browse to an image or photo, then click to mark all the LEDs in the order they're wired physically. The Pixelblaze Map tab will be updated with the results.
</span>
<div class="btn-toolbar mt-1" role="toolbar">
<div class="input-group me-2">
<input id="inputImage" type="file" class="form-control" style="width: auto;"></input>
</div>
<div class="btn-group" role="group">
<button id="buttonImageInputUndo" type="button" class="btn btn-outline-secondary" title="Undo (ctrl+z or cmd+z)"><i class="bi bi-arrow-counterclockwise"></i></button>
</div>
</div>
</div>
<div class="mt-1" style="width: 100%">
<canvas id="canvasImageInput" style="width: 100%" width="480" height="768" tabindex="1"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="config" role="tabpanel" aria-labelledby="config-tab">
<h6 class="mb-2 text-muted">Adjust the map's center coordinates, if needed.</h6>
<form class="row g-2" id="form">
<div class="col-sm-2">
<label for="inputWidth" class="form-label">Width</label>
<input class="form-control" id="inputWidth" disabled />
</div>
<div class="col-sm-2">
<label for="inputHeight" class="form-label">Height</label>
<input class="form-control" id="inputHeight" disabled />
</div>
<div class="col-sm-2">
<label for="inputCenterX" class="form-label">Center X</label>
<input type="number" class="form-control" id="inputCenterX" step=".5" />
</div>
<div class="col-sm-2">
<label for="inputCenterY" class="form-label">Center Y</label>
<input type="number" class="form-control" id="inputCenterY" step=".5" />
</div>
<div class="col-sm-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkboxFlipX" />
<label class="form-check-label" for="checkboxFlipX"> Flip X </label>
</div>
</div>
<div class="col-sm-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkboxFlipY" />
<label class="form-check-label" for="checkboxFlipY"> Flip Y </label>
</div>
</div>
</form>
</div>
<div class="tab-pane fade" id="output" role="tabpanel" aria-labelledby="output-tab">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="fastled-output-tab"
data-bs-toggle="tab"
data-bs-target="#fastled-output"
type="button"
role="tab"
aria-controls="fastled-output"
aria-selected="true"
>
FastLED
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="pixelblaze-output-tab"
data-bs-toggle="tab"
data-bs-target="#pixelblaze-output"
type="button"
role="tab"
aria-controls="pixelblaze-output"
aria-selected="false"
>
Pixelblaze
</button>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane fade show active" id="fastled-output" role="tabpanel" aria-labelledby="fastled-output-tab">
<h6 class="mb-2 text-muted">
Copy and paste this into your
<a href="https://www.arduino.cc/en/software" target="_blank" rel="noopener noreferrer">Arduino</a>
sketch for
<a href="https://github.com/FastLED/FastLED" target="_blank" rel="noopener noreferrer">FastLED</a>. Here's an
<a href="https://github.com/jasoncoon/led-mapper/blob/main/fastled-map-demo/fastled-map-demo.ino" target="_blank" rel="noopener noreferrer"
>example sketch</a
>.
</h6>
<pre><code id="codeFastLED"></code></pre>
<div class="btn-toolbar mt-1" role="toolbar">
<button id="buttonCopyCode" type="button" class="btn btn-sm btn-outline-secondary">Copy</button>
<div class="input-group ms-2">
<div class="invisible input-group-text" id="divCopyCode"></div>
</div>
</div>
</div>
<div class="tab-pane fade" id="pixelblaze-output" role="tabpanel" aria-labelledby="pixelblaze-output-tab">
<h6 class="mb-2 text-muted">
Copy and paste this into your
<a href="https://www.bhencke.com/mapping-in-pixelblaze" target="_blank" rel="noopener noreferrer">Pixelblaze</a>
Mapper tab.
</h6>
<pre><code id="codePixelblaze"></code></pre>
<div class="btn-toolbar mt-1" role="toolbar">
<button id="buttonCopyPixelblaze" type="button" class="btn btn-sm btn-outline-secondary">Copy</button>
<div class="input-group ms-2">
<div class="invisible input-group-text" id="divCopyPixelblaze"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="controls" role="tabpanel" aria-labelledby="controls-tab">
<div class="btn-toolbar mt-3 gap-2" role="toolbar">
<div class="input-group">
<div class="input-group-text">Pattern</div>
<select id="selectPattern" class="form-control w-auto">
<option selected>beatsin8</option>
<option>physical order</option>
<option>clockwise palette</option>
<option>counter-clockwise palette</option>
<option>outward palette</option>
<option>inward palette</option>
<option>north palette</option>
<option>northeast palette</option>
<option>east palette</option>
<option>southeast palette</option>
<option>south palette</option>
<option>southwest palette</option>
<option>west palette</option>
<option>northwest palette</option>
<option>red</option>
<option>green</option>
<option>blue</option>
<option>white</option>
<option>custom</option>
</select>
<button id="buttonPreviousPattern" type="button" class="btn btn-sm btn-outline-secondary" title="Previous Pattern">
<i class="bi bi-skip-backward-fill"></i>
</button>
<button id="buttonNextPattern" type="button" class="btn btn-sm btn-outline-secondary" title="Next Pattern">
<i class="bi bi-skip-forward-fill"></i>
</button>
</div>
<div class="btn-group" role="group">
<button id="buttonPlayPause" type="button" title="Pause" class="btn btn-sm btn-outline-secondary">
<i id="iconPlayPause" class="bi bi-pause-fill"></i>
</button>
</div>
<div class="btn-group" role="group" title="Show/Hide LEDs">
<input type="checkbox" class="btn-check" id="checkboxShowPreviewLEDs" checked />
<label class="btn btn-outline-secondary" for="checkboxShowPreviewLEDs">
<i id="iconShowPreviewLEDs" class="bi bi-check-square"></i>
LEDs</label
>
</div>
<div class="btn-group" role="group">
<input type="checkbox" class="btn-check" id="checkboxShowPreviewNumbers" title="Show/Hide LED Numbers" checked />
<label class="btn btn-outline-secondary" for="checkboxShowPreviewNumbers" title="Show/Hide LED Numbers">
<i id="iconShowPreviewNumbers" class="bi bi-square"></i>
Numbers</label
>
<div class="input-group" title="LED Number Text">
<div class="input-group-text">Text</div>
<select id="selectPreviewText" class="form-control" style="width: 5rem">
<option>Index</option>
<option>X</option>
<option>Y</option>
<option>Angle</option>
<option>Radius</option>
</select>
</div>
<div class="input-group" title="LED Numbers Font Size">
<div class="input-group-text">Size</div>
<input id="inputPreviewFontSize" class="form-control" type="number" step="0.25" min="0.25" value="20" style="width: 5rem" />
</div>
</div>
<div class="btn-group" role="group" title="Pattern Speed">
<div class="input-group" title="Pattern Speed">
<div class="input-group-text">Speed</div>
<input id="inputPreviewSpeed" class="form-control" type="number" step="0.1" min="0.1" max="1.0" value="1" style="width: 4rem" />
</div>
</div>
</div>
<div class="btn-toolbar mt-3 gap-2" role="toolbar">
<div class="input-group">
<div class="input-group-text">Palette</div>
<select id="selectPalette" class="form-control w-auto">
<option selected>rainbow</option>
<option>rainbow stripe</option>
<option>cloud</option>
<option>lava</option>
<option>ocean</option>
<option>forest</option>
<option>party</option>
<option>heat</option>
<option>temperature</option>
<option>ib_jul01</option>
</select>
<button id="buttonPreviousPalette" type="button" class="btn btn-sm btn-outline-secondary" title="Previous Palette">
<i class="bi bi-skip-backward-fill"></i>
</button>
<button id="buttonNextPalette" type="button" class="btn btn-sm btn-outline-secondary" title="Next Palette">
<i class="bi bi-skip-forward-fill"></i>
</button>
</div>
<canvas
id="canvasSelectedPalette"
width="256"
height="38"
style="width: 256px; height: 38px; border-radius: 4px"
title="Selected Palette"
></canvas>
<button id="buttonReset" class="btn btn-outline-secondary" title="Reset Pan/Zoom"><i class="bi bi-aspect-ratio"></i> Reset</button>
<button id="buttonToggleScale" class="btn btn-outline-secondary" title="Toggle LED preview scale between input and 256">Scale</button>
</div>
<div class="row mt-3 gap-2">
<div class="btn-group" role="group">
<div class="input-group" title="FastLED Code">
<div class="input-group-text">FastLED Code</div>
<textarea id="inputPreviewCode" class="form-control w-auto" rows="1"></textarea>
<button
class="btn btn-outline-secondary"
type="button"
title="Code help"
data-bs-toggle="collapse"
data-bs-target="#collapseExample"
aria-expanded="false"
aria-controls="collapseExample"
>
?
</button>
</div>
</div>
</div>
<div class="row mt-1">
<div id="renderError" class="col-12 text-danger"></div>
<div class="collapse" id="collapseExample">
<div class="card card-body">
<div class="col-12">
Input parameters: <code>i</code> (LED index), <code>offset</code> (incrementing counter), <code>coordsX</code>, <code>coordsY</code>,
<code>angles</code>, <code>radii</code> (number arrays)
</div>
<div class="col-12">
return <code>CHSV(hue, sat, val)</code>, <code>CRGB(r, g, b)</code>, <code>ColorFromPalette(currentPalette, index)</code>, or any
<a href="https://www.w3schools.com/cssref/css_colors_legal.asp" target="_blank" rel="noopener noreferrer">CSS color</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="panzoom-parent" style="margin: .75rem; border-radius: .25rem;">
<div id="panzoom-element">
<canvas id="canvasPreview"></canvas>
</div>
</div>
<div class="container-fluid">
<div class="accordion mt-1" id="accordionStats">
<div class="accordion-item">
<h2 class="accordion-header" id="headingStats">
<button
class="accordion-button text-decoration-none text-body"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseStats"
aria-expanded="true"
aria-controls="collapseStats"
>
Stats & Debug Info
</button>
</h2>
<div id="collapseStats" class="accordion-collapse collapse show" aria-labelledby="headingStats" data-bs-parent="#accordionStats">
<div class="accordion-body">
Parsed Layout:
<pre><code id="codeParsedLayout"></code></pre>
Parsed Coordinates:
<pre><code id="codeParsedCoordinates"></code></pre>
Parsed Pixelblaze:
<pre><code id="codeParsedPixelblaze"></code></pre>
Stats:
<pre><code id="codeStats"></code></pre>
</div>
</div>
</div>
</div>
<!-- bootstrap breakpoint debug display -->
<!--
<div class="d-block d-sm-none">xs</div>
<div class="d-none d-sm-block d-md-none">sm</div>
<div class="d-none d-md-block d-lg-none">md</div>
<div class="d-none d-lg-block d-xl-none">lg</div>
<div class="d-none d-xl-block d-xxl-none">xl</div>
<div class="d-none d-xxl-block">xxl</div> -->
</div>
<!-- Bootstrap Bundle with Popper -->
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"
></script>
<script src="https://unpkg.com/@panzoom/[email protected]/dist/panzoom.min.js"></script>
<script language="javascript" src="./js/lz-string.min.js"></script>
<script src="index.js" type="module"></script>
</body>
</html>