rushabhcodes/wireless-split-keyboard

Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure

Version
0.4.5
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone rushabhcodes/wireless-split-keyboard  # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard    # add it to your project as @tsci/rushabhcodes.wireless-split-keyboard

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/validate.ts

import {readFileSync,writeFileSync} from 'node:fs'
import {spawnSync} from 'node:child_process'
import {createHash} from 'node:crypto'
import {inputHash} from './input-hash'
const read=(path:string)=>JSON.parse(readFileSync(path,'utf8'))
const build=read('outputs/build-manifest.json')
const fresh=build.inputs.sha256===inputHash().sha256
const tests=spawnSync(process.execPath,['test'],{stdio:'inherit'})
const halves=Object.fromEntries(['left','right'].map(half=>{
 const file=`outputs/${half}/keyboard.circuit.json`,json=read(file)
 const hash=createHash('sha256').update(readFileSync(file)).digest('hex')
 const geometry=read(`outputs/${half}/native-copper-check.json`)
 const gerber=read(`outputs/${half}/gerber-shorts-check.json`)
 const models=read(`outputs/${half}/socket-model-check.json`)
 const modelHash=createHash('sha256').update(readFileSync(`outputs/${half}/keyboard-placement.glb`)).digest('hex')
 const socketModelsPassed=models.passed&&models.circuitJsonSha256===hash&&models.glbSha256===modelHash
 const previews=read(`outputs/${half}/preview-quality-check.json`)
 const previewQualityPassed=previews.passed&&previews.circuitJsonSha256===hash&&previews.glbSha256===modelHash
 const assembly=read(`outputs/${half}/assembly-model-check.json`)
 const assemblyModelsPassed=assembly.passed&&assembly.circuitJsonSha256===hash&&assembly.glbSha256===modelHash
 const fit=read(`outputs/${half}/enclosure-fit-check.json`)
 const enclosureFitPassed=fit.passed&&fit.circuitJsonSha256===hash&&fit.glbSha256===modelHash
 const geometryPassed=geometry.circuitJsonSha256===hash&&['shorts','clearanceBelow0Point1Mm','outsideBoard','keepoutViolations','holeClearanceViolations','opens'].every(k=>geometry[k].length===0)&&geometry.rfReferenceGapAreaMm2<1e-5
 return [half,{enclosureFitPassed,diagnostics:json.filter((e:{type:string})=>/error|warning/.test(e.type)).length,socketModelsPassed,previewQualityPassed,assemblyModelsPassed,routedTraces:json.filter((e:{type:string})=>e.type==='pcb_trace').length,geometryPassed,gerberShortsPassed:gerber.passed&&gerber.circuitJsonSha256===hash,circuitJsonSha256:hash}]
}))
const checksPass=fresh&&tests.status===0&&Object.values(halves).every(h=>h.diagnostics===0&&h.routedTraces>800&&h.geometryPassed&&h.gerberShortsPassed&&h.socketModelsPassed&&h.previewQualityPassed&&h.assemblyModelsPassed&&h.enclosureFitPassed)
const report={status:'ROUTED PROTOTYPE — hardware validation pending',checksPass,artifactsMatchCurrentSource:fresh,contractTestsPassed:tests.status===0,halves,fabricationReady:false,manufacturingBlockers:['Fabricator approval of 1+2+1 HDI stackup, filled/capped via-in-pad process and RF impedance','Final part, footprint, solder mask, stencil and availability audit','Battery/NTC, panel/FPC and enclosure fit validation','USB suspend-current handling and panel sleep sequencing','Prototype RF tuning, power, charge, sleep and firmware hardware tests']}
writeFileSync('outputs/validation-summary.json',JSON.stringify(report,null,2)+'\n')
console.log(JSON.stringify(report,null,2))
if(!checksPass||(process.argv.includes('--fabrication')&&!report.fabricationReady))process.exitCode=1