-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tscircuit/layout-and-extras
Jumper Support, pinLabels fix, Resistor.pullup, Capacitor.decoupling, Silkscreen drawings
- Loading branch information
Showing
23 changed files
with
313 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = ["./tests/fixtures/preload.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { NormalComponent } from "lib/components/base-components/NormalComponent" | ||
import { jumperProps } from "@tscircuit/props" | ||
import { Port } from "../primitive-components/Port" | ||
import type { BaseSymbolName } from "lib/utils/constants" | ||
import { | ||
getAllDimensionsForSchematicBox, | ||
type SchematicBoxDimensions, | ||
} from "lib/utils/schematic/getAllDimensionsForSchematicBox" | ||
import { underscorifyPortArrangement } from "lib/soup/underscorifyPortArrangement" | ||
import { underscorifyPinStyles } from "lib/soup/underscorifyPinStyles" | ||
|
||
export class Jumper<PinLabels extends string = never> extends NormalComponent< | ||
typeof jumperProps, | ||
PinLabels | ||
> { | ||
schematicDimensions: SchematicBoxDimensions | null = null | ||
|
||
get config() { | ||
return { | ||
zodProps: jumperProps, | ||
} | ||
} | ||
|
||
doInitialSourceRender(): void { | ||
const { db } = this.project! | ||
const { _parsedProps: props } = this | ||
|
||
const source_component = db.source_component.insert({ | ||
ftype: "simple_chip", // TODO unknown or jumper | ||
name: props.name, | ||
manufacturer_part_number: props.manufacturerPartNumber, | ||
supplier_part_numbers: props.supplierPartNumbers, | ||
}) | ||
|
||
this.source_component_id = source_component.source_component_id! | ||
} | ||
|
||
doInitialSchematicComponentRender() { | ||
const { db } = this.project! | ||
const { _parsedProps: props } = this | ||
|
||
const ports = this.children.filter((child) => child instanceof Port) | ||
|
||
const pinSpacing = props.schPinSpacing ?? 0.2 | ||
|
||
const dimensions = getAllDimensionsForSchematicBox({ | ||
schWidth: props.schWidth, | ||
schHeight: props.schHeight, | ||
schPinSpacing: pinSpacing, | ||
schPinStyle: props.schPinStyle, | ||
|
||
pinCount: ports.length, | ||
|
||
// @ts-ignore there's a subtley in the definition difference with | ||
// leftSide/rightSide/topSide/bottomSide in how the direction is defined | ||
// that doesn't really matter | ||
schPortArrangement: { | ||
// TODO use schematic direction or schPortArrangement | ||
rightSize: ports.length, | ||
}, | ||
}) | ||
this.schematicDimensions = dimensions | ||
|
||
const schematic_component = db.schematic_component.insert({ | ||
center: { x: props.schX ?? 0, y: props.schY ?? 0 }, | ||
rotation: props.schRotation ?? 0, | ||
size: dimensions.getSize(), | ||
|
||
port_arrangement: underscorifyPortArrangement( | ||
props.schPortArrangement as any, | ||
), | ||
|
||
pin_spacing: pinSpacing, | ||
|
||
// @ts-ignore soup needs to support distance for pin_styles | ||
pin_styles: underscorifyPinStyles(props.schPinStyle), | ||
|
||
port_labels: props.pinLabels, | ||
|
||
source_component_id: this.source_component_id!, | ||
}) | ||
|
||
this.schematic_component_id = schematic_component.schematic_component_id | ||
} | ||
|
||
doInitialPcbComponentRender() { | ||
const { db } = this.project! | ||
const { _parsedProps: props } = this | ||
|
||
const pcb_component = db.pcb_component.insert({ | ||
center: { x: props.pcbX ?? 0, y: props.pcbY ?? 0 }, | ||
width: 2, // Default width, adjust as needed | ||
height: 3, // Default height, adjust as needed | ||
layer: props.layer ?? "top", | ||
rotation: props.pcbRotation ?? 0, | ||
source_component_id: this.source_component_id!, | ||
}) | ||
|
||
this.pcb_component_id = pcb_component.pcb_component_id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { silkscreenPathProps } from "@tscircuit/props" | ||
import { PrimitiveComponent } from "../base-components/PrimitiveComponent" | ||
|
||
export class SilkscreenPath extends PrimitiveComponent< | ||
typeof silkscreenPathProps | ||
> { | ||
pcb_silkscreen_path_id: string | null = null | ||
|
||
get config() { | ||
return { | ||
zodProps: silkscreenPathProps, | ||
} | ||
} | ||
|
||
doInitialPcbPrimitiveRender(): void { | ||
const { db } = this.project! | ||
const { _parsedProps: props } = this | ||
|
||
const layer = props.layer ?? "top" | ||
if (layer !== "top" && layer !== "bottom") { | ||
throw new Error( | ||
`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`, | ||
) | ||
} | ||
|
||
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({ | ||
pcb_component_id: this.parent?.pcb_component_id!, | ||
layer, | ||
route: props.route, | ||
stroke_width: props.strokeWidth ?? 0.1, | ||
}) | ||
|
||
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.