cadbuildr-electronics 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. cadbuildr/__init__.py +3 -0
  2. cadbuildr/electronics/__init__.py +120 -0
  3. cadbuildr/electronics/_solids.py +89 -0
  4. cadbuildr/electronics/board.py +117 -0
  5. cadbuildr/electronics/boards/__init__.py +16 -0
  6. cadbuildr/electronics/boards/arduino_nano.py +59 -0
  7. cadbuildr/electronics/boards/arduino_uno.py +98 -0
  8. cadbuildr/electronics/boards/esp32_devkit.py +62 -0
  9. cadbuildr/electronics/boards/raspberry_pi.py +82 -0
  10. cadbuildr/electronics/boards/raspberry_pi_pico.py +70 -0
  11. cadbuildr/electronics/catalog/__init__.py +10 -0
  12. cadbuildr/electronics/catalog/catalog.py +126 -0
  13. cadbuildr/electronics/catalog/digikey.py +200 -0
  14. cadbuildr/electronics/catalog/package.py +37 -0
  15. cadbuildr/electronics/catalog/part.py +37 -0
  16. cadbuildr/electronics/components/__init__.py +44 -0
  17. cadbuildr/electronics/components/connectors.py +178 -0
  18. cadbuildr/electronics/components/diodes.py +68 -0
  19. cadbuildr/electronics/components/ics.py +139 -0
  20. cadbuildr/electronics/components/misc.py +59 -0
  21. cadbuildr/electronics/components/passives.py +147 -0
  22. cadbuildr/electronics/constants.py +65 -0
  23. cadbuildr/electronics/data/packages.json +33 -0
  24. cadbuildr/electronics/data/parts.csv +11 -0
  25. cadbuildr/electronics/families/__init__.py +14 -0
  26. cadbuildr/electronics/families/_ipc.py +82 -0
  27. cadbuildr/electronics/families/base.py +91 -0
  28. cadbuildr/electronics/families/generators.py +173 -0
  29. cadbuildr/electronics/footprint.py +207 -0
  30. cadbuildr/electronics/pcb.py +209 -0
  31. cadbuildr/electronics/projects.py +76 -0
  32. cadbuildr_electronics-0.1.0.dist-info/METADATA +185 -0
  33. cadbuildr_electronics-0.1.0.dist-info/RECORD +35 -0
  34. cadbuildr_electronics-0.1.0.dist-info/WHEEL +4 -0
  35. cadbuildr_electronics-0.1.0.dist-info/licenses/LICENSE +21 -0
