Skip to content

Commit

Permalink
feat(case): make the cover rounded
Browse files Browse the repository at this point in the history
  • Loading branch information
azzamsa committed Dec 3, 2024
1 parent d97711e commit df2e0aa
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
10 changes: 4 additions & 6 deletions case/cheapino-top-left.scad
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ rotate([0,180,0])
// -10.6 is the initial size of left/right
// 4.1 is the intial value of the PCB
translate([29.2 + (-2), -10.6 - 2, 4.1])
// +2 is for top cover
linear_extrude(rj45_height + 2)
// width = front/back, height = left/right
// Add thickness of 4. 2 left 2 right.
square([30 - 7, 16.6 + 4]);
// +2 is for top cover
roundedcube([30 - 7, 16.6 + 4, rj45_height + 2], false, 0.5, "all");
// repeat the difference() for initial rj45
translate([29.2, -10.6, 4.1])
linear_extrude(rj45_height)
Expand All @@ -68,11 +67,10 @@ rotate([0,180,0])
difference() {
// x = left/right, y = front/back
translate([29.5 - 2, 10.2 - 2, 4.1])
// +2 is for top cover
linear_extrude(mcu_height + 2)
// width = left/right, height = front/back
// Add thickness of 4. 2 left 2 right.
square([19.5 + 4, 25 + 2]);
// +2 is for top cover
roundedcube([19.5 + 4, 25 + 2, mcu_height + 2], false, 0.5, "all");

// repeat the difference() for initial mcu cutout
translate([29.2, 10.2, 4.1])
Expand Down
5 changes: 2 additions & 3 deletions case/cheapino-top-right.scad
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ mirror() {
// -9.7 is the initial size of left/right
// 4.1 is the intial value of the PCB
translate([29.2 + (-2), -9.33 - 2, 4.1])
// +2 is for top cover
linear_extrude(rj45_height + 2)
// width = front/back, height = left/right
// Add thickness of 4. 2 left 2 right.
square([30 - 7, 16.6 + 4]);
// +2 is for top cover
roundedcube([30 - 7, 16.6 + 4, rj45_height + 2], false, 0.5, "all");
// repeat the difference() for initial rj45
translate([29.2, -9.33, 4.1])
linear_extrude(rj45_height)
Expand Down
53 changes: 53 additions & 0 deletions case/modules.scad
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,56 @@ module mcu_cutout() {
square([10, 20]);
}
}

// More information: https://danielupshaw.com/openscad-rounded-corners/
// License: Unlicense
module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") {
// If single value, convert to [x, y, z] vector
size = (size[0] == undef) ? [size, size, size] : size;

translate_min = radius;
translate_xmax = size[0] - radius;
translate_ymax = size[1] - radius;
translate_zmax = size[2] - radius;

diameter = radius * 2;

obj_translate = (center == false) ?
[0, 0, 0] : [
-(size[0] / 2),
-(size[1] / 2),
-(size[2] / 2)
];

translate(v = obj_translate) {
hull() {
for (translate_x = [translate_min, translate_xmax]) {
x_at = (translate_x == translate_min) ? "min" : "max";
for (translate_y = [translate_min, translate_ymax]) {
y_at = (translate_y == translate_min) ? "min" : "max";
for (translate_z = [translate_min, translate_zmax]) {
z_at = (translate_z == translate_min) ? "min" : "max";

translate(v = [translate_x, translate_y, translate_z])
if (
(apply_to == "all") ||
(apply_to == "xmin" && x_at == "min") || (apply_to == "xmax" && x_at == "max") ||
(apply_to == "ymin" && y_at == "min") || (apply_to == "ymax" && y_at == "max") ||
(apply_to == "zmin" && z_at == "min") || (apply_to == "zmax" && z_at == "max")
) {
sphere(r = radius);
} else {
rotate =
(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? [0, 90, 0] : (
(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? [90, 90, 0] :
[0, 0, 0]
);
rotate(a = rotate)
cylinder(h = diameter, r = radius, center = true);
}
}
}
}
}
}
}

0 comments on commit df2e0aa

Please sign in to comment.