muse/book-reading-clip-lamp

A tscircuit package created by muse.

Version
0.4.6
License
unset
Stars
0

build-review.py

from pathlib import Path
import csv, json, html
p=Path(__file__).parent
bom=list(csv.DictReader((p/'bill-of-materials.csv').open(encoding='utf-8-sig')))
rows=''.join('<tr>'+''.join('<td>'+html.escape(r[k])+'</td>' for k in ['Reference designators','Quantity per product','Description','Manufacturer part number','Selection status'])+'</tr>' for r in bom)
page='''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lamp Clip · Head PCB Rev B</title><style>
:root{font-family:Inter,system-ui,sans-serif;color:#173631;background:#f0f4f0}*{box-sizing:border-box}body{margin:0}header{background:#093c31;color:#f7fff9;padding:38px 5vw 28px}header small{letter-spacing:.16em;text-transform:uppercase;color:#b5dfcd;font-size:12px}h1{font-size:clamp(32px,4vw,58px);margin:8px 0;letter-spacing:-.05em}p{line-height:1.6;max-width:800px}header p{color:#d6eae0}.pill{display:inline-block;padding:7px 12px;border-radius:30px;background:#ead4a0;color:#473c24;font-size:12px;font-weight:700}main{max-width:1320px;padding:28px;margin:auto}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:24px}.stat{background:white;border-radius:16px;padding:18px;border:1px solid #d8e4dc}.stat strong{display:block;font-size:25px}.stat span{font-size:13px;color:#537068}.review{background:white;border:1px solid #d8e4dc;border-radius:20px;overflow:hidden}.toolbar{padding:14px;display:flex;gap:8px;flex-wrap:wrap;border-bottom:1px solid #d8e4dc;align-items:center}button{background:#edf3ee;border:0;padding:11px 17px;border-radius:10px;color:#1c4b3d;cursor:pointer;font:inherit;font-size:13px}button.active{background:#126146;color:white}.viewer{height:650px;overflow:auto;background:#121716;display:flex;justify-content:center;align-items:flex-start;padding:20px}.viewer img{max-width:100%;height:100%;object-fit:contain}.viewer.zoom{justify-content:flex-start}.viewer.zoom img{max-width:none;height:2400px}.caption{padding:12px 20px;color:#537068;font-size:13px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:24px;margin-top:24px}article{background:white;border-radius:18px;padding:24px;border:1px solid #d8e4dc}h2{font-size:20px;margin:0 0 14px}h3{font-size:15px}ul{padding-left:20px;line-height:1.7}a{color:#087456}code{background:#edf3ee;padding:3px 6px;border-radius:4px}.note{border-left:4px solid #bd8b26;background:#fff7e5;padding:14px 18px;font-size:14px}.table-wrap{overflow:auto}table{border-collapse:collapse;width:100%;font-size:12px}th,td{text-align:left;padding:12px;border-bottom:1px solid #e5ece7;vertical-align:top}th{background:#edf3ee}input{padding:12px;border:1px solid #bdcfc3;border-radius:8px;width:100%;margin:12px 0}footer{padding:24px 0;color:#657c73;font-size:12px}.files{display:flex;gap:14px;flex-wrap:wrap;font-size:14px}@media(max-width:700px){.stats{grid-template-columns:1fr 1fr}.grid{grid-template-columns:1fr}main{padding:15px}.viewer{height:470px}}
</style><header><small>Engineering design · Revision B · tscircuit</small><h1>Lamp Clip / Head PCB</h1><p>A reading light with a camera, voice input and Wi-Fi. One custom main board in the head; the battery and physical speaker stay in the clip.</p><span class="pill">ENGINEERING PROTOTYPE · NOT RELEASED FOR MANUFACTURE</span></header><main><div class="stats"><div class="stat"><strong>60 mm</strong><span>Round board · 4 layers</span></div><div class="stat"><strong>ESP32-S3</strong><span>16 MB flash · 8 MB PSRAM</span></div><div class="stat"><strong>8 wires</strong><span>Battery · temperature · speaker · controls</span></div><div class="stat"><strong>OV5640 AF</strong><span>Direct flex camera</span></div></div><section class="review"><div class="toolbar"><button class="active" data-view="pcb-top.svg" data-caption="Top / rear electronics. Actual tscircuit PCB geometry; other layers are faint and inner pours hidden for clarity.">PCB · rear</button><button data-view="pcb-bottom.svg" data-caption="Bottom / page-facing side. Six reading LEDs and the camera FPC connector; bottom view is mirrored.">PCB · page side</button><button data-view="schematic-sheets/01-usb.svg" data-caption="Sheet 1 of 10: USB-C. Named nets connect between sheets.">Schematic</button><select id="sheet-selector" aria-label="Schematic sheet"><option value="01-usb">1. USB-C input and USB data</option><option value="02-usbpower">2. Automatic USB charging-source detection</option><option value="03-charger">3. Battery charging and clip harness</option><option value="04-regulator">4. 3.3 V supply and remote power switch</option><option value="05-mcu">5. ESP32-S3 controller and boot configuration</option><option value="06-camera">6. Direct FPC camera and signal-level conversion</option><option value="07-camerapower">7. Camera I/O, analog and internal core power</option><option value="08-audio">8. Microphone and spoken-response output</option><option value="09-light">9. Reading-light boost driver and LED string</option><option value="10-controls">10. Buttons, status and battery measurement</option></select><button data-view="assembly-map.svg" data-caption="Conceptual assembly map. Follow numbered nets and the assembly notes, not wire colors alone.">Assembly map</button><button id="zoom">Toggle zoom</button></div><div class="viewer" id="viewer"><img id="drawing" src="pcb-top.svg" alt="Lamp Clip PCB design"></div><div id="caption" class="caption">Top / rear electronics. Actual tscircuit PCB geometry; other layers are faint and inner pours hidden for clarity.</div></section><div class="grid"><article><h2>In the head</h2><ul><li>Wi-Fi processor and external antenna connection.</li><li>Autofocus camera module on an 24-contact FPC.</li><li>I2S microphone and speaker amplifier.</li><li>Six warm-white LEDs with constant-current driver.</li><li>USB-C, charging power path, buck-boost supply and three controls.</li></ul><h3>In the clip</h3><p>Protected 1S battery, cell-mounted thermistor and an 8-ohm speaker. The speaker output is differential: neither speaker wire is ground.</p></article><article><h2>Review status</h2><p>See <a href="validation.txt">validation.txt</a> for the exact final check results. Source and previews are included for electrical and mechanical review.</p><div class="note">This is untested hardware. It is not a ready-to-order consumer product. USB power behavior, regulator layout, acoustic fit and the complete firmware still need validation.</div><h3>Muse firmware</h3><p>The SDK is the starting point. Custom board support, photo/voice association and spoken-response playback remain to be implemented and tested.</p><h3>Automatic charging detection</h3><p>BC1.2 and USB-C current detection select the 500 mA input mode for recognized chargers, including with the lamp off. Unknown sources start at 100 mA. Host enumeration, total current and thermal behavior need prototype testing.</p></article></div><article style="margin-top:24px"><h2>Build files</h2><div class="files"><a href="index.circuit.tsx">Circuit source</a><a href="README.md">Readme</a><a href="firmware-and-assembly.txt">Assembly & firmware</a><a href="pin-map.csv">GPIO map</a><a href="camera-sourcing.txt">Camera supplier &amp; assembly</a><a href="camera-pinout.csv">FPC pinout</a><a href="component-provenance.csv">JLC import provenance</a><a href="bill-of-materials.csv">BOM CSV</a><a href="power-audit.txt">Power review</a><a href="validation.txt">Validation</a></div></article><article style="margin-top:24px"><h2>Parts list</h2><p>Selected parts and procurement gaps are marked explicitly. Check the complete CSV for footprint status, electrical ratings, sources and external parts.</p><input id="search" placeholder="Filter by reference, description or part number" aria-label="Filter parts"><div class="table-wrap"><table><thead><tr><th>Reference</th><th>Qty</th><th>Function</th><th>Part number</th><th>Status</th></tr></thead><tbody>'''+rows+'''</tbody></table></div></article><footer>Rev B · One custom head PCB plus an autofocus lens/sensor on flex. No measured battery-life, RF, thermal or audio performance is claimed.</footer></main><script>document.getElementById('sheet-selector').onchange=e=>{document.querySelectorAll('[data-view]').forEach(x=>x.classList.remove('active'));document.getElementById('drawing').src='schematic-sheets/'+e.target.value+'.svg';document.getElementById('caption').textContent=e.target.selectedOptions[0].text+' — Named nets connect between sheets.';document.getElementById('viewer').classList.remove('zoom')};document.querySelectorAll('[data-view]').forEach(b=>b.onclick=()=>{document.querySelectorAll('[data-view]').forEach(x=>x.classList.remove('active'));b.classList.add('active');document.getElementById('drawing').src=b.dataset.view;document.getElementById('caption').textContent=b.dataset.caption;document.getElementById('viewer').classList.remove('zoom')});document.getElementById('zoom').onclick=()=>document.getElementById('viewer').classList.toggle('zoom');document.getElementById('search').oninput=e=>document.querySelectorAll('tbody tr').forEach(r=>r.hidden=!r.textContent.toLowerCase().includes(e.target.value.toLowerCase()));</script></html>'''
(p/'preview.html').write_text(page)