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

Commit

Permalink
Library: Add basis of has_kicad_symbol_...
Browse files Browse the repository at this point in the history
  • Loading branch information
mawildoer committed Sep 16, 2024
1 parent e29b6c6 commit 85a079e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/faebryk/library/_F.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from faebryk.library.has_footprint_defined import has_footprint_defined
from faebryk.library.has_kicad_footprint import has_kicad_footprint
from faebryk.library.Pad import Pad
from faebryk.library.has_kicad_symbol import has_kicad_symbol
from faebryk.library.has_symbol_defined import has_symbol_defined
from faebryk.library.Button import Button
from faebryk.library.Common_Mode_Filter import Common_Mode_Filter
Expand All @@ -102,6 +103,7 @@
from faebryk.library.has_equal_pins import has_equal_pins
from faebryk.library.has_kicad_manual_footprint import has_kicad_manual_footprint
from faebryk.library.has_pcb_routing_strategy_greedy_direct_line import has_pcb_routing_strategy_greedy_direct_line
from faebryk.library.has_kicad_manual_symbol import has_kicad_manual_symbol
from faebryk.library.BJT import BJT
from faebryk.library.Diode import Diode
from faebryk.library.MOSFET import MOSFET
Expand All @@ -119,6 +121,7 @@
from faebryk.library.can_attach_via_pinmap_equal import can_attach_via_pinmap_equal
from faebryk.library.has_equal_pins_in_ifs import has_equal_pins_in_ifs
from faebryk.library.has_kicad_footprint_equal_ifs import has_kicad_footprint_equal_ifs
from faebryk.library.has_kicad_symbol_equal_ifs import has_kicad_symbol_equal_ifs
from faebryk.library.KicadFootprint import KicadFootprint
from faebryk.library.TVS import TVS
from faebryk.library.can_be_decoupled import can_be_decoupled
Expand All @@ -130,6 +133,7 @@
from faebryk.library.SMDTwoPin import SMDTwoPin
from faebryk.library.SOIC import SOIC
from faebryk.library.has_kicad_footprint_equal_ifs_defined import has_kicad_footprint_equal_ifs_defined
from faebryk.library.has_kicad_symbol_equal_ifs_defined import has_kicad_symbol_equal_ifs_defined
from faebryk.library.Mounting_Hole import Mounting_Hole
from faebryk.library.can_be_surge_protected import can_be_surge_protected
from faebryk.library.is_surge_protected import is_surge_protected
Expand Down
17 changes: 17 additions & 0 deletions src/faebryk/library/has_kicad_manual_symbol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

import faebryk.library._F as F


class has_kicad_manual_symbol(F.has_kicad_symbol.impl()):
def __init__(self, str, pinmap: dict[F.Pad, str]) -> None:
super().__init__()
self.str = str
self.pinmap = pinmap

def get_kicad_symbol(self):
return self.str

def get_pin_names(self):
return self.pinmap
21 changes: 21 additions & 0 deletions src/faebryk/library/has_kicad_symbol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

from abc import abstractmethod
from typing import TYPE_CHECKING

import faebryk.library._F as F

if TYPE_CHECKING:
from faebryk.library.Pad import Pad


class has_kicad_symbol(F.Symbol.TraitT):
@abstractmethod
def get_kicad_symbol(self) -> str: ...

@abstractmethod
def get_pin_names(self) -> dict["Pad", str]: ...

def get_kicad_symbol_name(self) -> str:
return self.get_kicad_symbol().split(":")[-1]
9 changes: 9 additions & 0 deletions src/faebryk/library/has_kicad_symbol_equal_ifs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

import faebryk.library._F as F


class has_kicad_symbol_equal_ifs(F.has_kicad_symbol.impl()):
def get_pin_names(self):
return self.obj.get_trait(F.has_equal_pins).get_pin_map()
13 changes: 13 additions & 0 deletions src/faebryk/library/has_kicad_symbol_equal_ifs_defined.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file is part of the faebryk project
# SPDX-License-Identifier: MIT

import faebryk.library._F as F


class has_kicad_symbol_equal_ifs_defined(F.has_kicad_symbol_equal_ifs):
def __init__(self, str) -> None:
super().__init__()
self.str = str

def get_kicad_symbol(self):
return self.str

0 comments on commit 85a079e

Please sign in to comment.