seveibar/nine-key-keyboard
This code defines a PCB layout with a Raspberry Pi Pico microcontroller and a 3x3 grid of switches and SMD diodes connected via traces.
- Version
- 1.0.0
- License
- unset
- Stars
- 3
dist/index.js
PCB
import { jsxs, jsx } from 'react/jsx-runtime';
import { SmdDiode } from '@tsci/seveibar.SmdDiode';
import { Key } from '@tsci/seveibar.Key';
import { Pico2 } from '@tsci/seveibar.pico2';
const rowToMicroPin = {
0: "GP0",
1: "GP1",
2: "GP10",
};
const colToMicroPin = {
0: "GP19",
1: "GP17",
2: "GP5",
};
var index = () => (jsxs("board", { width: "100mm", height: "60mm", outlineOffsetY: -4, schTraceAutoLabelEnabled: true, children: [jsx(Pico2, { name: "U1", pcbX: -30 }), grid({ sizeX: 3, sizeY: 3, pitch: 19.05, offset: { x: 20, y: 0 } }).map(({ x, y, row, col }, index) => {
const schOffX = 5 + x / 6;
const schOffY = -y / 8;
return (jsxs("group", { children: [jsx(Key, { pcbX: x, pcbY: y, schX: schOffX, schY: schOffY + 0.5, name: `K${index + 1}` }), jsx(SmdDiode, { pcbX: x, pcbY: y - 13, schX: schOffX, schY: schOffY, layer: "bottom", name: `D${index + 1}` }), jsx("trace", { from: `.D${index + 1} .pin1`, to: `.K${index + 1} .pin1` }), jsx("trace", { from: `.D${index + 1} .pin2`, to: `.U1 .${rowToMicroPin[row]}` }), jsx("trace", { from: `.K${index + 1} .pin2`, to: `.U1 .${colToMicroPin[col]}` })] }, `Kgroup${index}`));
})] }));
function grid(opts) {
const { sizeX, sizeY, pitch, offset = { x: 0, y: 0 } } = opts;
const points = [];
const startX = (-2 * pitch) / 2;
const startY = (-2 * pitch) / 2;
for (let row = 0; row < sizeY; row++) {
for (let col = 0; col < sizeX; col++) {
points.push({
x: startX + col * pitch + offset.x,
y: startY + row * pitch + offset.y,
row,
col,
});
}
}
return points;
}
export { index as default };