cadbuildr/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from pkgutil import extend_path
2
+
3
+ __path__ = extend_path(__path__, __name__)
@@ -0,0 +1,120 @@
1
+ """CADbuildr PCB — 3D models of common printed-circuit-board components plus a
2
+ reusable framework for assembling them into boards.
3
+
4
+ Two halves:
5
+
6
+ * **Components** — parametric 3D parts (resistors, capacitors, LEDs, headers,
7
+ USB / Ethernet connectors, ICs, crystals, ...), each of which carries its own
8
+ :class:`~cadbuildr.electronics.footprint.Footprint`.
9
+
10
+ * **Assembly** — :class:`~cadbuildr.electronics.pcb.PCB`, a template that owns a
11
+ :class:`~cadbuildr.electronics.board.PCBBoard` and places components with a
12
+ single dual-action call that keeps the board holes and the 3D bodies in sync.
13
+
14
+ Quick start::
15
+
16
+ from cadbuildr.foundation import show
17
+ from cadbuildr.electronics import PCB, PinHeader, Resistor, LED
18
+
19
+ pcb = PCB(50, 30, color="blue")
20
+ pcb.place(PinHeader(positions=6), ref="J1", x=-18, y=10)
21
+ pcb.place(Resistor("220"), ref="R1", x=0, y=0)
22
+ pcb.place(LED("red"), ref="D1", x=12, y=0)
23
+ show(pcb)
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ from .constants import COLORS, BOARD_COLOR_CHOICES, LED_COLOR_CHOICES
29
+ from .footprint import (
30
+ ElectronicComponent,
31
+ Footprint,
32
+ Pad,
33
+ footprint,
34
+ grid_pads,
35
+ two_pad,
36
+ )
37
+ from .board import PCBBoard, RoundedPCBBoard
38
+ from .pcb import PCB, Components, Placement, BomLine
39
+ from .components import (
40
+ Resistor,
41
+ ResistorSMD,
42
+ CeramicCapacitor,
43
+ ElectrolyticCapacitor,
44
+ LED,
45
+ Diode,
46
+ PinHeader,
47
+ ScrewTerminal,
48
+ USBTypeA,
49
+ USBMicroB,
50
+ RJ45,
51
+ BarrelJack,
52
+ DIP,
53
+ SOIC,
54
+ QFP,
55
+ Crystal,
56
+ TactileButton,
57
+ )
58
+
59
+ # Scale layer: data-driven catalog (parts → packages → family generators) and
60
+ # the parametric generators behind it. Lets the library grow to catalogue size
61
+ # by adding data rows, not classes. See docs/SCALING.md.
62
+ from .families import GeneratedComponent, PackageFamily, families
63
+ from .catalog import Catalog, Package, Part, PackageKey, parse_package_case
64
+
65
+ # Parametric @cadbuildr_project entry points (best-effort: needs a foundation
66
+ # new enough to expose the SDK parameter decorators).
67
+ try:
68
+ from .projects import demo_board, header_strip, blinky
69
+ except Exception: # pragma: no cover - older pinned foundations
70
+ demo_board = header_strip = blinky = None # type: ignore[assignment]
71
+
72
+ __all__ = [
73
+ "COLORS",
74
+ "BOARD_COLOR_CHOICES",
75
+ "LED_COLOR_CHOICES",
76
+ # framework
77
+ "ElectronicComponent",
78
+ "Footprint",
79
+ "Pad",
80
+ "footprint",
81
+ "grid_pads",
82
+ "two_pad",
83
+ "PCBBoard",
84
+ "RoundedPCBBoard",
85
+ "PCB",
86
+ "Components",
87
+ "Placement",
88
+ "BomLine",
89
+ # components
90
+ "Resistor",
91
+ "ResistorSMD",
92
+ "CeramicCapacitor",
93
+ "ElectrolyticCapacitor",
94
+ "LED",
95
+ "Diode",
96
+ "PinHeader",
97
+ "ScrewTerminal",
98
+ "USBTypeA",
99
+ "USBMicroB",
100
+ "RJ45",
101
+ "BarrelJack",
102
+ "DIP",
103
+ "SOIC",
104
+ "QFP",
105
+ "Crystal",
106
+ "TactileButton",
107
+ # scale layer
108
+ "GeneratedComponent",
109
+ "PackageFamily",
110
+ "families",
111
+ "Catalog",
112
+ "Package",
113
+ "Part",
114
+ "PackageKey",
115
+ "parse_package_case",
116
+ # projects
117
+ "demo_board",
118
+ "header_strip",
119
+ "blinky",
120
+ ]
@@ -0,0 +1,89 @@
1
+ """Tiny geometry helpers shared by the component bodies.
2
+
3
+ Everything is expressed in the component's *local* frame: the board top sits at
4
+ ``z = 0`` and the body grows in ``+Z``. Leads grow in ``-Z`` (down through the
5
+ board). All helpers add operations to a foundation ``Part`` and return it.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from cadbuildr.foundation import (
11
+ Circle,
12
+ Extrusion,
13
+ Part,
14
+ Point,
15
+ Rectangle,
16
+ Sketch,
17
+ )
18
+
19
+
20
+ def add_box(
21
+ part: Part,
22
+ width: float,
23
+ depth: float,
24
+ height: float,
25
+ cx: float = 0.0,
26
+ cy: float = 0.0,
27
+ z0: float = 0.0,
28
+ ) -> Part:
29
+ """Axis-aligned box centred at ``(cx, cy)`` spanning ``z0 .. z0+height``."""
30
+ sketch = Sketch(part.xy())
31
+ rect = Rectangle.from_center_and_sides(Point(sketch, cx, cy), width, depth)
32
+ part.add_operation(Extrusion(rect, z0, z0 + height))
33
+ return part
34
+
35
+
36
+ def add_cylinder_z(
37
+ part: Part,
38
+ radius: float,
39
+ height: float,
40
+ cx: float = 0.0,
41
+ cy: float = 0.0,
42
+ z0: float = 0.0,
43
+ ) -> Part:
44
+ """Vertical cylinder (axis along +Z) from ``z0`` to ``z0+height``."""
45
+ sketch = Sketch(part.xy())
46
+ circle = Circle(Point(sketch, cx, cy), radius)
47
+ part.add_operation(Extrusion(circle, z0, z0 + height))
48
+ return part
49
+
50
+
51
+ def add_cylinder_x(
52
+ part: Part,
53
+ radius: float,
54
+ length: float,
55
+ cy: float = 0.0,
56
+ cz: float = 0.0,
57
+ x0: float | None = None,
58
+ ) -> Part:
59
+ """Horizontal cylinder whose axis runs along +X.
60
+
61
+ Sketched on the YZ plane (normal = X) and extruded along X. ``cy`` / ``cz``
62
+ locate the axis; the cylinder is centred on X unless ``x0`` is given.
63
+ """
64
+ sketch = Sketch(part.yz())
65
+ circle = Circle(Point(sketch, cy, cz), radius)
66
+ if x0 is None:
67
+ part.add_operation(Extrusion(circle, -length / 2.0, length / 2.0))
68
+ else:
69
+ part.add_operation(Extrusion(circle, x0, x0 + length))
70
+ return part
71
+
72
+
73
+ def add_lead_z(part: Part, x: float, y: float, radius: float = 0.25, depth: float = 3.5) -> Part:
74
+ """A round through-hole lead at ``(x, y)`` dropping from the board top
75
+ (``z = 0``) down to ``z = -depth``."""
76
+ sketch = Sketch(part.xy())
77
+ circle = Circle(Point(sketch, x, y), radius)
78
+ part.add_operation(Extrusion(circle, -depth, 0.0))
79
+ return part
80
+
81
+
82
+ def add_pin_z(
83
+ part: Part, x: float, y: float, side: float, top: float, bottom: float
84
+ ) -> Part:
85
+ """A square pin (e.g. a header post) at ``(x, y)`` spanning ``bottom..top``."""
86
+ sketch = Sketch(part.xy())
87
+ rect = Rectangle.from_center_and_sides(Point(sketch, x, y), side, side)
88
+ part.add_operation(Extrusion(rect, bottom, top))
89
+ return part
@@ -0,0 +1,117 @@
1
+ """The bare PCB substrate as a foundation ``Part``.
2
+
3
+ The board is a flat FR-4 slab extruded from ``z = 0`` (bottom) to
4
+ ``z = thickness`` (top copper). Footprint holes are *cut* operations added on
5
+ top of the base extrusion, so the board geometry always reflects every
6
+ component that has been placed on it.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from cadbuildr.foundation import (
12
+ Circle,
13
+ Extrusion,
14
+ Line,
15
+ Part,
16
+ Point,
17
+ Polygon,
18
+ Rectangle,
19
+ Sketch,
20
+ )
21
+
22
+ from .constants import BOARD_COLOR_CHOICES, COLORS, DEFAULT_BOARD_THICKNESS
23
+ from .footprint import Footprint, Pad, paint_pads
24
+
25
+
26
+ class PCBBoard(Part):
27
+ """A rectangular printed-circuit board.
28
+
29
+ The origin sits at the board centre, in the board plane. Use
30
+ :meth:`apply_footprint` to drill a placed footprint, or :meth:`drill` for a
31
+ single mounting hole.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ width: float,
37
+ height: float,
38
+ thickness: float = DEFAULT_BOARD_THICKNESS,
39
+ color: str = "green",
40
+ corner_radius: float = 0.0,
41
+ show_pads: bool = True,
42
+ outline: list[tuple[float, float]] | None = None,
43
+ ):
44
+ super().__init__()
45
+ self.width = width
46
+ self.height = height
47
+ self.thickness = thickness
48
+ self.corner_radius = corner_radius
49
+ self.show_pads = show_pads
50
+ self._hex = BOARD_COLOR_CHOICES.get(color, color)
51
+ self._outline_vertices: list[tuple[float, float]] | None = outline
52
+
53
+ self._build_substrate()
54
+ self.paint(self._hex)
55
+
56
+ # -- geometry -----------------------------------------------------------
57
+
58
+ def _build_substrate(self) -> None:
59
+ sketch = Sketch(self.xy())
60
+ if self._outline_vertices:
61
+ pts = [Point(sketch, x, y) for x, y in self._outline_vertices]
62
+ lines = [Line(p1=pts[i], p2=pts[(i + 1) % len(pts)]) for i in range(len(pts))]
63
+ outline = Polygon(lines=lines)
64
+ else:
65
+ outline = Rectangle.from_center_and_sides(sketch.origin, self.width, self.height)
66
+ self.add_operation(Extrusion(outline, self.thickness))
67
+
68
+ @property
69
+ def top_z(self) -> float:
70
+ return self.thickness
71
+
72
+ # -- drilling / footprints ---------------------------------------------
73
+
74
+ def drill(self, x: float, y: float, diameter: float) -> "PCBBoard":
75
+ """Cut a single round hole clean through the board at ``(x, y)``."""
76
+ sketch = Sketch(self.xy())
77
+ hole = Circle(Point(sketch, x, y), diameter / 2.0)
78
+ # Extrude the cut slightly proud of both faces so it is unambiguously
79
+ # a through hole regardless of floating-point board thickness.
80
+ self.add_operation(
81
+ Extrusion(hole, -0.1, self.thickness + 0.1, cut=True)
82
+ )
83
+ return self
84
+
85
+ def apply_footprint(
86
+ self, footprint: Footprint, x: float, y: float, rotation_deg: float = 0.0
87
+ ) -> "PCBBoard":
88
+ """Paint the copper lands of ``footprint`` placed at ``(x, y)`` and drill
89
+ its through-hole pads. Surface-mount pads only paint; they never modify
90
+ the board outline.
91
+
92
+ Order matters: lands are painted **before** the holes are drilled, so the
93
+ through-cut punches cleanly through both the board *and* the copper land,
94
+ leaving a real annular pad with an open hole. (Drilling first and then
95
+ painting a solid land would cap the hole back up.)"""
96
+ placed: list[Pad] = footprint.transformed_pads(x, y, rotation_deg)
97
+ if self.show_pads:
98
+ paint_pads(self, placed, self.top_z)
99
+ for pad in placed:
100
+ if pad.is_through_hole:
101
+ self.drill(pad.x, pad.y, pad.drill)
102
+ return self
103
+
104
+
105
+ class RoundedPCBBoard(PCBBoard):
106
+ """Convenience board with a default 3 mm corner radius for nicer outlines.
107
+
108
+ (Corner rounding is approximated by the base rectangle for now; the radius
109
+ is recorded for downstream silkscreen / outline tooling.)
110
+ """
111
+
112
+ def __init__(self, width: float, height: float, **kwargs):
113
+ kwargs.setdefault("corner_radius", 3.0)
114
+ super().__init__(width, height, **kwargs)
115
+
116
+
117
+ __all__ = ["PCBBoard", "RoundedPCBBoard", "COLORS", "BOARD_COLOR_CHOICES"]
@@ -0,0 +1,16 @@
1
+ """Reference board assemblies that validate the library by reproducing the look
2
+ of well-known open-hardware boards."""
3
+
4
+ from .arduino_uno import ArduinoUno
5
+ from .arduino_nano import ArduinoNano
6
+ from .raspberry_pi import RaspberryPi
7
+ from .raspberry_pi_pico import RaspberryPiPico
8
+ from .esp32_devkit import ESP32DevKit
9
+
10
+ __all__ = [
11
+ "ArduinoUno",
12
+ "ArduinoNano",
13
+ "RaspberryPi",
14
+ "RaspberryPiPico",
15
+ "ESP32DevKit",
16
+ ]
@@ -0,0 +1,59 @@
1
+ """A stylised Arduino Nano, assembled from the component library.
2
+
3
+ The Nano is the compact (18 x 45 mm) ATmega328 board with two 1x15 0.1" header
4
+ rows down the long edges, a mini-USB at the top, the MCU in a TQFP in the centre
5
+ and the usual reset button + indicator LEDs.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from ..pcb import PCB
11
+ from ..components import (
12
+ CeramicCapacitor,
13
+ Crystal,
14
+ LED,
15
+ PinHeader,
16
+ QFP,
17
+ TactileButton,
18
+ USBMicroB,
19
+ )
20
+
21
+ # Real Nano outline.
22
+ WIDTH = 18.0
23
+ HEIGHT = 45.0
24
+
25
+ _HW = WIDTH / 2.0 # 9.0
26
+ _HH = HEIGHT / 2.0 # 22.5
27
+
28
+
29
+ class ArduinoNano(PCB):
30
+ """A Nano-class board populated from the PCB component library."""
31
+
32
+ def __init__(self):
33
+ super().__init__(WIDTH, HEIGHT, color="blue", name="ArduinoNano")
34
+
35
+ # --- mini-USB at the top edge (pads kept on-board) ---
36
+ self.place(USBMicroB(), ref="J-USB", x=0.0, y=19.5, rotation=0)
37
+
38
+ # --- the ATmega328 (TQFP-32) in the centre ---
39
+ self.place(QFP(32, body=7.0), ref="U1", x=0.0, y=0.0)
40
+
41
+ # --- clock crystal beside the MCU ---
42
+ self.place(Crystal("16MHz"), ref="Y1", x=0.0, y=-9.0, rotation=90)
43
+
44
+ # --- the two 1x15 header rows down the long edges ---
45
+ self.place(PinHeader(positions=15), ref="J1", x=-7.5, y=-0.5, rotation=90)
46
+ self.place(PinHeader(positions=15), ref="J2", x=7.5, y=-0.5, rotation=90)
47
+
48
+ # --- reset button + power/TX/RX indicator LEDs (LEDs dropped clear of
49
+ # the reset button body) ---
50
+ self.place(TactileButton(), ref="SW-RST", x=0.0, y=14.0)
51
+ self.place(LED("green", diameter=3.0), ref="D-PWR", x=-3.5, y=8.0)
52
+ self.place(LED("yellow", diameter=3.0), ref="D-L", x=3.5, y=8.0)
53
+
54
+ # --- a couple of decoupling caps (dropped clear of the crystal) ---
55
+ self.place(CeramicCapacitor("100n"), ref="C1", x=-3.5, y=-16.5)
56
+ self.place(CeramicCapacitor("100n"), ref="C2", x=3.5, y=-16.5)
57
+
58
+
59
+ __all__ = ["ArduinoNano"]
@@ -0,0 +1,98 @@
1
+ """A stylised Arduino-Uno-style board, built entirely from the component
2
+ library to validate the framework end-to-end.
3
+
4
+ Coordinates are board-centred (origin at the centre of the 68.58 x 53.34 mm
5
+ outline) and approximate the real Uno layout closely enough to be recognisable
6
+ in the viewer: the USB and barrel jack hang off the left edge, the ATmega DIP
7
+ sits in the middle next to its crystal, and the four 0.1" header banks line the
8
+ top and bottom edges.
9
+
10
+ The board outline is the **genuine** Arduino Uno R3 edge-cut shape — the iconic
11
+ profile with the chamfered top-right corner and the right-edge notch where the
12
+ board steps in from 68.58 mm to 66.04 mm wide. The vertices were taken from the
13
+ official Arduino Uno R3 KiCad footprint (Edge.Cuts / silkscreen perimeter) and
14
+ re-centred / flipped to our Y-up, board-centred frame.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from ..pcb import PCB
20
+ from ..components import (
21
+ BarrelJack,
22
+ CeramicCapacitor,
23
+ Crystal,
24
+ DIP,
25
+ ElectrolyticCapacitor,
26
+ LED,
27
+ PinHeader,
28
+ TactileButton,
29
+ USBTypeA,
30
+ )
31
+
32
+ # Real Uno R3 outline — 68.58 mm x 53.34 mm.
33
+ WIDTH = 68.58
34
+ HEIGHT = 53.34
35
+
36
+ # Genuine Arduino Uno R3 perimeter, centred at the origin with +Y pointing up.
37
+ # Source: Arduino_Uno_R3 KiCad footprint board-edge (origin bottom-left, Y-down),
38
+ # transformed by x' = x - 34.29, y' = -y - 26.67. The notch + chamfer on the
39
+ # right edge (USB is on the *left*) is what makes the Uno instantly recognisable.
40
+ _OUTLINE = [
41
+ (-34.29, -26.670), # bottom-left
42
+ (31.75, -26.670), # bottom edge
43
+ (31.75, -25.400), # step up to the chamfer
44
+ (34.29, -22.860), # chamfer out to full width
45
+ (34.29, 11.430), # right edge (full-width lower section)
46
+ (31.75, 13.970), # chamfer in — the right-edge notch
47
+ (31.75, 25.146), # inset upper section
48
+ (30.226, 26.670), # chamfer at the top-right corner
49
+ (-34.29, 26.670), # top edge → top-left
50
+ ]
51
+
52
+
53
+ class ArduinoUno(PCB):
54
+ """An Uno-class board populated from the PCB component library."""
55
+
56
+ def __init__(self):
57
+ super().__init__(
58
+ WIDTH, HEIGHT, color="blue", name="ArduinoUno", outline=_OUTLINE
59
+ )
60
+
61
+ # --- left-edge connectors (mouths overhang the board edge, as on the
62
+ # real Uno: USB-B above the barrel power jack) ---
63
+ self.place(USBTypeA(), ref="J-USB", x=-28.0, y=14.0, rotation=-90)
64
+ self.place(BarrelJack(), ref="J-PWR", x=-28.0, y=-14.0, rotation=-90)
65
+
66
+ # --- the microcontroller + clock (ATmega long axis vertical, crystal
67
+ # seated right beside it, as on the real board) ---
68
+ self.place(DIP(28), ref="U1", x=4.0, y=-2.0, rotation=90)
69
+ self.place(Crystal("16MHz"), ref="Y1", x=-7.0, y=7.0, rotation=0)
70
+
71
+ # --- the four header banks (digital top, power+analog bottom), spans
72
+ # matched to the real R3 0.1" rows ---
73
+ self.place(PinHeader(positions=10), ref="J-D8-13", x=-6.0, y=24.13)
74
+ self.place(PinHeader(positions=8), ref="J-D0-7", x=18.0, y=24.13)
75
+ self.place(PinHeader(positions=8), ref="J-PWRHDR", x=2.0, y=-24.13)
76
+ self.place(PinHeader(positions=6), ref="J-ANALOG", x=21.0, y=-24.13)
77
+
78
+ # --- user IO + indicators (reset clear of the USB shell; ON/L LEDs
79
+ # beside the ATmega) ---
80
+ self.place(TactileButton(), ref="SW-RST", x=-16.0, y=17.0)
81
+ self.place(LED("green"), ref="D-ON", x=-4.0, y=14.0)
82
+ self.place(LED("yellow"), ref="D-L", x=-10.0, y=14.0)
83
+
84
+ # --- power filtering (electrolytics stacked apart, clear of the barrel) ---
85
+ self.place(ElectrolyticCapacitor("47u"), ref="C1", x=-16.0, y=-9.0)
86
+ self.place(ElectrolyticCapacitor("47u"), ref="C2", x=-16.0, y=1.0)
87
+ self.place(CeramicCapacitor("100n"), ref="C3", x=-2.0, y=-12.0)
88
+
89
+ # --- mounting holes (genuine Uno R3 positions, board-centred) ---
90
+ # Official Uno hole centres (origin bottom-left): (15.24, 50.8),
91
+ # (66.04, 35.56), (66.04, 7.62), (13.97, 2.54) → centred below.
92
+ self.mounting_hole(-19.05, 24.13)
93
+ self.mounting_hole(31.75, 8.89)
94
+ self.mounting_hole(31.75, -19.05)
95
+ self.mounting_hole(-20.32, -24.13)
96
+
97
+
98
+ __all__ = ["ArduinoUno"]
@@ -0,0 +1,62 @@
1
+ """A stylised ESP32 DevKitC, assembled from the component library.
2
+
3
+ The DevKitC is the ~28 x 52 mm dev board carrying the ESP-WROOM-32 module (the
4
+ big shielded can in the top half), a micro-USB + USB-serial bridge at the bottom,
5
+ EN and BOOT buttons flanking the USB, and two 1x19 0.1" header rows down the long
6
+ edges.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from ..pcb import PCB
12
+ from ..components import (
13
+ CeramicCapacitor,
14
+ LED,
15
+ PinHeader,
16
+ QFP,
17
+ SOIC,
18
+ TactileButton,
19
+ USBMicroB,
20
+ )
21
+
22
+ # DevKitC outline.
23
+ WIDTH = 28.0
24
+ HEIGHT = 52.0
25
+
26
+ _HW = WIDTH / 2.0 # 14.0
27
+ _HH = HEIGHT / 2.0 # 26.0
28
+
29
+
30
+ class ESP32DevKit(PCB):
31
+ """An ESP32-DevKitC-class board populated from the PCB component library."""
32
+
33
+ def __init__(self):
34
+ super().__init__(WIDTH, HEIGHT, color="black", name="ESP32DevKit")
35
+
36
+ # --- ESP-WROOM-32 module (big shielded can) in the top half ---
37
+ # Approximated with a large QFP body; the real module is a metal can.
38
+ self.place(QFP(48, body=18.0), ref="U1", x=0.0, y=11.0)
39
+
40
+ # --- micro-USB at the bottom edge ---
41
+ self.place(USBMicroB(), ref="J-USB", x=0.0, y=-23.0, rotation=180)
42
+
43
+ # --- EN / BOOT buttons flanking the USB (inboard of the 1x19 headers
44
+ # at x=±12.5 so the bodies stay clear) ---
45
+ self.place(TactileButton(), ref="SW-EN", x=-7.5, y=-19.0)
46
+ self.place(TactileButton(), ref="SW-BOOT", x=7.5, y=-19.0)
47
+
48
+ # --- USB-to-serial bridge (SOIC) + 3V3 LDO ---
49
+ self.place(SOIC(8), ref="U2", x=0.0, y=-14.0)
50
+ self.place(SOIC(8), ref="U3", x=0.0, y=-7.0)
51
+
52
+ # --- the two 1x19 header rows down the long edges ---
53
+ self.place(PinHeader(positions=19), ref="J1", x=-12.5, y=-0.5, rotation=90)
54
+ self.place(PinHeader(positions=19), ref="J2", x=12.5, y=-0.5, rotation=90)
55
+
56
+ # --- power LED + decoupling caps ---
57
+ self.place(LED("red", diameter=3.0), ref="D1", x=-9.0, y=-13.0)
58
+ self.place(CeramicCapacitor("100n"), ref="C1", x=-6.0, y=-2.0)
59
+ self.place(CeramicCapacitor("100n"), ref="C2", x=6.0, y=-2.0)
60
+
61
+
62
+ __all__ = ["ESP32DevKit"]
@@ -0,0 +1,82 @@
1
+ """A stylised Raspberry-Pi-style single-board computer, assembled from the
2
+ component library.
3
+
4
+ Like :mod:`arduino_uno`, this is a recognisable approximation rather than a
5
+ pin-accurate clone: the 40-pin GPIO header runs along the top edge, the SoC is
6
+ a big QFP in the middle, and the bulky I/O (USB stack + Ethernet) sits on the
7
+ right edge where it does on a real Pi.
8
+
9
+ The outline is the real Pi Model B footprint — 85 x 56 mm with the
10
+ characteristic 3 mm rounded corners (approximated here as 3 mm chamfers) and the
11
+ 58 x 49 mm mounting-hole rectangle.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from ..pcb import PCB
17
+ from ..components import (
18
+ CeramicCapacitor,
19
+ LED,
20
+ PinHeader,
21
+ QFP,
22
+ RJ45,
23
+ USBTypeA,
24
+ )
25
+
26
+ # Real Pi Model B outline.
27
+ WIDTH = 85.0
28
+ HEIGHT = 56.0
29
+
30
+ _HW = WIDTH / 2.0 # 42.5
31
+ _HH = HEIGHT / 2.0 # 28.0
32
+ _CHAMFER = 3.0 # real Pi has 3 mm corner radius; chamfer is a close stand-in
33
+
34
+ # 8-vertex chamfered rectangle (rounded-corner stand-in), centred, +Y up.
35
+ _OUTLINE = [
36
+ (-_HW + _CHAMFER, -_HH),
37
+ (_HW - _CHAMFER, -_HH),
38
+ (_HW, -_HH + _CHAMFER),
39
+ (_HW, _HH - _CHAMFER),
40
+ (_HW - _CHAMFER, _HH),
41
+ (-_HW + _CHAMFER, _HH),
42
+ (-_HW, _HH - _CHAMFER),
43
+ (-_HW, -_HH + _CHAMFER),
44
+ ]
45
+
46
+
47
+ class RaspberryPi(PCB):
48
+ """A Pi-class SBC populated from the PCB component library."""
49
+
50
+ def __init__(self):
51
+ super().__init__(
52
+ WIDTH, HEIGHT, color="green", name="RaspberryPi", outline=_OUTLINE
53
+ )
54
+
55
+ # --- 40-pin GPIO header along the top edge ---
56
+ self.place(PinHeader(positions=20, rows=2), ref="J8", x=-3.5, y=23.5)
57
+
58
+ # --- the SoC (big QFP/BGA stand-in) near board centre ---
59
+ self.place(QFP(64), ref="U1", x=-7.0, y=0.0)
60
+
61
+ # --- right-edge I/O: stacked USB + Ethernet ---
62
+ self.place(USBTypeA(), ref="J-USB1", x=33.0, y=14.0, rotation=90)
63
+ self.place(USBTypeA(), ref="J-USB2", x=33.0, y=-2.0, rotation=90)
64
+ self.place(RJ45(), ref="J-ETH", x=32.0, y=-18.0, rotation=90)
65
+
66
+ # --- power + activity LEDs (corner near the GPIO/microSD edge) ---
67
+ # 3 mm packages spaced 4 mm apart (flange dia 3.6 mm) so they clear.
68
+ self.place(LED("red", diameter=3.0), ref="D-PWR", x=-39.0, y=20.0)
69
+ self.place(LED("green", diameter=3.0), ref="D-ACT", x=-35.0, y=20.0)
70
+
71
+ # --- a scattering of decoupling caps around the SoC ---
72
+ for i, (dx, dy) in enumerate([(-20, 8), (-4, 8), (-20, -8), (-4, -8)]):
73
+ self.place(CeramicCapacitor("100n"), ref=f"C{i + 1}", x=dx, y=dy)
74
+
75
+ # --- mounting holes (genuine 58 x 49 mm Pi rectangle) ---
76
+ self.mounting_hole(-39.0, 24.5)
77
+ self.mounting_hole(19.0, 24.5)
78
+ self.mounting_hole(-39.0, -24.5)
79
+ self.mounting_hole(19.0, -24.5)
80
+
81
+
82
+ __all__ = ["RaspberryPi"]