This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d575fab
commit 105afa7
Showing
12 changed files
with
203 additions
and
30 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,79 @@ | ||
# This file is part of the faebryk project | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
This file contains a faebryk sample. | ||
""" | ||
|
||
import logging | ||
|
||
import typer | ||
|
||
import faebryk.library._F as F | ||
from faebryk.core.module import Module | ||
from faebryk.exporters.pcb.layout.extrude import LayoutExtrude | ||
from faebryk.exporters.pcb.layout.typehierarchy import LayoutTypeHierarchy | ||
from faebryk.libs.brightness import TypicalLuminousIntensity | ||
from faebryk.libs.examples.buildutil import apply_design_to_pcb | ||
from faebryk.libs.library import L | ||
from faebryk.libs.logging import setup_basic_logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class App(Module): | ||
led = L.f_field(F.LEDIndicator)(use_mosfet=False) | ||
mcu: F.RP2040_ReferenceDesign | ||
usb_power: F.USB_C_5V_PSU | ||
|
||
def __preinit__(self) -> None: | ||
# Parametrize | ||
self.led.led.led.color.merge(F.LED.Color.YELLOW) | ||
self.led.led.led.brightness.merge( | ||
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value | ||
) | ||
|
||
self.usb_power.power_out.connect(self.mcu.usb.usb_if.buspower) | ||
self.mcu.rp2040.gpio[25].connect(self.led.logic_in) | ||
self.mcu.rp2040.pinmux.enable(self.mcu.rp2040.gpio[25]) | ||
|
||
self._set_layout() | ||
|
||
def _set_layout(self): | ||
# set center | ||
self.add( | ||
F.has_pcb_position_defined( | ||
F.has_pcb_position.Point( | ||
(50, 50, 0, F.has_pcb_position.layer_type.TOP_LAYER) | ||
) | ||
) | ||
) | ||
|
||
# distribute horizontally | ||
layout = LayoutTypeHierarchy( | ||
layouts=[ | ||
LayoutTypeHierarchy.Level( | ||
mod_type=Module, | ||
layout=LayoutExtrude((20, 0)), | ||
) | ||
] | ||
) | ||
self.add(F.has_pcb_layout_defined(layout)) | ||
|
||
|
||
# Boilerplate ----------------------------------------------------------------- | ||
|
||
|
||
def main(): | ||
logger.info("Building app") | ||
app = App() | ||
|
||
logger.info("Export") | ||
apply_design_to_pcb(app) | ||
|
||
|
||
if __name__ == "__main__": | ||
setup_basic_logging() | ||
logger.info("Running example") | ||
|
||
typer.run(main) |
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
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,23 @@ | ||
# This file is part of the faebryk project | ||
# SPDX-License-Identifier: MIT | ||
|
||
import logging | ||
from abc import abstractmethod | ||
|
||
from faebryk.core.module import Module | ||
from faebryk.core.trait import Trait | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class is_multi_module(Trait): | ||
""" | ||
Docstring describing your module | ||
""" | ||
|
||
@abstractmethod | ||
def get(self) -> list[Module]: | ||
""" | ||
Docstring describing the function | ||
""" | ||
pass |
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,17 @@ | ||
# This file is part of the faebryk project | ||
# SPDX-License-Identifier: MIT | ||
|
||
import logging | ||
|
||
from faebryk.core.module import Module | ||
from faebryk.library.is_multi_module import is_multi_module | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class is_multi_module_defined(is_multi_module.impl()): | ||
def __init__(self, children: list[Module]): | ||
self._children = children | ||
|
||
def get(self) -> list[Module]: | ||
return self._children |
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,17 @@ | ||
# This file is part of the faebryk project | ||
# SPDX-License-Identifier: MIT | ||
|
||
import logging | ||
|
||
from faebryk.core.module import Module | ||
from faebryk.library.is_multi_module import is_multi_module | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class is_multi_module_defined_by_type(is_multi_module.impl()): | ||
def __init__(self, children_type: type[Module]): | ||
self._children_type = children_type | ||
|
||
def get(self) -> list[Module]: | ||
return self.obj.get_children(direct_only=False, types=self._children_type) |