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/BatteryPower.tsx

import * as React from 'react'
import { ntcWireCadModel } from './mechanicalModels'
import { jstPhCadModel } from '../imports/S2B_PH_K_S_LF__SN_'
import { PCM12SMTR } from '../imports/PCM12SMTR'
import { BQ25185DLHR } from '../imports/BQ25185DLHR'
import { TPS63802DLAR } from '../imports/TPS63802DLAR'
import type { Half } from './mechanicalGeometry'
import { placement,offsetPlacement,pcbProps } from './componentPlacement'
import { Passives,type PassiveSpec } from './components'
const chargerParts:PassiveSpec[]=[
 {ref:'C_CH_IN',kind:'C',value:'1uF',from:'VBUS',to:'GND',dx:-2.8,dy:0,footprint:'0603'},
 {ref:'C_CH_BAT',kind:'C',value:'1uF',from:'VBAT',to:'GND',dx:0,dy:-2.8,footprint:'0603'},
 {ref:'C_CH_SYS',kind:'C',value:'10uF',from:'SYS',to:'GND',dx:3,dy:3,footprint:'0603'},
 {ref:'R_ISET',kind:'R',value:'6.04k',from:'CH_ISET',to:'GND',dx:3,dy:0},
 {ref:'R_ILIM',kind:'R',value:'24k',from:'CH_ILIM',to:'GND',dx:3,dy:-2.5},
 {ref:'R_STAT1',kind:'R',value:'10k',from:'CH_STAT1',to:'VCC',dx:-3,dy:-2},
 {ref:'R_STAT2',kind:'R',value:'10k',from:'CH_STAT2',to:'VCC',dx:-3,dy:2},
]
const regulatorParts:PassiveSpec[]=[
 {ref:'C_REG_IN',kind:'C',value:'10uF',from:'SYS',to:'GND',dx:0,dy:3,footprint:'0603'},
 {ref:'C_REG_OUT1',kind:'C',value:'22uF',from:'VCC',to:'GND',dx:0,dy:-3,footprint:'0805'},
 {ref:'C_REG_OUT2',kind:'C',value:'22uF',from:'VCC',to:'GND',dx:-4,dy:-5.5,footprint:'0805'},
 {ref:'L_BUCK',kind:'L',value:'0.47uH',from:'SW_NODE1',to:'SW_NODE2',dx:3.5,dy:0,footprint:<footprint><smtpad shape="rect" pcbX={-1.55} pcbY={0} width={1.2} height={3.8} portHints={['pin1']}/><smtpad shape="rect" pcbX={1.55} pcbY={0} width={1.2} height={3.8} portHints={['pin2']}/><courtyardrect width={4.4} height={4.0}/></footprint>,mpn:'XFL4015-471MEC'},
 {ref:'R_FB_TOP',kind:'R',value:'453k',from:'VCC',to:'REG_FB',dx:-3,dy:1},
 {ref:'R_FB_BOTTOM',kind:'R',value:'91k',from:'REG_FB',to:'GND',dx:-3,dy:-1},
 {ref:'R_REG_EN',kind:'R',value:'1M',from:'REG_EN',to:'GND',dx:-3,dy:-3},
]
export function BatteryPower({half}:{half:Half}) {
 const powerSwitch=placement(half,'SW_PWR',{x:-63,y:4,rotation:270,side:'bottom'})
 const angle=powerSwitch.rotation*Math.PI/180
 const mirror=powerSwitch.side==='bottom'?-1:1
 const label=(travel:number)=>({
  pcbX:powerSwitch.x-4.5*Math.sin(angle)+travel*mirror*Math.cos(angle),
  pcbY:powerSwitch.y+4.5*Math.cos(angle)+travel*mirror*Math.sin(angle),
  layer:powerSwitch.side,
 })
 return <>
 <schematictext text="Li-ion charging" schX={38} schY={-27.5} fontSize={.3} anchor="left"/>
 <schematictext text="3V buck-boost" schX={36} schY={-40} fontSize={.3} anchor="left"/>
 <schematicsection name="charger" displayName="" sectionTitleFontSize={.4}/>
 <schematicsection name="regulator" displayName="" sectionTitleFontSize={.4}/>
 <BQ25185DLHR name="U_CHG" {...pcbProps(placement(half,'U_CHG',{x:-55,y:-4,rotation:0,side:'bottom'}))}
  schX={45} schY={-34} schSectionName="charger" schWidth={2.15} schHeight={1.4}
  connections={{pin1:'net.SYS',pin2:'net.VBAT',pin3:'net.CH_STAT2',pin4:'net.GND',pin5:'net.GND',pin6:'net.BAT_NTC',pin7:'net.CH_ILIM',pin8:'net.CH_ISET',pin9:'net.CH_STAT1',pin10:'net.VBUS',pin11:'net.GND'}}/>
 <Passives half={half} anchor="U_CHG" section="charger" specs={chargerParts} schX={51} schY={-30}/>
 <connector name="J_NTC" pinCount={2} doNotPlace cadModel={{jscad:ntcWireCadModel}} footprint="pinrow2_p2.54mm" pinLabels={{pin1:'TS',pin2:'GND'}} schPinArrangement={{topSide:[1],bottomSide:[2]}}
  {...pcbProps(offsetPlacement(half,'J_NTC','U_CHG',8,2))} schX={53} schY={-38} schSectionName="charger"
  connections={{TS:'net.BAT_NTC',GND:'net.GND'}} />
 <TPS63802DLAR name="U_REG" {...pcbProps(placement(half,'U_REG',{x:-47,y:1,rotation:0,side:'bottom'}))}
  schX={44.91} schY={-40} schSectionName="regulator" schWidth={1.96} schHeight={1.2}
  connections={{pin1:'net.REG_EN',pin2:'net.GND',pin3:'net.GND',pin4:'net.REG_FB',pin6:'net.VCC',pin7:'net.SW_NODE2',pin8:'net.GND',pin9:'net.SW_NODE1',pin10:'net.SYS'}}/>
 <Passives half={half} anchor="U_REG" section="regulator" specs={regulatorParts} schX={51} schY={-43}/>
 {/* The actuator intentionally overhangs the edge; all copper stays on-board. */}
 <PCM12SMTR name="SW_PWR" allowOffBoard
  {...pcbProps(powerSwitch)} schX={44} schY={-42} schSectionName="regulator"
  connections={{pin1:'net.SYS',pin2:'net.REG_EN',pin3:'net.GND',pin4:'net.GND'}}/>
 <silkscreentext text="ON" {...label(-1.6)} fontSize={.7}/>
 <silkscreentext text="OFF" {...label(1.6)} fontSize={.7}/>
 <connector cadModel={{...jstPhCadModel,pcbRotationOffset:0,modelOriginPosition:{x:1,y:0,z:0}}} supplierPartNumbers={{jlcpcb:['C173752']}} name="J_BAT" standard="jst_ph" pinCount={2} footprint="jst2_p2mm_ph" manufacturerPartNumber="S2B-PH-K-S(LF)(SN)"
  {...pcbProps(placement(half,'J_BAT',{x:-49,y:-7,rotation:0,side:'bottom'}))} schX={38} schY={-34} schSectionName="charger"
  connections={{pin1:'net.VBAT',pin2:'net.GND'}}>
  <courtyardrect pcbX={0} pcbY={-2.4} width={6.5} height={8.2} layer="top"/>
 </connector>
 </>
}