Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rpi hat outline full width #120

Merged
merged 1 commit into from
Jul 17, 2024
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 src/osr_mechanical/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def export_pcb_outline(args: Namespace) -> None:
module = importlib.import_module(module_name)
container = getattr(module, class_name)

pcb_face = container(mounting_holes=False).board_face()
pcb_face = container(mounting_holes=False, full_size=True).board_face()

with tempfile.TemporaryDirectory() as tmp_dir:
tmp_file = Path(tmp_dir) / "tmp.dxf"
Expand Down
89 changes: 60 additions & 29 deletions src/osr_mechanical/pcb/rpi_hat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,99 @@
class RpiHatBoard(CqWorkplaneContainer):
"""Raspberry Pi HAT+ board outline.

See https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf
"""
Reference
---------

def __init__(self, mounting_holes: bool = True) -> None:
* `Raspberry Pi HAT+ Specification <https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf>`__
* `Raspberry Pi 3b plus mechanical drawing <https://datasheets.raspberrypi.com/rpi3/raspberry-pi-3-b-plus-mechanical-drawing.pdf>`__
""" # noqa: E501

def __init__(self, mounting_holes: bool = True, full_size: bool = True) -> None:
"""Initialise RPi HAT+ board."""
self.mounting_holes = mounting_holes

self.width = 65
self.full_size = full_size

self.full_width = 85
self.standard_width = 65

self.height = 56.5
self.thickness = 1.5
self.corner_radius = 3.5

self.csi_slot_width = 17
self.csi_slot_height = 2
self.csi_slot_location = (45, 11.5)

self.dsi_slot_height = 17
self.dsi_slot_width = 5

self.mounting_hole_radius = 2.7 / 2
self.mounting_hole_between_centers_x = 58
self.mounting_hole_between_centers_y = 49

dsi_slot_loc_x = -self.width / 2 + self.dsi_slot_width / 2
dsi_slot_offset_y = -0.5
self.dsi_slot_loc = (dsi_slot_loc_x, dsi_slot_offset_y)
self.dsi_slot_location = (self.dsi_slot_width / 2, 28)

self.mounting_hole_radius = 2.75 / 2
mounting_hole_from_edge = 3.5
mounting_hole_between_centers_x = 58
mounting_hole_between_centers_y = 49

self.mounting_hole_locations = [
(mounting_hole_from_edge, mounting_hole_from_edge),
(
mounting_hole_from_edge,
mounting_hole_between_centers_y + mounting_hole_from_edge,
),
(
mounting_hole_between_centers_x + mounting_hole_from_edge,
mounting_hole_from_edge + mounting_hole_between_centers_y,
),
(
mounting_hole_from_edge + mounting_hole_between_centers_x,
mounting_hole_from_edge,
),
]

self._cq_object = self._make()

def outline(self) -> cq.Sketch:
"""Create RPi HAT+ board outline."""
def outline(self, width: float) -> cq.Sketch:
"""HAT pcb outline."""
sketch = (
cq.Sketch()
.rect(self.width, self.height)
.push([(width / 2, self.height / 2)])
.rect(width, self.height)
.reset()
.vertices()
.tag("major_outline")
.push([self.dsi_slot_loc])
.tag("major_vertices")
.push([self.dsi_slot_location])
.rect(self.dsi_slot_width, self.dsi_slot_height, mode="s")
.reset()
.vertices("(<X and <<Y[2]) or (<X and >>Y[2]) or (<<X[-2])")
.tag("dsi_slot_vertices")
.tag("dsi_notch_vertices")
)

if self.mounting_holes:
sketch.reset().rarray(
self.mounting_hole_between_centers_x,
self.mounting_hole_between_centers_y,
2,
2,
).circle(self.mounting_hole_radius, mode="s")
sketch.vertices(tag="major_vertices").fillet(self.corner_radius)
sketch.vertices(tag="dsi_notch_vertices").fillet(1)

sketch.vertices(tag="major_outline").fillet(self.corner_radius)
sketch.vertices(tag="dsi_slot_vertices").fillet(1)
if self.mounting_holes:
(
sketch.reset()
.push(self.mounting_hole_locations)
.circle(self.mounting_hole_radius, mode="s")
)

return sketch

def _make(self) -> cq.Workplane:
"""Create RPi HAT+ board."""
if self.full_size:
width = self.full_width
else:
width = self.standard_width

outline = self.outline(width)

result = (
cq.Workplane("XY")
.placeSketch(self.outline())
.placeSketch(outline)
.extrude(self.thickness)
.pushPoints([(-(self.width / 2) + 50, -(self.height / 2) + 11.5)])
.pushPoints([self.csi_slot_location])
.slot2D(self.csi_slot_width, self.csi_slot_height, angle=90)
.cutThruAll()
)
Expand Down
Loading