abse/gameboy-advance
A tscircuit package created by abse.
- Version
- 0.0.45
- License
- unset
- Stars
- 0
checks/display-parallel.ts
PCB
Schematic
import {readFileSync,writeFileSync} from 'node:fs'
const c=JSON.parse(readFileSync('dist/index/circuit.json','utf8'))
const comps=new Map(c.filter((e:any)=>e.type==='source_component').map((e:any)=>[e.name,e])) as Map<string,any>
const ports=c.filter((e:any)=>e.type==='source_port')
const port=(name:string,pin:string)=>ports.find((e:any)=>e.source_component_id===comps.get(name)?.source_component_id&&(e.name===pin||e.port_hints?.includes(pin)))
const key=(name:string,pin:string)=>port(name,pin)?.subcircuit_connectivity_map_key
const assert=(ok:any,msg:string)=>{if(!ok)throw Error('8080 LCD: '+msg)}
const gnd=key('U1','GND'),logic=key('C_LCD_VDDI','pin1')
const same=(a:string,p:string,b:string,q:string)=>assert(key(a,p)&&key(a,p)===key(b,q),`${a}.${p} must connect to ${b}.${q}`)
const signals=[]
for(let bit=0;bit<8;bit++){
same('J_LCD','pin'+(32-bit),'U1','GPIO'+(15+bit));signals.push(key('U1','GPIO'+(15+bit)))
}
for(const [pin,gpio] of [[36,23],[37,25],[10,10]]){same('J_LCD','pin'+pin,'U1','GPIO'+gpio);signals.push(key('U1','GPIO'+gpio))}
assert(new Set(signals).size===11&&signals.every(k=>k!==gnd&&k!==logic),'data/control signals shorted together or to a rail')
for(const pin of [7,8,35,40,41,42])assert(key('J_LCD','pin'+pin)===logic,'wrong high strap/supply FPC'+pin)
for(const pin of [9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,34,38,43])assert(key('J_LCD','pin'+pin)===gnd,'wrong low strap/unused FPC'+pin)
assert(!key('J_LCD','pin33'),'serial output must be disconnected')
same('SW_SELECT','pin1','U1','GPIO0');same('R_AMP_IN','pin1','U1','GPIO1')
same('SW_START','pin1','U1','GPIO11')
const gpioKeys=ports.filter((e:any)=>e.source_component_id===comps.get('U1').source_component_id&&/^GPIO[0-9]+(?:_|$)/.test(e.name)).map((e:any)=>e.subcircuit_connectivity_map_key)
assert(gpioKeys.length===30&&gpioKeys.every(Boolean)&&new Set(gpioKeys).size===30,'MCU GPIO functions share a net or an assigned GPIO is unconnected')
assert(!ports.some((e:any)=>e.source_component_id===comps.get('U1').source_component_id&&[44,45,46].some(n=>e.subcircuit_connectivity_map_key===key('J_LCD','pin'+n))),'reserved touch signal still attached to MCU')
assert(comps.get('R_LCD_LED').resistance===22,'backlight series resistance changed')
same('R_LCD_LED','pin2','J_LCD','pin1');same('R_LCD_LED','pin1','D_USB_POWER','cathode')
assert(key('R_LCD_LED','pin1')!==key('R_LCD_LED','pin2'),'backlight resistor bypassed')
const r=c.find((e:any)=>e.type==='pcb_component'&&e.source_component_id===comps.get('R_LCD_LED').source_component_id)
assert(Math.abs(r.center.x-30.5)<1e-6&&Math.abs(r.center.y-36.5)<1e-6&&r.rotation===270,'resistor not at cable-clearance location')
writeFileSync('dist/index/display-parallel.json',JSON.stringify({interface:'ILI9488 8080 8-bit',modeIM2IM1IM0:'011',pixelFormat:'RGB565',gpioData:[15,16,17,18,19,20,21,22],wr:23,dc:25,reset:10,select:0,audio:1,backlight:24,frameBytes:307200,bytesPerSecondAt33Fps:10137600,targetWriteHz:15000000,benchValidationRequired:true,pass:true},null,2))
console.log('8080 display topology and backlight series path passed')