seveibar/am3352-dev-board-4layer-dogbone

Defines PCB footprints and pin mappings for a TI AM3352ZCZ100 processor, JST GH connectors, and assembly-part lookup helpers for capacitors, resistors, and headers.

Version
0.1.5
License
unset
Stars
0

scripts/check-led-polarity.mjs

import fs from 'node:fs'
import assert from 'node:assert/strict'
import {convertCircuitJsonToPickAndPlaceRows} from 'circuit-json-to-pnp-csv'
const c=JSON.parse(fs.readFileSync('dist/index/circuit.json'))
const source=c.find(e=>e.type==='source_component'&&e.name==='D_STATUS')
const comp=c.find(e=>e.type==='pcb_component'&&e.source_component_id===source.source_component_id)
for(const [alias,pin,x] of [['cathode',1,-23.175],['anode',2,-24.825]]) {
 const s=c.find(e=>e.type==='source_port'&&e.source_component_id===source.source_component_id&&e.port_hints.includes(alias))
 assert.equal(s.pin_number,pin)
 const p=c.find(e=>e.type==='pcb_port'&&e.source_port_id===s.source_port_id)
 assert(Math.abs(p.x-x)<1e-6&&Math.abs(p.y-6)<1e-6,alias+' moved off its existing copper')
 const trace=c.find(e=>e.type==='source_trace'&&e.connected_source_port_ids.includes(s.source_port_id))
 if(alias==='cathode')assert(trace.connected_source_net_ids.includes(c.find(e=>e.type==='source_net'&&e.name==='GND').source_net_id))
 else assert(trace.connected_source_port_ids.some(id=>c.some(e=>e.type==='source_port'&&e.source_port_id===id&&e.source_component_id===c.find(e=>e.type==='source_component'&&e.name==='R_STATUS').source_component_id)))
}
assert(!c.some(e=>e.type==='source_component_misconfigured_error'&&e.message.includes('D_STATUS')))
comp.supplier_pin1_location_map={jlcpcb:JSON.parse(fs.readFileSync('design/assembly-orientations.json')).C965805.pin1Location}
for(const e of c)if(e.type==='pcb_component'&&e!==comp)e.do_not_place=true
const row=convertCircuitJsonToPickAndPlaceRows(c,{supplier:'jlcpcb',requireSupplierRotation:true}).find(r=>r.designator==='D_STATUS')
assert.equal(row.rotation,180,'Supplier placement must retain cathode orientation without an LED-specific override')
console.log('LED polarity, pad positions, resistor/GND connections, and supplier rotation pass')