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-keyboardIn 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.
scripts/export-schematic-pdf.py
"""Combine native vector sheets, with a short review index, into a printable PDF."""
from pathlib import Path
import subprocess, json
from pypdf import PdfWriter
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
root = Path(__file__).resolve().parents[1]
temporary = root / '.cache/schematic-pdf'
temporary.mkdir(parents=True, exist_ok=True)
cover = temporary / 'index.pdf'
page = canvas.Canvas(str(cover), pagesize=A4)
page.setTitle('Wireless Split Keyboard - schematics')
page.setFont('Helvetica-Bold', 21)
page.drawString(48, 780, 'Wireless Split Keyboard')
page.setFont('Helvetica', 13)
page.drawString(48, 752, 'Native vector schematics - left and right PCBs')
page.setFont('Helvetica', 11)
for index, text in enumerate([
'Each half has seven A4 sheets:',
'01 Key matrix and rotary encoder',
'02 Bare nRF52840, clocks and decoupling',
'03 Li-ion charger, power path and 3 V regulator',
'04 Raw memory LCD interface and switched supply',
'05 USB-C sink, configuration resistors and ESD protection',
'06 SWD, reset and switched battery measurement',
'07 RF matching and antenna',
'',
'All sheets use native A4 size. Vector detail stays sharp.',
'Matching named nets connect the sheets. GPIOs are shared by both halves.',
'USB-C, power switch and hot-swap sockets are mounted on the bottom.',
'Physical outline, switch stems and mounting centers are locked.',
'',
'Routed prototype. Fabrication, RF tuning and physical fit remain pending.',
]):
page.drawString(48, 704 - index * 23, text)
page.save()
writer = PdfWriter()
writer.append(cover)
for half in ['left', 'right']:
circuit = json.loads((root / f'outputs/{half}/keyboard.circuit.json').read_text())
sheets = {sheet['sheet_index']: sheet for sheet in circuit if sheet['type'] == 'schematic_sheet'}
for svg in sorted((root / f'outputs/{half}/schematics').glob('*.svg')):
pdf = temporary / f'{half}-{svg.stem}.pdf'
sheet = sheets[int(svg.stem[:2]) - 1]
width = str(sheet['sheet_width']) + 'mm'
height = str(sheet['sheet_height']) + 'mm'
subprocess.run(['rsvg-convert', '--format=pdf', '--page-width=' + width, '--page-height=' + height, '--width=' + width, '--height=' + height, '--keep-aspect-ratio', '--output', str(pdf), str(svg)], check=True)
writer.append(pdf, outline_item=f'{half.title()} - {svg.stem}')
writer.add_metadata({'/Title': 'Wireless Split Keyboard - native schematics'})
writer.write(root / 'outputs/wireless-split-keyboard-schematics.pdf')
print(f'Wrote {len(writer.pages)} vector PDF pages')