Skip to content

Commit

Permalink
silkscreen definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed May 7, 2024
1 parent 96df6e0 commit 2ca6ef6
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/any-soup-element.ts → src/any_soup_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const any_soup_element = z.union([
pcb.pcb_smtpad,
pcb.pcb_board,
pcb.pcb_trace_hint,
pcb.pcb_silkscreen_line,
pcb.pcb_silkscreen_path,
pcb.pcb_trace_error,
pcb.pcb_placement_error,
pcb.pcb_port_not_matched_error,
Expand Down
3 changes: 3 additions & 0 deletions src/pcb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ export * from "./pcb_via"
export * from "./pcb_board"
export * from "./pcb_placement_error"
export * from "./pcb_trace_hint"
export * from "./pcb_silkscreen_line"
export * from "./pcb_silkscreen_path"
export * from "./pcb_silkscreen_text"
19 changes: 19 additions & 0 deletions src/pcb/pcb_silkscreen_line.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from "zod"
import { distance } from "../units"
import { layer_ref, visible_layer } from "./properties/layer_ref"

export const pcb_silkscreen_line = z
.object({
type: z.literal("pcb_silkscreen_line"),
pcb_silkscreen_line_id: z.string(),
pcb_component_id: z.string(),
x1: distance,
y1: distance,
x2: distance,
y2: distance,
layer: visible_layer,
})
.describe("Defines a silkscreen line on the PCB")

export type PcbSilkscreenLine = z.infer<typeof pcb_silkscreen_line>
export type PcbSilkscreenLineInput = z.input<typeof pcb_silkscreen_line>
16 changes: 16 additions & 0 deletions src/pcb/pcb_silkscreen_path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { z } from "zod"
import { visible_layer } from "./properties/layer_ref"
import { point } from "src/common"

export const pcb_silkscreen_path = z
.object({
type: z.literal("pcb_silkscreen_path"),
pcb_silkscreen_path_id: z.string(),
pcb_component_id: z.string(),
layer: visible_layer,
route: z.array(point),
})
.describe("Defines a silkscreen path on the PCB")

export type PcbSilkscreenPath = z.infer<typeof pcb_silkscreen_path>
export type PcbSilkscreenPathInput = z.input<typeof pcb_silkscreen_path>
18 changes: 18 additions & 0 deletions src/pcb/pcb_silkscreen_text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { z } from "zod"
import { visible_layer } from "./properties/layer_ref"
import { point } from "src/common"

export const pcb_silkscreen_text = z
.object({
type: z.literal("pcb_silkscreen_text"),
variant: z.literal("tscircuit2024").default("tscircuit2024"),
pcb_component_id: z.string(),
text: z.string(),
layer: visible_layer,
pcbX: z.number(),
pcbY: z.number(),
})
.describe("Defines silkscreen text on the PCB")

export type PcbSilkscreenText = z.infer<typeof pcb_silkscreen_text>
export type PcbSilkscreenTextInput = z.input<typeof pcb_silkscreen_text>
3 changes: 3 additions & 0 deletions src/pcb/properties/layer_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ export const layer_ref = layer_string

export type LayerRefInput = z.input<typeof layer_ref>
export type LayerRef = z.output<typeof layer_ref>

export const visible_layer = z.enum(["top", "bottom"])
export type VisibleLayerRef = z.infer<typeof visible_layer>

0 comments on commit 2ca6ef6

Please sign in to comment.