Devesh36/pocket-audio-player
A portable, rechargeable microSD audio player built around an RP2040, SPI flash, USB‑C charging/power management, LCD/button controls, PCM5102A I²S DAC, and TPA6132A headphone amplifier in a 3D‑printed enclosure.
- Version
- 1.0.12
- License
- unset
- Stars
- 0
scripts/check-lcd-hardware-fit.tsx
import {renderToJscadPlan} from 'jscad-fiber/headless'
import {executeJscadOperations,resolveReferencePlanes} from 'jscad-planner'
import modeling from '@jscad/modeling'
import {CaseBase,CaseLid} from '../enclosure'
import plan from '../lcd-model-plan.json'
const m=modeling as any
const solid=(jsx:any)=>executeJscadOperations(m,resolveReferencePlanes(renderToJscadPlan(jsx)).geometry)
const base=solid(<CaseBase/>),lid=solid(<CaseLid/>),pcb=m.primitives.cuboid({size:[60,90,1.6]})
const results=[]
// Each supplied STEP mesh is checked independently; menu glyphs are not hardware.
for(let i=0;i<49;i++){
const geometry=m.transforms.translate([0,-7,.8],executeJscadOperations(m,plan.shapes[i]))
const bounds=m.measurements.measureBoundingBox(geometry)
const box=m.primitives.cuboid({size:bounds[1].map((v:number,a:number)=>v-bounds[0][a]),center:bounds[1].map((v:number,a:number)=>(v+bounds[0][a])/2)})
const overlaps:any={}
for(const [name,g] of [['base',base],['lid',lid],['pcb',pcb]] as const){const v=m.measurements.measureVolume(m.booleans.intersect(box,g));if(Math.abs(v)>1e-4){const precise=m.measurements.measureVolume(m.booleans.intersect(geometry,g)); if(Math.abs(precise)>1e-4)overlaps[name]=precise}}
results.push({mesh:i,bounds:m.measurements.measureBoundingBox(geometry),overlaps})
}
const collision=results.filter(x=>Object.keys(x.overlaps).length)
await Bun.write('dist/enclosure/lcd-hardware-fit.json',JSON.stringify({checks:collision.length?'failed':'passed',model:'Waveshare 1.9inch LCD Module manufacturer STEP',results},null,2))
if(collision.length)throw new Error(JSON.stringify(collision))
console.log('All 49 manufacturer display meshes clear the enclosure and PCB substrate')