Skip to content
Merged
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
2 changes: 1 addition & 1 deletion generics/Capacitor.zen
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Component(
"P2": P2,
},
spice_model=SpiceModel(
"//simulation/Capacitor.lib",
"../simulation/Capacitor.lib",
"C",
nets=[P1, P2],
args={"CVAL": str(value.value)},
Expand Down
2 changes: 1 addition & 1 deletion generics/Crystal.zen
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Component(
symbol=Symbol(**_symbol(package)),
footprint=File(_footprint(package)),
spice_model=SpiceModel(
"//simulation/Crystal.lib",
"../simulation/Crystal.lib",
_spice_subcircuit_name(package),
nets=_spice_nets(package, XIN, XOUT, GND),
args=_spice_args(frequency, load_capacitance, package),
Expand Down
2 changes: 1 addition & 1 deletion generics/Diode.zen
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Component(
symbol=Symbol(**_symbol(variant)),
footprint=File(_footprint(mount, package)),
spice_model=SpiceModel(
"//simulation/Diode.lib",
"../simulation/Diode.lib",
_spice_subcircuit_name(variant),
nets=[A, K],
args=_spice_args(variant, v_f, i_f, v_r, i_r),
Expand Down
2 changes: 1 addition & 1 deletion generics/Inductor.zen
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Component(
"2": P2,
},
spice_model=SpiceModel(
"//simulation/Inductor.lib",
"../simulation/Inductor.lib",
"L",
nets=[P1, P2],
args={"LVAL": str(value.value)},
Expand Down
2 changes: 1 addition & 1 deletion generics/Led.zen
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Component(
footprint=File(_footprint(package)),
prefix="D",
spice_model=SpiceModel(
"//simulation/Led.lib",
"../simulation/Led.lib",
_spice_subcircuit_name(color),
nets=[A, K],
args=_spice_args(color, forward_voltage, forward_current),
Expand Down
2 changes: 1 addition & 1 deletion generics/NetTie.zen
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Component(
prefix="NT",
pins=_pins(P),
spice_model=SpiceModel(
"//simulation/NetTie.lib",
"../simulation/NetTie.lib",
_spice_subcircuit_name(pin_count),
nets=_spice_nets(P, pin_count),
args={"RVAL": "1m"}, # 1 milliohm for near-zero resistance
Expand Down
2 changes: 1 addition & 1 deletion generics/Resistor.zen
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Component(
"P2": P2,
},
spice_model=SpiceModel(
"//simulation/Resistor.lib",
"../simulation/Resistor.lib",
"R",
nets=[P1, P2],
args={"RVAL": str(value.value)},
Expand Down
17 changes: 11 additions & 6 deletions kicad/PinHeader.zen
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ Orientation = enum(
"Vertical_SMD_Pin1Right", # Vertical SMD with Pin 1 on right (single row)
)

_FOOTPRINT_DIRS = {
Pitch("1.27mm"): "@kicad-footprints/Connector_PinHeader_1.27mm.pretty",
Pitch("2.00mm"): "@kicad-footprints/Connector_PinHeader_2.00mm.pretty",
Pitch("2.54mm"): "@kicad-footprints/Connector_PinHeader_2.54mm.pretty",
}

# -----------------------------------------------------------------------------
# Component parameters
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -109,20 +115,19 @@ def _footprint(pins: int, rows: int, pitch: Pitch, orientation: Orientation):
"Vertical_SMD_Pin1Left and Vertical_SMD_Pin1Right orientations are only valid for single row (rows=1) pin headers. Use Vertical_SMD for dual row."
)

# Build footprint name
pitch_str = pitch.value
# Get footprint directory from table
footprint_dir = _FOOTPRINT_DIRS[pitch]

# Format pin count with leading zero if needed
pin_str = str(pins) if pins >= 10 else "0" + str(pins)

# Build the footprint name
if rows == 1:
footprint_name = "PinHeader_1x" + pin_str + "_P" + pitch_str + "_" + orientation_str
footprint_name = "PinHeader_1x" + pin_str + "_P" + pitch.value + "_" + orientation_str
else:
footprint_name = "PinHeader_2x" + pin_str + "_P" + pitch_str + "_" + orientation_str
footprint_name = "PinHeader_2x" + pin_str + "_P" + pitch.value + "_" + orientation_str

# Construct the file path
return "@kicad-footprints/Connector_PinHeader_" + pitch_str + ".pretty/" + footprint_name + ".kicad_mod"
return footprint_dir + "/" + footprint_name + ".kicad_mod"


def _symbol(pins: int, rows: int):
Expand Down
16 changes: 10 additions & 6 deletions kicad/PinSocket.zen
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Orientation = enum(
"Vertical_SMD", # Vertical SMD
)

_FOOTPRINT_DIRS = {
Pitch("2.00mm"): "@kicad-footprints/Connector_PinSocket_2.00mm.pretty",
Pitch("2.54mm"): "@kicad-footprints/Connector_PinSocket_2.54mm.pretty",
}

# -----------------------------------------------------------------------------
# Component parameters
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -57,25 +62,24 @@ def _footprint(pins: int, rows: int, pitch: Pitch, orientation: Orientation):
if rows not in [1, 2]:
error("Invalid row count: " + str(rows) + ". Must be 1 or 2.")

# Build footprint name
pitch_str = pitch.value
# Get footprint directory from table
footprint_dir = _FOOTPRINT_DIRS[pitch]

# Format pin count with leading zero if needed
pin_str = str(pins) if pins >= 10 else "0" + str(pins)

# Build the footprint name
if rows == 1:
footprint_name = "PinSocket_1x" + pin_str + "_P" + pitch_str + "_" + orientation.value
footprint_name = "PinSocket_1x" + pin_str + "_P" + pitch.value + "_" + orientation.value
else:
footprint_name = "PinSocket_2x" + pin_str + "_P" + pitch_str + "_" + orientation.value
footprint_name = "PinSocket_2x" + pin_str + "_P" + pitch.value + "_" + orientation.value

# Handle SMD variants with pin position
if orientation == Orientation("Vertical_SMD") and rows == 1:
# For single row SMD, we default to Pin1Left
footprint_name += "_Pin1Left"

# Construct the file path
return "@kicad-footprints/Connector_PinSocket_" + pitch_str + ".pretty/" + footprint_name + ".kicad_mod"
return footprint_dir + "/" + footprint_name + ".kicad_mod"


def _symbol(pins: int, rows: int):
Expand Down
Loading