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/check-preview-quality.py
"""Check the actual exported textures and preview pixels, rather than requested settings."""
from pathlib import Path
from io import BytesIO
import json, struct, hashlib, sys
from PIL import Image
half = sys.argv[1]
folder = Path(__file__).resolve().parents[1] / f'outputs/{half}'
model = (folder / 'keyboard-placement.glb').read_bytes()
length = struct.unpack_from('<I', model, 12)[0]
document = json.loads(model[20:20 + length])
binary = model[28 + length:]
textures = []
for image in document.get('images', []):
view = document['bufferViews'][image['bufferView']]
offset = view.get('byteOffset', 0)
with Image.open(BytesIO(binary[offset:offset + view['byteLength']])) as pixels:
textures.append(list(pixels.size))
with Image.open(folder / '3d.png') as pixels:
preview = list(pixels.size)
passed = len(textures) >= 2 and all(max(size) >= 4096 for size in textures[:2]) and preview == [1600, 1200]
report = {
'passed': passed, 'embeddedTexturePixels': textures, 'previewPixels': preview,
'glbSha256': hashlib.sha256(model).hexdigest(),
'circuitJsonSha256': hashlib.sha256((folder / 'keyboard.circuit.json').read_bytes()).hexdigest(),
}
(folder / 'preview-quality-check.json').write_text(json.dumps(report, indent=2) + '\n')
print(half, 'preview quality', report)
if not passed:
sys.exit(1)