abse/smartwatch-flex-top-only
Three-panel flex smartwatch with two parallel R3.9 bends, all components flat-top, low-profile JST connector harnesses, split heartbeat optical windows and screw-retained PCB mounting. Modeled 39 × 50.5 × 14.5mm prototype; 100% routing, zero native DRC and shorts. Hardware qualification pending.
- Version
- 0.2.20
- License
- unset
- Stars
- 0
scripts/thermal-via-policy.mjs
import fs from 'node:fs'
export const thermalViaSpecification=JSON.parse(fs.readFileSync(new URL('../thermal-vias.json',import.meta.url)))
const contexts=new WeakMap()
export function thermalViaContext(source) {
if(contexts.has(source))return contexts.get(source)
const s=thermalViaSpecification,c=source.find(e=>e.type==='source_component'&&e.name===s.reference),pcb=source.find(e=>e.type==='pcb_component'&&e.source_component_id===c?.source_component_id),sp=source.find(e=>e.type==='source_port'&&e.source_component_id===c?.source_component_id&&e.pin_number===s.physicalPin),pp=source.find(e=>e.type==='pcb_port'&&e.source_port_id===sp?.source_port_id),pad=source.find(e=>e.type==='pcb_smtpad'&&e.pcb_port_id===pp?.pcb_port_id),net=source.find(e=>e.type==='source_net'&&e.name===s.net);
if(!pcb||!pad||!net||pad.shape!=='rect'||Math.abs(pad.width-4)>1e-4||Math.abs(pad.height-4)>1e-4)throw Error('Thermal exception requires the reviewed U1 4x4mm exposed land');
const result={padId:pad.pcb_smtpad_id,port:pp.pcb_port_id,net:net.source_net_id,pad,sites:s.offsetsMM.map(o=>({x:pcb.center.x+o.x,y:pcb.center.y+o.y}))};contexts.set(source,result);return result;
}
export function isAuthorizedThermalVia(v,p,source,cache) {
const traceId=v.traceId??v.pcb_trace_id;if(!/^esp32_thermal_escape_[0-8]$/.test(traceId??''))return false;
const s=thermalViaSpecification,c=thermalViaContext(source);
if(p.id!==c.padId||p.port!==c.port||p.net!==c.net||!/^esp32_thermal_escape_[0-8]$/.test(traceId??''))return false;
const t=cache.traces.find(t=>t.pcb_trace_id===traceId);if(!t||t.connection_name!==c.net)return false;
const hole=v.hole??v.hole_diameter,outer=v.r!==undefined?v.r*2:v.outer_diameter;
if(Math.abs(hole-s.holeDiameterMM)>1e-8||Math.abs(outer-s.padDiameterMM)>1e-8||!c.sites.some(q=>Math.hypot(q.x-v.x,q.y-v.y)<1e-7))return false;
if(v.net!==undefined&&v.net!==c.net)return false;
// Contained annulus with positive land margin; overlapping any other pad is rejected.
return Math.abs(v.x-c.pad.x)+outer/2<c.pad.width/2&&Math.abs(v.y-c.pad.y)+outer/2<c.pad.height/2;
}