diff --git a/src/osr_mechanical/console/application.py b/src/osr_mechanical/console/application.py index 400cef5..4200ad2 100644 --- a/src/osr_mechanical/console/application.py +++ b/src/osr_mechanical/console/application.py @@ -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" diff --git a/src/osr_mechanical/pcb/rpi_hat.py b/src/osr_mechanical/pcb/rpi_hat.py index 0fd7d01..05f9443 100644 --- a/src/osr_mechanical/pcb/rpi_hat.py +++ b/src/osr_mechanical/pcb/rpi_hat.py @@ -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 `__ + * `Raspberry Pi 3b plus mechanical drawing `__ + """ # 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("(>Y[2]) or (< 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() )