rushabhcodes/desk-fidget-counter
A PLA desk fidget counter assembly houses an F1 PCB, 1.28-inch LCD with harness, rotary knob/bearing mechanism, button cap, and screw-secured base/display mount.
- Version
- 6.0.16
- License
- MIT
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone rushabhcodes/desk-fidget-counter # download the package files into ./desk-fidget-counter
tsci add rushabhcodes/desk-fidget-counter # add it to your project as @tsci/rushabhcodes.desk-fidget-counterIn 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/generate-board-pins.py
#!/usr/bin/env python3
"""Generate the firmware pin map from the circuit's RP2040 profile."""
from pathlib import Path
import argparse, json
root = Path(__file__).resolve().parents[1]
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--check', action='store_true')
args = parser.parse_args()
p = json.loads((root / 'reference/rp2040.json').read_text())
pins = list(p['gpio'].values())
assert len(pins) == len(set(pins)) and all(0 <= n < 30 for n in pins)
assert p['gpio']['ENC_B'] == p['gpio']['ENC_A'] + 1
assert [p['gpio'][n] for n in ['SDA', 'SCL', 'SPI_SCK', 'SPI_MOSI']] == [4, 5, 18, 19]
text = '// SPDX-License-Identifier: MIT\n// Generated by scripts/generate-board-pins.py; edit reference/rp2040.json.\n#pragma once\n'
text += ''.join(f'#define PIN_{name} {pin}u\n' for name, pin in p['gpio'].items())
for key in ['system_clock_hz', 'i2c_hz', 'spi_hz', 'encoder_max_step_rate']:
text += f'#define BOARD_{key.upper()} {p[key]}u\n'
dest = root / 'firmware/board-pins.h'
if args.check:
assert dest.read_text() == text, 'Firmware pin map differs from circuit profile'
print('RP2040 circuit/firmware pin map matches.')
else:
dest.write_text(text)