MustafaMulla29/usb-pd-motherboard

4-layer USB-C PD hub motherboard with 20 V USB-C input, Linux T113-S3 computer, CH338F USB hub, four individually controlled 5–20 V PD outputs, USB data/camera ports, regulated rails, and hardware watchdog/E-stop safety interlock.

Version
1.0.24
License
unset
Stars
0

Use with the tscircuit CLI

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

tsci clone MustafaMulla29/usb-pd-motherboard  # download the package files into ./usb-pd-motherboard
tsci add MustafaMulla29/usb-pd-motherboard    # add it to your project as @tsci/MustafaMulla29.usb-pd-motherboard

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.

tools/place.py

"""Small helper to move components by name in a TSX file: at={{...}} or pcbX/pcbY."""
import re,sys,json
def apply(path, moves):
    s=open(path).read()
    for name,v in moves.items():
        q=re.escape(name)
        npat=r'name=(?:"'+q+r'"|\{`'+q+r'`\})'
        if 'x' in v and 'at' not in v and v.get('kind')=='pcb':
            pat=re.compile('('+npat+r'[^\n]*?pcbX=\{)[-0-9.]+(\} pcbY=\{)[-0-9.]+(\})')
            new=lambda m:m.group(1)+str(v['x'])+m.group(2)+str(v['y'])+m.group(3)
        else:
            pat=re.compile('('+npat+r'[^\n]*?at=\{\{)[^}]*(\}\})')
            body=f"x: {v['x']}, y: {v['y']}"+(f", r: {v['r']}" if v.get('r') is not None else '')
            new=lambda m,b=body:m.group(1)+' '+b+' '+m.group(2)
        if not pat.search(s): print('MISS',path,name)
        s=pat.sub(new,s)
    open(path,'w').write(s)
if __name__=='__main__':
    apply(sys.argv[1], json.loads(sys.argv[2]))