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.

src/Programming.tsx

import * as React from 'react'
import { SKRPACE010 } from '../imports/SKRPACE010'
import { placement,offsetPlacement,pcbProps } from './componentPlacement'
import type { Half } from './mechanicalGeometry'
import { Passives,type PassiveSpec } from './components'
export function Programming({half}:{half:Half}) {
 const nets=['VCC','SWDIO','SWDCLK','GND','RESET','GND']
 const specs:PassiveSpec[]=[
 {ref:'R_RST',kind:'R',value:'10k',from:'RESET',to:'VCC',dx:1,dy:-5},
 {ref:'R_BAT_TOP',kind:'R',value:'1M',from:'VBAT_SENSE_PWR',to:'batterySense',dx:6,dy:-1},
 {ref:'R_BAT_BOTTOM',kind:'R',value:'1M',from:'batterySense',to:'GND',dx:6,dy:-3},
 {ref:'C_BAT_SENSE',kind:'C',value:'1nF',from:'batterySense',to:'GND',dx:6,dy:-5},
 {ref:'R_BAT_GATE',kind:'R',value:'1M',from:'VBAT',to:'BAT_GATE',dx:9,dy:-1},
 {ref:'R_BAT_EN',kind:'R',value:'100k',from:'batterySenseEnable',to:'GND',dx:9,dy:-3},
 ]
 return <>
 <schematicsection name="debug" displayName="SWD / reset / battery ADC" sectionTitleFontSize={.4}/>
 <connector name="J_SWD" pinCount={6} doNotPlace pinLabels={Object.fromEntries(nets.map((n,i)=>[`pin${i+1}`,`${n}_${i}`]))}
  footprint={<footprint insertionDirection="from_above">{nets.map((_,i)=><React.Fragment key={i}><smtpad shape="circle" radius={0.45} pcbX={(i%3)*1.5} pcbY={Math.floor(i/3)*1.5} portHints={[`pin${i+1}`]}/></React.Fragment>)}<courtyardrect pcbX={1.5} pcbY={.75} width={4.4} height={3}/></footprint>}
  {...pcbProps(offsetPlacement(half,'J_SWD','SW_RESET',7,1.8))} schX={84} schY={-32} schSectionName="debug"
  connections={Object.fromEntries(nets.map((n,i)=>[`pin${i+1}`,`net.${n}`]))}/>
 <SKRPACE010 name="SW_RESET" {...pcbProps(offsetPlacement(half,'SW_RESET_BODY','SW_RESET',0,half==='right'?1.4:1.5))}
  schX={84} schY={-35} schSectionName="debug" connections={{pin1:'net.RESET',pin2:'net.RESET',pin3:'net.GND',pin4:'net.GND'}}/>
 <Passives half={half} anchor="SW_RESET" section="debug" specs={specs} schX={91} schY={-30}/>
 <mosfet name="Q_BAT_P" channelType="p" mosfetMode="enhancement" manufacturerPartNumber="AO3401A" pinLabels={{pin1:'gate',pin2:'source',pin3:'drain'}} footprint="sot23"
  {...pcbProps(offsetPlacement(half,'Q_BAT_P','SW_RESET',9,-7))} schX={91} schY={-39} schSectionName="debug"
  connections={{gate:'net.BAT_GATE',source:'net.VBAT',drain:'net.VBAT_SENSE_PWR'}}/>
 <mosfet name="Q_BAT_N" channelType="n" mosfetMode="enhancement" manufacturerPartNumber="2N7002" pinLabels={{pin1:'gate',pin2:'source',pin3:'drain'}} footprint="sot23"
  {...pcbProps(offsetPlacement(half,'Q_BAT_N','SW_RESET',13.5,-4))} schX={96} schY={-39} schSectionName="debug"
  connections={{gate:'net.batterySenseEnable',source:'net.GND',drain:'net.BAT_GATE'}}/>
 {['VBUS','VBAT','SYS','VCC','GND'].map((net,i)=><React.Fragment key={net}><testpoint doNotPlace name={`TP_${net}`} footprint={<footprint><smtpad shape="circle" radius={0.5} portHints={['pin1']}/></footprint>}
   {...pcbProps(offsetPlacement(half,`TP_${net}`,'SW_RESET',i*2,-13))}
   schX={net==='GND'?86:82+i*3} schY={net==='GND'?-37.5:-45} schSectionName="debug" connections={{pin1:`net.${net}`}}/></React.Fragment>)}
 </>
}