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

import { Nrf52840 } from './Nrf52840'
import { RadioFrontend } from './RadioFrontend'
import { BatteryPower } from './BatteryPower'
import { Display } from './Display'
import { UsbC } from './UsbC'
import { Encoder } from './Encoder'
import { Programming } from './Programming'
import * as React from 'react'
import { geometryFor, type Half } from './mechanicalGeometry'
import { KeyCell } from './KeyCell'
import { persistedRouting } from './routing'
export function KeyboardHalf({half,routeMatrix=false,placementOnly=false}: {half:Half;routeMatrix?:boolean;placementOnly?:boolean}) {
 const g=geometryFor(half)
 return <board title={`Wireless Split Keyboard — ${half}`} name={`custom_sofle_${half}`}
   outline={g.outline} layers={4} thickness={1.6} routingDisabled={placementOnly} routeRemaining={false}
   allowBlindAndBuriedVias={true} isViaInPadAllowed={true} autorouter={{local:true,allowViaInPad:true}}
   minTraceWidth={.125} minTraceToPadEdgeClearance={.1} minPadEdgeToPadEdgeClearance={.1}
   minViaHoleDiameter={.15} minViaPadDiameter={.35} minViaEdgeToPadEdgeClearance={.1}
   schAutoLayoutEnabled={false}>
   {g.mountingHoles.map(h=><React.Fragment key={h.reference}>{h.plated
      ? <platedhole name={h.reference} pcbX={h.x} pcbY={h.y} shape="circle" holeDiameter={h.diameter} outerDiameter={h.padDiameter} />
      : <hole name={h.reference} pcbX={h.x} pcbY={h.y} diameter={h.diameter} />}</React.Fragment>)}
   <schematicsheet name="matrix" displayName="01 · Key matrix and encoder" sheetIndex={0}>
   <schematicsection name="matrix" displayName="Choc matrix / COL2ROW" sectionTitleFontSize={.4}/>
   {g.keys.map(k=><KeyCell key={k.reference} position={k} half={half}/>)}
 {routeMatrix&&<autoroutingphase name="matrix-cell-only" autorouter="auto-local" connections={[...g.keys.map(k=>`.${k.reference} > .OUT`),'.ENC1 > .S2']}/>}
 {!placementOnly&&!routeMatrix&&<autoroutingphase name="complete-verified-routing" algorithmFn={persistedRouting(half)}/>}
 <Encoder half={half}/>
 </schematicsheet>
 <schematicsheet name="processor" displayName="02 · nRF52840 and clocks" sheetIndex={1}>
   <schematicsection name="rail_decoupling" displayName="3V decoupling" sectionTitleFontSize={.4}/>
   <Nrf52840 half={half}/>
 </schematicsheet>
 <schematicsheet name="radio" displayName="07 · RF matching and antenna" sheetIndex={6}>
   <RadioFrontend half={half}/>
 </schematicsheet>
 <schematicsheet name="power" displayName="03 · Li-ion charging and 3V supply" sheetIndex={2}>
   <BatteryPower half={half}/>
 </schematicsheet>
 <schematicsheet name="display" displayName="04 · Raw memory LCD interface" sheetIndex={3}>
   <Display half={half}/>
 </schematicsheet>
 <schematicsheet name="usb" displayName="05 · USB-C and ESD protection" sheetIndex={4}>
   <UsbC half={half}/>
 </schematicsheet>
 <schematicsheet name="debug" displayName="06 · SWD, reset and battery measurement" sheetIndex={5}>
   <Programming half={half}/>
 </schematicsheet>
 {!placementOnly&&!routeMatrix&&(['inner1','inner2'] as const).map(layer=>
   <React.Fragment key={layer}><copperpour name={`GND_${layer}`} layer={layer} connectsTo="net.GND"
    clearance={.125} traceMargin={.125} padMargin={.125} boardEdgeMargin={.25} cutoutMargin={.2}
    useThermalReliefs={false}/></React.Fragment>
 )}
 </board>
}