Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Library: Add NetTie to library
Browse files Browse the repository at this point in the history
  • Loading branch information
mawildoer committed Sep 5, 2024
1 parent d82e61e commit 417b26b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/faebryk/library/KicadFootprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
class KicadFootprint(F.Footprint):
def __init__(self, kicad_identifier: str, pin_names: list[str]) -> None:
super().__init__()
assert ":" in kicad_identifier, (
'kicad_identifier must be in the format "library:footprint".'
" If not, it'll cause downstream problems"
)

unique_pin_names = sorted(set(pin_names))
self.pin_names_sorted = list(enumerate(unique_pin_names))
Expand Down
51 changes: 51 additions & 0 deletions src/faebryk/library/NetTie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

import logging
from enum import Enum

import faebryk.library._F as F
from faebryk.core.module import Module
from faebryk.core.moduleinterface import ModuleInterface
from faebryk.library.Electrical import Electrical
from faebryk.library.KicadFootprint import KicadFootprint
from faebryk.libs.picker.picker import has_part_picked_remove

logger = logging.getLogger(__name__)


class NetTie[T: ModuleInterface](Module):
class Size(float, Enum):
_2_0MM = 2.0
_0_5MM = 0.5

unnamed: list[T]

def __init__(
self,
width: Size,
interface_type: type[T] = Electrical,
) -> None:
super().__init__()

# dynamically construct the interfaces
self.unnamed = self.add([interface_type(), interface_type()], "unnamed")

# add dem trairs
self.add(F.can_bridge_defined(*self.unnamed))

width_mm = NetTie.Size(width).value

self.add(F.can_attach_to_footprint_symmetrically())
self.add(F.has_designator_prefix_defined("H"))
# TODO: "removed" isn't really true, but seems to work
self.add(has_part_picked_remove())

# TODO: generate the kicad footprint instead of loading it
self.add(
F.has_footprint_defined(
KicadFootprint(
f"NetTie:NetTie-2_SMD_Pad{width_mm:.1f}mm", pin_names=["1", "2"]
)
)
)
1 change: 1 addition & 0 deletions src/faebryk/library/_F.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
from faebryk.library.Capacitor import Capacitor
from faebryk.library.Fuse import Fuse
from faebryk.library.Inductor import Inductor
from faebryk.library.NetTie import NetTie
from faebryk.library.Resistor import Resistor
from faebryk.library.Switch import Switch
from faebryk.library.B4B_ZR_SM4_TF import B4B_ZR_SM4_TF
Expand Down

0 comments on commit 417b26b

Please sign in to comment.