Skip to content

Commit

Permalink
Merge pull request #202 from tscircuit/pcb-viewer-up
Browse files Browse the repository at this point in the history
Update 3d viewer, core and pcb viewer. Add switches to keyboard example
  • Loading branch information
seveibar authored Sep 23, 2024
2 parents 5570e42 + a964d32 commit f35fa6b
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 14 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions example-project/examples/basic-chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const BasicChip = () => (
<chip
name="U2"
schPortArrangement={{
leftSize: 4,
rightSize: 4,
leftSize: 8,
rightSize: 8,
}}
footprint="ssop16"
pinLabels={{
Expand Down
2 changes: 1 addition & 1 deletion example-project/examples/macrokeypad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { layout } from "@tscircuit/layout"
import { ArduinoProMicroBreakout } from "example-project/src/ArduinoProMicroBreakout"
import { Key } from "example-project/src/Key"
import manualEdits from "example-project/src/manual-edits"
import { SwitchShaft } from "example-project/src/SwitchShaft"
import { KeyswitchSocket } from "example-project/src/KeyswitchSocket"

export const MacroKeypad = () => {
const keyPositions = Array.from({ length: 9 })
Expand Down
20 changes: 15 additions & 5 deletions example-project/src/Key.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
import { SwitchShaft } from "./SwitchShaft"
import { Keyswitch } from "./Keyswitch"
import { KeyswitchSocket } from "./KeyswitchSocket"

export const Key = (props: {
name: string
keyNum: number
pcbX: number
pcbY: number
}) => {
const shaftName = `SW${props.keyNum}`
const socketName = `SW${props.keyNum}`
const switchHoleName = `HO${props.keyNum}`
const diodeName = `D${props.keyNum}`
return (
<>
<SwitchShaft
<KeyswitchSocket
key="shaft1"
name={shaftName}
layer="bottom"
name={socketName}
pcbX={props.pcbX}
pcbY={props.pcbY}
/>
<Keyswitch
key="switch"
name={switchHoleName}
pcbX={props.pcbX + 0.55}
pcbY={props.pcbY + -3.81}
/>
<diode
// @ts-ignore
key="diode"
pcbRotation={-90}
name={diodeName}
footprint="0603"
layer="bottom"
pcbX={props.pcbX + 7}
pcbY={props.pcbY - 6}
/>
<trace
// @ts-ignore
key="trace1"
from={`.${shaftName} .pin2`}
from={`.${socketName} .pin2`}
to={`.${diodeName} .pin1`}
/>
</>
Expand Down
33 changes: 33 additions & 0 deletions example-project/src/Keyswitch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Keyswitch (Brown)
*
* https://www.lcsc.com/datasheet/lcsc_datasheet_1912111437_Kailh-CPG1511F01S03_C400227.pdf
*/
export const Keyswitch = (props: {
name: string
pcbX?: number
pcbY?: number
}) => {
return (
<chip
{...props}
cadModel={{
objUrl:
"https://modelcdn.tscircuit.com/easyeda_models/download?pn=C400227",
rotationOffset: { x: 180, y: 0, z: -90 },
}}
footprint={
<footprint>
<smtpad
shape="rect"
width="0.1mm"
height="0.1mm"
portHints={["pin1"]}
layer="top"
/>
<hole diameter={2.5} pcbX={0} pcbY={0} />
</footprint>
}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import "@tscircuit/core"
*
* Datasheet: https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc/2211090930_Kailh-CPG151101S11-1_C5184526.pdf
*/
export const SwitchShaft = (props: {
export const KeyswitchSocket = (props: {
name: string
pcbX?: number
pcbY?: number
layer?: "top" | "bottom"
}) => (
<chip
{...props}
pcbRotation={0}
cadModel={{
objUrl: `https://modelcdn.tscircuit.com/easyeda_models/download?pn=C5184526`,
}}
footprint={
<footprint>
{/* <silkscreentext text={props.name} /> */}
Expand Down
18 changes: 17 additions & 1 deletion example-project/src/manual-edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ export default {
relative_to: "group_center",
},
],
manual_trace_hints: [],
manual_trace_hints: [
{
pcb_port_selector: ".D4 > .pin2",
offsets: [
{
x: -12.12299453118936,
y: -8.872955772271606,
via: true,
},
{
x: 43.833615026953254,
y: -17.47530225275473,
via: true,
},
],
},
],
edit_events: [],
}
1 change: 1 addition & 0 deletions frontend/views/MainContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "react-data-grid/lib/styles.css"
import { useEffect, useRef, useState } from "react"
import type { EditEvent } from "@tscircuit/pcb-viewer"
import { CadViewer } from "@tscircuit/3d-viewer"
import type { PcbHole, PcbSmtPad, PcbCircuitElement } from "circuit-json"

export const MainContentView = () => {
const devExamplePackageId = useGlobalStore(
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "bun run dev",
"dev": "bun run build:dev-server && concurrently 'bun run dev:frontend' 'bun run dev:test-project'",
"dev:fast": "concurrently 'bun run dev:frontend' 'bun run dev:test-project'",
"dev:frontend": "vite dev --config frontend/vite.config.ts",
"dev:frontend": "vite dev --force --config frontend/vite.config.ts",
"dev:test-project": "bun --hot cli/cli.ts dev --no-cleanup --cwd ./example-project",
"start:dev-server": "bun build:dev-server && bun cli/cli.ts dev -y --cwd ./example-project",
"build": "bun build:dev-server && npm run build:cli",
Expand All @@ -35,12 +35,13 @@
"dependencies": {
"@edge-runtime/primitives": "^4.1.0",
"@hono/node-server": "^1.8.2",
"@tscircuit/core": "^0.0.72",
"@tscircuit/core": "^0.0.84",
"@tscircuit/props": "^0.0.66",
"@tscircuit/soup": "^0.0.73",
"archiver": "^7.0.1",
"axios": "^1.6.7",
"chokidar": "^3.6.0",
"circuit-json": "^0.0.77",
"circuit-json-to-bom-csv": "^0.0.4",
"circuit-json-to-connectivity-map": "^0.0.16",
"circuit-json-to-gerber": "^0.0.4",
Expand All @@ -59,7 +60,7 @@
"hono": "^4.1.0",
"ignore": "^5.3.1",
"json5": "^2.2.3",
"kicad-converter": "^0.0.7",
"kicad-converter": "^0.0.12",
"kleur": "^4.1.5",
"lodash": "^4.17.21",
"memory-level": "^1.0.0",
Expand Down Expand Up @@ -103,7 +104,7 @@
"@tscircuit/3d-viewer": "^0.0.26",
"@tscircuit/layout": "^0.0.28",
"@tscircuit/manual-edit-events": "^0.0.4",
"@tscircuit/pcb-viewer": "^1.10.2",
"@tscircuit/pcb-viewer": "^1.10.4",
"@tscircuit/schematic-viewer": "^1.2.14",
"@tscircuit/soup-util": "^0.0.31",
"@tscircuit/table-viewer": "0.0.8",
Expand Down

0 comments on commit f35fa6b

Please sign in to comment.