-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: command to generate rpi hat outline
- Loading branch information
1 parent
b2acaaa
commit 702374d
Showing
6 changed files
with
131 additions
and
0 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
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,6 @@ | ||
"""Utilities.""" | ||
|
||
|
||
def snake_to_camel_case(snake_str: str) -> str: | ||
"""Convert a snake case string to camel case.""" | ||
return "".join(x.capitalize() for x in snake_str.lower().split("_")) |
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,4 @@ | ||
"""PCB mechanical designs. | ||
Mechanical designs for printed circuit boards such as board outlines. | ||
""" |
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,71 @@ | ||
"""Raspberry Pi HAT mechanical design.""" | ||
|
||
import cadquery as cq | ||
|
||
from osr_common.cq_containers import CqWorkplaneContainer | ||
|
||
|
||
class RpiHatBoard(CqWorkplaneContainer): | ||
"""Raspberry Pi HAT+ board outline. | ||
See https://datasheets.raspberrypi.com/hat/hat-plus-specification.pdf | ||
""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialise RPi HAT+ board.""" | ||
self.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.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._cq_object = self._make() | ||
|
||
def outline(self) -> cq.Sketch: | ||
"""Create RPi HAT+ board outline.""" | ||
sketch = ( | ||
cq.Sketch() | ||
.rect(self.width, self.height) | ||
.vertices() | ||
.tag("major_outline") | ||
.reset() | ||
.push([(-(self.width / 2) + 50, -(self.height / 2) + 11.5)]) | ||
.slot(self.csi_slot_width, self.csi_slot_height, angle=90, mode="s") | ||
.push([self.dsi_slot_loc]) | ||
.rect(self.dsi_slot_width, self.dsi_slot_height, mode="s") | ||
.reset() | ||
.vertices("(<X and <<Y[1]) or (<X and >>Y[2]) or (<<X[-2])") | ||
.tag("dsi_slot_vertices") | ||
.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_outline").fillet(self.corner_radius) | ||
sketch.vertices(tag="dsi_slot_vertices").fillet(1) | ||
|
||
return sketch | ||
|
||
def _make(self) -> cq.Workplane: | ||
"""Create RPi HAT+ board.""" | ||
result = cq.Workplane("XY").placeSketch(self.outline()).extrude(self.thickness) | ||
|
||
return result |
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 @@ | ||
"""Test console app utilities.""" |
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,13 @@ | ||
"""Test console utilities.""" | ||
|
||
from osr_mechanical.console.utilities import snake_to_camel_case | ||
|
||
|
||
class TestSnakeToCamelCase: | ||
"""Test snake to camel case utility.""" | ||
|
||
def test_lower_snake_case(self) -> None: | ||
"""Test valid snake case.""" | ||
result = snake_to_camel_case("valid_snake_case") | ||
|
||
assert "ValidSnakeCase" == result |