Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./lib/RaspberryPiHatBoard/RaspberryPiHatBoard.circuit"
export * from "./lib/XiaoBoard/XiaoBoard.circuit"
export * from "./lib/ProMicroBoard/ProMicroBoard.circuit"
// export * from "./Common Boards/RaspberryPiHatBoard/RaspberryPiHatBoard.circuit"
export * from "./lib/ViaGridBoard/ViaGridBoard.circuit"
156 changes: 156 additions & 0 deletions lib/ViaGridBoard/ViaGridBoard.circuit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { splitBoardAndChipProps } from "../../util/splitBoardAndChipProps"
import { ChipProps, BoardProps } from "@tscircuit/props"
import { grid } from "@tscircuit/math-utils"
import {
ViaGridVia,
ViaGridPlus,
pacmanPolygonOutline,
} from "./viaGridElements"

type ViaGridBoardProps = ChipProps &
BoardProps & { children?: any; boardName?: string }

export const ViaGridBoard = ({ children, ...rest }: ViaGridBoardProps) => {
const { boardProps, chipProps = {} } = splitBoardAndChipProps({
...rest,
}) as {
boardProps: any
chipProps: Record<string, any>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this type casting necessary? (CC @Abse2001 if so we should patch this)

Copy link
Author

@raykholo raykholo Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seveibar lines 14 through 27 are a direct copy from the Arduino Shield in this repo. You said "there's an existing pattern in that tscircuit/common repo" which I interpreted as this so I copied it over directly. I don't use anything like this in the similar "userland" stuff I have been doing, but I defer to you to determine what is ultimately necessary or not for everything to work properly. However, it is important to deal with passing BoardProps and children into the that ViaGridBoard encompasses. So some variation of all this seems necessary.

}

const resolvedName = `${chipProps.name}_chip`
const { name: _, ...chipRest } = chipProps

return (
<board
{...boardProps}
width="100mm"
height="65mm"
boardAnchorPosition={{ x: 0, y: 0 }}
boardAnchorAlignment="bottom_left"
>
<pcbnoterect //User.1 kicad rect shows outer bounds of usable area
pcbX={50}
pcbY={32.5}
width={90}
height={55}
strokeWidth={0.3}
color="blue"
/>

{["BL", "TL", "TR", "BR"].map((cornerPositionName, index) => {
const x = (cornerPositionName.includes("R") ? 90 : 0) + 5
const y = (cornerPositionName.includes("T") ? 55 : 0) + 5
const rotation = index * 90
return (
<chip
key={"pacman_" + cornerPositionName}
name={cornerPositionName}
pcbX={x}
pcbY={y}
noSchematicRepresentation={true}
pcbRotation={-rotation} //{(cell.index-1)*90}
footprint={
<footprint>
<smtpad
pcbX="0mm"
pcbY="0mm"
layer="top"
shape="polygon"
portHints={["pin1"]}
points={pacmanPolygonOutline}
/>
</footprint>
}
/>
)
})}

<ViaGridPlus pcbX={30} pcbY={25} startIndex={0} />
<ViaGridPlus pcbX={70} pcbY={25} startIndex={5} />
<ViaGridPlus pcbX={30} pcbY={40} startIndex={10} />
<ViaGridPlus pcbX={70} pcbY={40} startIndex={15} />

{horizontalEdgeViaGridCells.map((cell) => (
<ViaGridVia
pcbX={cell.center.x}
pcbY={cell.center.y}
key={cell.index}
viaIndex={cell.index + 20}
/>
))}

{verticalEdgeViaGridCells.map((cell) => (
<ViaGridVia
pcbX={cell.center.x}
pcbY={cell.center.y}
key={cell.index}
viaIndex={cell.index + 54}
/>
))}

<chip
name="TOP_RECT"
noSchematicRepresentation={true}
footprint={
<footprint>
<smtpad
pcbX="50mm"
pcbY="62.5mm"
layer="top"
shape="rect"
width="40mm"
height="3mm"
portHints={["pin1"]}
cornerRadius={0.5}
/>
</footprint>
}
/>

<silkscreentext
text="VIAGRID TOP"
fontSize="1.5mm"
pcbX={50}
pcbY={2.5}
/>
<net name="GND" />
{/* <copperpour
connectsTo="net.GND"
layer="top"
// outline=[
// { x: 5, y: 5 },
// { x: 5, y: 60 },
// { x: 95, y: 60 },
// { x: 95, y: 5 }
// ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @ShiboSoftwareDev we should get this working!

/> */}
</board>
)
}

const horizontalEdgeViaGridCells = grid({
rows: 2,
cols: 17,
// width: 80,
// height: 45,
xSpacing: 5, // if you want to provide the spacing instead of width
ySpacing: 45, // if you want to provide the spacing instead of height
offsetX: 90 / 2 + 5, // optional
offsetY: 55 / 2 + 5, // optional
yDirection: "up-is-negative", // optional, default: "cartesian"
// centered: true // optional, default: true
})

const verticalEdgeViaGridCells = grid({
rows: 8,
cols: 2,
// width: 80,
// height: 45,
xSpacing: 80, // if you want to provide the spacing instead of width
ySpacing: 5, // if you want to provide the spacing instead of height
offsetX: 90 / 2 + 5, // optional
offsetY: 55 / 2 + 5, // optional
yDirection: "up-is-negative", // optional, default: "cartesian"
// centered: true // optional, default: true
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions lib/ViaGridBoard/viaGridElements.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { CommonLayoutProps, GroupProps } from "@tscircuit/props"
import { OutlineBuilder } from "../../util/outlineBuilder"

export const ViaGridVia = (props: CommonLayoutProps & { viaIndex: number }) => {
const { viaIndex, ...restProps } = props
return (
<via
name={`via_${viaIndex}`}
fromLayer="top"
toLayer="bottom"
outerDiameter="1.5mm"
holeDiameter="0.3mm"
// pcbX={0}
// pcbY={0}
{...restProps}
/>
)
}

export const ViaGridPlus = (props: GroupProps & { startIndex: number }) => {
const { startIndex, ...restProps } = props
return (
<group {...restProps}>
<ViaGridVia pcbX={0} pcbY={0} viaIndex={startIndex} />
<ViaGridVia pcbX={2.5} pcbY={0} viaIndex={startIndex + 1} />
<ViaGridVia pcbX={0} pcbY={2.5} viaIndex={startIndex + 2} />
<ViaGridVia pcbX={-2.5} pcbY={0} viaIndex={startIndex + 3} />
<ViaGridVia pcbX={0} pcbY={-2.5} viaIndex={startIndex + 4} />
</group>
)
}

export default ViaGridPlus

export const pacmanPolygonOutline = new OutlineBuilder(-0.2, -0.2)
.lineTo(-0.2, 2.5)
.arcTo(-2.5, 0, { radius: 2.5, sweep: true })
.arcTo(0, -2.5, { radius: 2.5, sweep: true })
.arcTo(2.5, -0.2, { radius: 2.5, sweep: true })
.lineTo(-0.2, -0.2)
.toArray()
Loading