seveibar/keyboard-sample
A tscircuit package created by seveibar.
Usage: For "@tsci/seveibar.keyboard-sample": 1. Import the component: ```tsx import KeyboardSample from "@tsci/seveibar.keyboard-sample" ``` 2. Use the component in a React-like circuit design: ```tsx <board> <KeyboardSample sampleNumber={3} /> </board> ``` The component takes an optional `sampleNumber` parameter to define the grid size of the keyboard matrix (defaults to 2). It automatically generates a keyboard matrix with keys, diodes, and traces connecting to a Pico2 microcontroller.
- Version
- 0.0.1
- License
- unset
- Stars
- 0
dist/index.cjs
PCB
Schematic
'use strict';
var core = require('@tscircuit/core');
function _extends$3() { return _extends$3 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$3.apply(null, arguments); }
const SmdDiode = props => {
return /*#__PURE__*/React.createElement("diode", _extends$3({}, props, {
footprint: /*#__PURE__*/React.createElement("footprint", null, /*#__PURE__*/React.createElement("smtpad", {
portHints: ["1"],
pcbX: "-1.1725910000000113mm",
pcbY: "0mm",
width: "0.9999979999999999mm",
height: "0.7500112mm",
shape: "rect"
}), /*#__PURE__*/React.createElement("smtpad", {
portHints: ["2"],
pcbX: "1.1725910000000113mm",
pcbY: "0mm",
width: "0.9999979999999999mm",
height: "0.7500112mm",
shape: "rect"
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 0.9012427999999773,
y: -0.726211400000011
}, {
x: 0.9012427999999773,
y: -0.5199887999999646
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 0.9012427999999773,
y: 0.726211400000011
}, {
x: 0.9012427999999773,
y: 0.5299964000000728
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -0.8512047999998913,
y: 0.726211400000011
}, {
x: 0.9012427999999773,
y: 0.726211400000011
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -0.8512047999998913,
y: -0.726211400000011
}, {
x: 0.9012427999999773,
y: -0.726211400000011
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -0.44676059999994777,
y: 0.726211400000011
}, {
x: -0.44676059999994777,
y: -0.726211400000011
}]
})),
supplierPartNumbers: {
jlcpcb: ["C57759"]
},
cadModel: {
objUrl: "https://modelcdn.tscircuit.com/easyeda_models/download?uuid=973acf8a660c48b1975f1ba1c890421a&pn=C57759",
rotationOffset: {
x: 0,
y: 0,
z: 0
},
positionOffset: {
x: 0,
y: 0,
z: 0
}
},
schPinSpacing: 0.75,
schPortArrangement: {
leftSide: {
direction: "top-to-bottom",
pins: [1]
},
rightSide: {
direction: "bottom-to-top",
pins: [2]
}
}
}));
};
function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
const pinLabels$1 = {
"1": "pin1",
"2": "pin2"
};
const pinNames$1 = Object.values(pinLabels$1);
const KeyHotSocket = props => {
return /*#__PURE__*/React.createElement("pushbutton", _extends$1({
layer: "bottom"
}, props, {
footprint: /*#__PURE__*/React.createElement("footprint", null, /*#__PURE__*/React.createElement("hole", {
pcbX: "3.1749999999999545mm",
pcbY: "-1.2699999999999818mm",
diameter: "2.9999939999999996mm"
}), /*#__PURE__*/React.createElement("hole", {
pcbX: "-3.1749999999999545mm",
pcbY: "1.2700000000000955mm",
diameter: "2.9999939999999996mm"
}), /*#__PURE__*/React.createElement("smtpad", {
portHints: ["2"],
pcbX: "6.724904000000038mm",
pcbY: "-1.2699999999999818mm",
width: "2.8999941999999996mm",
height: "2.4999949999999997mm",
shape: "rect"
}), /*#__PURE__*/React.createElement("smtpad", {
portHints: ["1"],
pcbX: "-6.724904000000038mm",
pcbY: "1.2699999999999818mm",
width: "2.8999941999999996mm",
height: "2.4999949999999997mm",
shape: "rect"
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -5.461000000000013,
y: -0.4611370000000079
}, {
x: -5.461000000000013,
y: -2.9209999999999354
}, {
x: -5.461000000000013,
y: -2.9209999999999354
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 5.4500017999999955,
y: -2.950006799999869
}, {
x: -5.461000000000013,
y: -2.950006799999869
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 0.18298159999994823,
y: 1.0549889999999778
}, {
x: 5.450027199999909,
y: 1.0549889999999778
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 5.450027199999909,
y: 1.0549889999999778
}, {
x: 5.450027199999909,
y: 0.4611370000000079
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -2.944114000000127,
y: 2.9450030000000424
}, {
x: -5.461000000000013,
y: 2.9450030000000424
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -1.707006999999976,
y: 2.9450030000000424
}, {
x: -2.944114000000127,
y: 2.9450030000000424
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -1.707006999999976,
y: 2.9450030000000424
}, {
x: -1.460311886129034,
y: 2.9288336092640748
}, {
x: -1.2178378661753868,
y: 2.8806021044970294
}, {
x: -0.9837338087377248,
y: 2.801133754218995
}, {
x: -0.762005367588813,
y: 2.6917883071702136
}, {
x: -0.5564464426572613,
y: 2.5544367262343712
}, {
x: -0.37057426423848483,
y: 2.3914291751993915
}, {
x: -0.20756921118118044,
y: 2.2055548061152876
}, {
x: -0.07022039279377168,
y: 1.9999940353145576
}, {
x: 0.03912207440475868,
y: 1.7782641246765252
}, {
x: 0.11858727851722506,
y: 1.5441589992735771
}, {
x: 0.1668155246366041,
y: 1.301684331151364
}, {
x: 0.18298159999994823,
y: 1.0549889999999778
}]
})),
supplierPartNumbers: {
jlcpcb: ["C41430893"]
},
cadModel: {
objUrl: "https://modelcdn.tscircuit.com/easyeda_models/download?uuid=c886ec2b42464573a88fc1f647577a49&pn=C5184526",
rotationOffset: {
x: 0,
y: 0,
z: 0
},
positionOffset: {
x: 0,
y: 0,
z: 0
}
},
pinLabels: pinLabels$1,
schPortArrangement: {
leftSide: {
direction: "top-to-bottom",
pins: [1]
},
rightSide: {
direction: "bottom-to-top",
pins: [2]
}
}
}));
};
core.createUseComponent(KeyHotSocket, pinNames$1);
function _extends$2() { return _extends$2 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$2.apply(null, arguments); }
const pinLabels = {
"1": "pin1",
"2": "pin2"
};
const pinNames = Object.values(pinLabels);
const KeyShaftForHotSocket = props => {
return /*#__PURE__*/React.createElement("chip", _extends$2({}, props, {
noSchematicRepresentation: true,
schWidth: 0.1,
schHeight: 0.1,
supplierPartNumbers: {
jlcpcb: ["C400227"]
},
footprint: /*#__PURE__*/React.createElement("footprint", null, /*#__PURE__*/React.createElement("hole", {
pcbX: "0.6349999999999909mm",
pcbY: "-3.1149987999999666mm",
diameter: "4.1999916mm"
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -7.165009800000007,
y: 4.685011000000031
}, {
x: 8.435009799999989,
y: 4.685011000000031
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -7.165009800000007,
y: -10.915008600000078
}, {
x: 8.435009799999989,
y: -10.915008600000078
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: -7.165009800000007,
y: 4.685011000000031
}, {
x: -7.165009800000007,
y: -10.915008600000078
}]
}), /*#__PURE__*/React.createElement("silkscreenpath", {
route: [{
x: 8.435009799999989,
y: 4.685011000000031
}, {
x: 8.435009799999989,
y: -10.915008600000078
}]
})),
cadModel: {
objUrl: "https://modelcdn.tscircuit.com/easyeda_models/download?uuid=c00f29e7afb64c29bc388e168980ded2&pn=C400227",
rotationOffset: {
x: 0,
y: 0,
z: 90
},
positionOffset: {
x: 0,
y: 0,
z: 0
}
},
pinLabels: pinLabels,
schPinSpacing: 0.75,
schPortArrangement: {}
}));
};
core.createUseComponent(KeyShaftForHotSocket, pinNames);
const Key = props => {
return /*#__PURE__*/React.createElement("group", {
pcbX: props.pcbX,
pcbY: props.pcbY,
schX: props.schX,
schY: props.schY
}, /*#__PURE__*/React.createElement(KeyHotSocket, {
name: props.name,
connections: props.connections
}), /*#__PURE__*/React.createElement(KeyShaftForHotSocket, {
name: `${props.name}_shaft`,
pcbX: 0,
pcbY: -0.52
}), /*#__PURE__*/React.createElement("footprint", null, /*#__PURE__*/React.createElement("silkscreentext", {
text: props.name,
pcbY: 5
})));
};
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const Pico2 = props => /*#__PURE__*/React.createElement("chip", _extends({}, props, {
pinLabels: {
"1": "GP0",
"2": "GP1",
"3": "GND1",
"4": "GP2",
"5": "GP3",
"6": "GP4",
"7": "GP5",
"8": "GND",
"9": "GP6",
"10": "GP7",
"11": "GP8",
"12": "GP9",
"13": "GND2",
"14": "GP10",
"15": "GP11",
"16": "GP12",
"17": "GP13",
"18": "GND3",
"19": "GP14",
"20": "GP15",
"21": "GP16",
"22": "GP17",
"23": "GND4",
"24": "GP18",
"25": "GP19",
"26": "GP20",
"27": "GP21",
"28": "GND5",
"29": "GP22",
"30": "RUN",
"31": "GP26",
"32": "GP27",
"33": "GND6",
"34": "GP28",
"35": "ADC_VREF",
"36": "V3V3",
"37": "V3V3_EN",
"38": "GND7",
"39": "VSYS",
"40": "VBUS"
},
footprint: "soic40_w22.58mm_p2.54mm_pl3.8_ph2.2"
}));
function grid(opts) {
const {
sizeX,
sizeY,
pitch,
offset = {
x: 0,
y: 0
}
} = opts;
const points = [];
const startX = -(sizeX - 1) * pitch / 2;
const startY = -(sizeY - 1) * 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;
}
const rowToMicroPin = {
0: "GP0",
1: "GP1",
2: "GP10"
};
const colToMicroPin = {
0: "GP19",
1: "GP17",
2: "GP5"
};
var index = ({
sampleNumber = 2
}) => {
return /*#__PURE__*/React.createElement("board", {
width: "100mm",
height: "100mm",
routingDisabled: true
}, /*#__PURE__*/React.createElement(Pico2, {
name: "U1",
pcbX: -30
}), grid({
sizeX: sampleNumber,
sizeY: sampleNumber,
pitch: 19.05,
offset: {
x: 20,
y: 0
}
}).map(({
x,
y,
row,
col
}, index) => /*#__PURE__*/React.createElement("group", {
key: `Kgroup${index}`
}, /*#__PURE__*/React.createElement(Key, {
pcbX: x,
pcbY: y,
name: `K${index + 1}`
}), /*#__PURE__*/React.createElement(SmdDiode, {
pcbX: x,
pcbY: y - 13,
layer: "bottom",
name: `D${index + 1}`
}), /*#__PURE__*/React.createElement("trace", {
from: `.D${index + 1} .pin1`,
to: `.K${index + 1} .pin1`
}), /*#__PURE__*/React.createElement("trace", {
from: `.D${index + 1} .pin2`,
to: `.U1 .${rowToMicroPin[row]}`
}), /*#__PURE__*/React.createElement("trace", {
from: `.K${index + 1} .pin2`,
to: `.U1 .${colToMicroPin[col]}`
}))));
};
module.exports = index;