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/generate-lcd-model.tsx

// Manufacturer mesh import -> native tscircuit CAD plan, plus a static menu preview.
// STEP source: https://files.waveshare.com/upload/9/98/1.9inch_LCD_Module_3D.zip
import {renderToJscadPlan} from 'jscad-fiber/headless'
import {resolveReferencePlanes,executeJscadOperations} from 'jscad-planner'
import modeling from '@jscad/modeling'
import {LcdMenu} from '../oled-shape'
const occt=await require('occt-import-js')()
const raw=occt.ReadStepFile(new Uint8Array(await Bun.file('assets/waveshare-1.9inch-lcd.stp').arrayBuffer()),{linearUnit:'millimeter',linearDeflectionType:'absolute_value',linearDeflection:.1,angularDeflection:.5})
if(!raw.success)throw new Error('Manufacturer STEP import failed')
const shapes=raw.meshes.map((mesh:any)=>{
 const p=mesh.attributes.position.array,indices=mesh.index.array
 const polygons=[]
 for(let i=0;i<indices.length;i+=3) polygons.push({vertices:indices.slice(i,i+3).map((j:number)=>[p[j*3]-25.6,p[j*3+1]-13.65+17.2+7,p[j*3+2]+6.91148-0.8])})
 return {type:'colorize',color:mesh.color??[.15,.15,.15],shape:{type:'createGeom3',polygons}}
})
const leaves=(op:any):any[]=>op.type==='union'?op.shapes.flatMap(leaves):op.shape?leaves(op.shape).map(shape=>({...op,shape})):[op]
const menu=resolveReferencePlanes(renderToJscadPlan(<LcdMenu/>)).geometry
for(const op of leaves(menu)){
 const g=executeJscadOperations(modeling as any,op)
 const moved=modeling.transforms.translate([0,7,-0.8],g)
 shapes.push({type:'colorize',color:op.type==='colorize'?op.color:[.33,.34,.31],shape:{type:'createGeom3',polygons:modeling.geometries.geom3.toPolygons(moved)}})
}
await Bun.write('lcd-model-plan.json',JSON.stringify({type:'union',shapes}))
console.log(`Generated native CAD plan: ${raw.meshes.length} manufacturer meshes + static screen menu`)