Repository navigation
Expand file tree
/
Copy pathread.html
More file actions
700 lines (650 loc) · 20.3 KB
/
Copy pathread.html
File metadata and controls
700 lines (650 loc) · 20.3 KB
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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
---
title: Read a Tag
layout: single
description: A tool to read and display the data stored on an OpenTag3D tag.
---
<style>
* {
box-sizing: border-box;
}
.muted {
color: var(--muted);
}
.flex {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
#controls {
margin-bottom: 1em;
}
/* --- Tag display --- */
#tagEmptyState {
padding: 3em 1em;
text-align: center;
}
.tag-header {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 20px;
}
.tag-header h2 {
margin: 4px 0 0;
font-size: 2em;
border-bottom: none;
}
.tag-header .material-name {
font-size: 1.6em;
font-weight: 600;
text-align: right;
}
.tag-header .material-mod {
color: var(--muted);
}
.tag-header .material-specs {
text-align: right;
}
.tag-header .material-tolerance {
color: var(--muted);
font-size: 0.85em;
}
.tag-id-list {
display: grid;
gap: 6px;
margin-top: 10px;
}
.tag-id-row {
display: flex;
justify-content: space-between;
gap: 12px;
font-size: 13px;
}
.tag-id-row .tag-stat-label {
margin-bottom: 0;
}
.tag-color-preview {
margin-bottom: 16px;
}
.tag-panel {
border-radius: 10px;
padding: 14px 16px;
margin-bottom: 16px;
}
.tag-panel__heading {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.tag-panel__icon {
width: 20px;
height: 20px;
object-fit: contain;
opacity: 0.8;
}
.tag-panel__heading .tag-stat-label {
margin-bottom: 0;
}
.tag-header__icon {
width: 18px;
height: 18px;
margin-right: 6px;
vertical-align: -3px;
opacity: 0.8;
}
.tag-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 16px;
}
.tag-grid--wide {
grid-template-columns: repeat(3, 1fr);
}
.tag-grid--2col {
grid-template-columns: repeat(2, 1fr);
}
.tag-stat-label {
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--muted);
margin-bottom: 6px;
}
.tag-stat-value {
font-size: 1.3em;
font-weight: 600;
}
.tag-stat-subvalue,
.tag-stat-divider {
font-size: 13px;
color: var(--muted);
margin-top: 2px;
}
.color-swatches {
display: flex;
width: 100%;
height: 64px;
margin-bottom: 10px;
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
}
.color-swatch {
flex: 1;
background-image: url(/assets/images/transparency-grid.jpg);
background-size: cover;
}
.color-hex-list {
font-size: 12px;
color: var(--muted);
line-height: 1.6;
}
.tag-footer {
text-align: center;
font-size: 13px;
color: var(--muted);
}
@media screen and (max-width: 900px), screen and (max-device-width: 900px) {
.tag-header,
.tag-grid,
.tag-grid--wide {
grid-template-columns: 1fr;
}
}
@media screen and (max-width: 600px), screen and (max-device-width: 600px) {
.tag-grid--2col {
grid-template-columns: 1fr;
}
}
</style>
<p>
This is a utility to read OpenTag3D tag data and display it in a friendly
format.
</p>
<main>
<div id="controls" class="flex">
<button class="btn btn--warning" id="loadFileBtn">
<img
class="control-icon"
src="{{ '/assets/images/icons/icons8-archive.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
Load File
</button>
<button class="btn btn--warning" id="loadClipboardBtn">
<img
class="control-icon"
src="{{ '/assets/images/icons/icons8-clipboard.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
Load from Clipboard
</button>
<input
type="file"
id="uploadFile"
accept=".bin,.nfc,.txt,.hex,.json"
style="display: none"
/>
</div>
<div id="tagEmptyState" class="muted">
No tag data loaded yet.<br />You can load a tag dump from a file or from the
clipboard, or scan a tag using Web NFC (if your device supports it).
</div>
<div id="tagDisplay" hidden>
<div class="tag-header">
<div>
<div id="tagManufacturer"></div>
<h2 id="tagColorName"></h2>
<div id="tagColorSwatches" class="color-swatches"></div>
<div id="tagColorHexes" class="color-hex-list"></div>
<div id="tagTd" class="tag-stat-subvalue"></div>
</div>
<div>
<div class="material-name">
<span id="tagMaterial"></span>
<span id="tagMaterialMod" class="material-mod"></span>
</div>
<div class="material-specs">
<span id="tagWeight"></span> —
<strong id="tagDiameter"></strong>
<em id="tagTolerance" class="material-tolerance"></em>
</div>
<div class="tag-id-list">
<div class="tag-id-row">
<span class="tag-stat-label">OpenTag3D Version</span>
<span id="tagVersion"></span>
</div>
<div class="tag-id-row">
<span class="tag-stat-label">Serial Number</span>
<span id="tagSerial"></span>
</div>
<div class="tag-id-row">
<span class="tag-stat-label">Manufacture Date</span>
<span id="tagMfgDate"></span>
</div>
<div class="tag-id-row">
<span class="tag-stat-label">SKU</span>
<span id="tagSku"></span>
</div>
<div class="tag-id-row">
<span class="tag-stat-label">Barcode</span>
<span id="tagBarcode"></span>
</div>
</div>
</div>
</div>
<div class="tag-panel">
<div class="tag-grid--wide" style="display: grid; gap: 16px">
<div>
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/mdi-nozzle-printing.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Print Temp</div>
</div>
<div id="tagPrintTemp" class="tag-stat-value"></div>
<div id="tagPrintTempRange" class="tag-stat-subvalue"></div>
</div>
<div>
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/mdi-bed.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Bed Temp</div>
</div>
<div id="tagBedTemp" class="tag-stat-value"></div>
<div id="tagBedTempRange" class="tag-stat-subvalue"></div>
</div>
<div>
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/vecteezy-chamber.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Chamber Temp</div>
</div>
<div id="tagChamberTemp" class="tag-stat-value"></div>
</div>
</div>
</div>
<div class="tag-grid">
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/vecteezy-nozzle.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Minimum Nozzle Diameter</div>
</div>
<div id="tagNozzle" class="tag-stat-value"></div>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-microwave.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Recommended Drying Time + Temp</div>
</div>
<span id="tagDryTime" class="tag-stat-value"></span> —
<span id="tagDryTemp" class="tag-stat-value"></span>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/vecteezy-chemistry.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Target VSO</div>
</div>
<div id="tagTargetVso" class="tag-stat-value"></div>
<div id="tagVsoRange" class="tag-stat-subvalue"></div>
</div>
</div>
<div class="tag-grid">
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-length.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Measured Length</div>
</div>
<div id="tagMeasuredLength" class="tag-stat-value"></div>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-weight.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Measured Weight</div>
</div>
<div id="tagMeasuredWeight" class="tag-stat-value"></div>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-weight.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Empty Spool Weight</div>
</div>
<div id="tagSpoolWeight" class="tag-stat-value"></div>
</div>
</div>
<div class="tag-grid">
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-diameter.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Core Diameter</div>
</div>
<div id="tagSpoolCoreDiameter" class="tag-stat-value"></div>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/vecteezy-density.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">Density</div>
</div>
<div id="tagDensity" class="tag-stat-value"></div>
</div>
<div class="tag-panel">
<div class="tag-panel__heading">
<img
class="tag-panel__icon"
src="{{ '/assets/images/icons/icons8-microwave.svg' | relative_url }}"
alt=""
aria-hidden="true"
/>
<div class="tag-stat-label">MFI Temp / Load / Value</div>
</div>
<div id="tagMfiTemp" class="tag-stat-value"></div>
<div id="tagMfiLoadValue" class="tag-stat-subvalue"></div>
</div>
</div>
<div id="tagFooter" class="tag-footer"></div>
</div>
<details class="scroll" id="hexdumpBox" hidden>
<summary>Show hex dump</summary>
<pre id="hexdump" class="mono"></pre>
</details>
</main>
<script>
/* prettier-ignore-start */
// Spec comes from site.data.spec (Jekyll).
globalThis.OpenTag3D = { spec: {{site.data.spec | jsonify}} };
/* prettier-ignore-end */
</script>
<script type="module">
import { msg } from "{{ '/assets/scripts/site.js' | relative_url }}";
import {
allFields,
bufferFromText,
decodeTagBuffer,
hexdump,
parseImportedText,
parseProxmark3Bin,
startAutomaticWebNFC,
urlParams,
} from "{{ '/assets/scripts/opentag3d.js' | relative_url }}";
const SPEC = globalThis.OpenTag3D.spec;
const tagEmptyState = document.getElementById("tagEmptyState");
const tagDisplay = document.getElementById("tagDisplay");
const hexdumpBox = document.getElementById("hexdumpBox");
const hexdumpElement = document.getElementById("hexdump");
const el = (id) => document.getElementById(id);
// Returns the decoded display value for a field, or null if it should be
// treated as "not set" (optional field left at its zero/empty default).
const fieldValue = (values, id) => {
const field = allFields.find((f) => f.id === id);
const entry = values.get(id);
if (!entry) return null;
if (field?.required) return entry.display;
if (field?.type === "ascii" || field?.type === "utf8") {
return entry.raw.trim().length ? entry.display : null;
}
if (field?.type === "rgba") {
return entry.raw.some((v) => v !== 0) ? entry.display : null;
}
if (field?.type === "date") {
return entry.raw.year ? entry.display : null;
}
if (field?.type === "time") {
return entry.raw.hour || entry.raw.minute || entry.raw.second
? entry.display
: null;
}
// int
return entry.display ? entry.display : null;
};
const setText = (id, text) => {
el(id).textContent = text ?? "";
};
const renderTag = (values) => {
const v = (id) => fieldValue(values, id);
const dash = (text) => text || "—";
setText("tagManufacturer", v("manufacturer") || "Unknown Brand");
setText("tagColorName", v("color_name") || "Unknown Color");
const weight = v("weight");
const formattedWeight = weight
? Number(weight) >= 1000
? `${Number(weight) / 1000}kg`
: `${weight}g`
: "—";
setText("tagWeight", formattedWeight);
setText("tagMaterial", v("material") || "Unknown Material");
setText(
"tagMaterialMod",
v("material_mod") ? `— ${v("material_mod")}` : "",
);
setText("tagVersion", v("tag_version"));
setText("tagSerial", dash(v("serial")));
const mfgDate = v("mfg_date");
const mfgTime = v("mfg_time");
setText(
"tagMfgDate",
dash(
[mfgDate, mfgTime ? `${mfgTime} UTC` : ""].filter(Boolean).join(" "),
),
);
setText("tagSku", dash(v("sku")));
setText("tagBarcode", dash(v("barcode")));
// Colors
const swatches = el("tagColorSwatches");
swatches.innerHTML = "";
const hexLines = [];
for (const id of ["color_1", "color_2", "color_3", "color_4"]) {
const hexValue = v(id);
if (!hexValue) continue;
const swatch = document.createElement("div");
swatch.className = "color-swatch";
swatch.style.backgroundImage = `linear-gradient(0deg, ${hexValue.slice(0, 7)} 0%, ${hexValue.slice(0, 7)} 50%, ${hexValue} 50%, ${hexValue} 100%), url(/assets/images/transparency-grid.jpg)`;
swatch.title = hexValue;
swatches.append(swatch);
hexLines.push(hexValue);
}
setText("tagColorHexes", hexLines.join(" / "));
const td = v("td");
setText("tagTd", td ? `Transmission Distance (TD): ${td}mm` : "");
const diameter = v("diameter");
setText("tagDiameter", diameter ? `${diameter}mm` : "—");
const tolerance = v("tolerance");
setText("tagTolerance", tolerance ? `±${tolerance}mm` : "");
const density = v("density");
setText("tagDensity", density ? `${density}g/cm³` : "");
const printTemp = v("print_temp");
setText("tagPrintTemp", printTemp ? `${printTemp}°C` : "—");
const minPrint = v("min_print_temp"),
maxPrint = v("max_print_temp");
setText(
"tagPrintTempRange",
minPrint || maxPrint ? `${minPrint ?? "?"} - ${maxPrint ?? "?"}°C` : "",
);
const bedTemp = v("bed_temp");
setText("tagBedTemp", bedTemp ? `${bedTemp}°C` : "—");
const minBed = v("min_bed_temp"),
maxBed = v("max_bed_temp");
setText(
"tagBedTempRange",
minBed || maxBed ? `${minBed ?? "?"} - ${maxBed ?? "?"}°C` : "",
);
const chamberTemp = v("chamber_temp");
setText("tagChamberTemp", chamberTemp ? `${chamberTemp}°C` : "—");
const nozzle = v("nozzle_diameter");
setText("tagNozzle", nozzle ? `${nozzle}mm` : "—");
const dryTime = v("dry_time");
setText("tagDryTime", dryTime ? `${dryTime}hr` : "—");
const dryTemp = v("max_dry_temp");
setText("tagDryTemp", dryTemp ? `${dryTemp}°C` : "");
const targetVso = v("target_vso");
setText("tagTargetVso", targetVso ? `${targetVso}mm³/s` : "—");
const minVso = v("min_vso"),
maxVso = v("max_vso");
setText(
"tagVsoRange",
minVso || maxVso ? `${minVso ?? "?"} - ${maxVso ?? "?"}mm³/s` : "",
);
const measuredLength = v("measured_length");
setText("tagMeasuredLength", measuredLength ? `${measuredLength}m` : "—");
const measuredWeight = v("measured_weight");
setText("tagMeasuredWeight", measuredWeight ? `${measuredWeight}g` : "");
const spoolWeight = v("empty_spool_weight");
setText("tagSpoolWeight", spoolWeight ? `${spoolWeight}g` : "—");
const spoolCoreDiameter = v("spool_core_diameter");
setText(
"tagSpoolCoreDiameter",
spoolCoreDiameter ? `${spoolCoreDiameter}mm` : "",
);
const mfiTemp = v("mfi_temp");
setText("tagMfiTemp", mfiTemp ? `${mfiTemp}°C` : "—");
const mfiLoad = v("mfi_load");
const mfiValue = v("mfi_value");
setText(
"tagMfiLoadValue",
[mfiLoad ? `${mfiLoad}kg load` : "", mfiValue ? `${mfiValue}g/min` : ""]
.filter(Boolean)
.join(" — "),
);
const dataUrl = v("data_url");
const footer = el("tagFooter");
footer.innerHTML = "";
if (dataUrl) {
const link = document.createElement("a");
link.href = dataUrl.startsWith("http") ? dataUrl : `https://${dataUrl}`;
link.target = "_blank";
link.rel = "noopener noreferrer";
link.textContent = dataUrl;
footer.append("Online data: ", link);
}
};
const loadBufferIntoDisplay = async (buf, startAddr) => {
const data = new Uint8Array(buf);
hexdumpElement.textContent = hexdump(data, startAddr);
hexdumpBox.hidden = false;
const { values, warnings } = await decodeTagBuffer(data, startAddr);
warnings.forEach((w) => msg(`Warning: ${w}`, true));
renderTag(values);
tagEmptyState.hidden = true;
tagDisplay.hidden = false;
};
window.addEventListener("DOMContentLoaded", () => {
window.addEventListener("error", (e) => {
msg("Error: " + e.message, true);
});
document
.getElementById("loadFileBtn")
.addEventListener("click", () =>
document.getElementById("uploadFile").click(),
);
document
.getElementById("loadClipboardBtn")
.addEventListener("click", async () => {
const clipboard = await navigator.clipboard.readText();
try {
const { data, startAddr } = parseImportedText(clipboard);
await loadBufferIntoDisplay(data, startAddr);
msg("Loaded data from clipboard");
} catch (e) {
msg(
"Clipboard does not appear to be a valid OpenTag3D dump - " +
e.message,
true,
);
}
});
document
.getElementById("uploadFile")
.addEventListener("change", async (e) => {
const file = e.target.files?.[0];
if (!file) return;
try {
if (file.name.toLowerCase().endsWith(".bin")) {
const buf = await file.arrayBuffer();
// A Proxmark3 dump is just a raw .bin with a 56-byte header, try that first.
try {
await loadBufferIntoDisplay(parseProxmark3Bin(buf), 0x00);
} catch {
await loadBufferIntoDisplay(buf, 0x00);
}
} else {
const { data, startAddr } = parseImportedText(await file.text());
await loadBufferIntoDisplay(data, startAddr);
}
msg(`Loaded ${file.name}`);
} catch (err) {
msg("Import error: " + err.message, true);
} finally {
e.target.value = "";
}
});
const hexParam = urlParams.get("hex");
if (hexParam) {
loadBufferIntoDisplay(bufferFromText(hexParam), 0x00).catch((e) =>
msg("Import error: " + e.message, true),
);
}
// Automatically scan for an OpenTag3D tag when Web NFC is available.
if ("NDEFReader" in window) {
startAutomaticWebNFC((buf, startAddr) =>
loadBufferIntoDisplay(buf, startAddr).catch((e) =>
msg("Import error: " + e.message, true),
),
);
}
});
</script>