xantronix-z32/case/case.scad

238 lines
7.5 KiB
OpenSCAD
Raw Normal View History

2023-11-11 14:21:39 -05:00
$fn = 72;
2023-11-11 04:28:53 -05:00
pcb_width = 257.175;
2023-11-12 21:13:58 -05:00
pcb_length = 95.250;
2023-11-11 19:47:32 -05:00
2023-11-12 21:13:58 -05:00
module keyboard_base_plate(pcb_width, pcb_length) {
2023-11-11 14:21:39 -05:00
pcb_clearance_edge = 1.0;
pcb_clearance_bottom = 2.0;
2023-11-11 15:59:01 -05:00
2023-11-11 19:47:32 -05:00
pcb_screw_hole_diameter = 1.5;
thickness = 1.75;
2023-11-12 23:09:49 -05:00
corner_radius = thickness / 4;
case_color = [0.5, 0.5, 0.5, 1.0];
2023-11-12 23:09:49 -05:00
wall_width = pcb_width + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
wall_length = pcb_length + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
2023-11-12 21:33:04 -05:00
wall_height = 14.0;
2023-11-12 21:57:41 -05:00
bottom_width = 2 * (pcb_clearance_edge) + pcb_width;
bottom_length = 2 * (pcb_clearance_edge) + pcb_length;
bottom_height = thickness;
2023-11-12 01:06:25 -05:00
2023-11-11 20:55:34 -05:00
screw_holes = [
[ 4.8150, 85.7250],
2023-11-12 20:28:31 -05:00
[ 66.7322, 85.7250],
[161.8150, 85.7250],
2023-11-12 20:28:31 -05:00
[238.2500, 85.7250],
[ 61.7500, 47.6250],
[138.2500, 47.6250],
[214.2500, 47.6250],
[ 20.0000, 9.5250],
[123.8150, 9.5250],
2023-11-12 20:28:31 -05:00
[238.2500, 9.5250]
2023-11-11 20:55:34 -05:00
];
2023-11-11 15:59:01 -05:00
module round_corner(translation, rotation) {
2023-11-12 01:06:25 -05:00
color(case_color)
2023-11-11 14:21:39 -05:00
translate(translation)
rotate(rotation)
rotate_extrude(angle=90) {
intersection() {
circle(r=corner_radius);
square(corner_radius*2);
}
}
}
2023-11-11 18:53:21 -05:00
module round_edge(translation, rotation, length) {
2023-11-12 01:06:25 -05:00
color(case_color)
2023-11-11 14:21:39 -05:00
translate(translation)
rotate(rotation)
linear_extrude(length)
intersection() {
2023-11-11 04:28:53 -05:00
circle(r=corner_radius);
square(corner_radius*2);
}
}
2023-11-11 18:12:21 -05:00
module side(translation, dimensions) {
2023-11-12 01:06:25 -05:00
color(case_color)
2023-11-11 18:12:21 -05:00
translate(translation)
linear_extrude(dimensions[2])
square([dimensions[0], dimensions[1]], false);
}
2023-11-11 18:53:21 -05:00
module wall_corner(translation, rotation, radius, length) {
2023-11-12 01:06:25 -05:00
color(case_color)
2023-11-11 18:53:21 -05:00
translate(translation)
rotate(rotation)
linear_extrude(length)
intersection() {
circle(r=radius);
square([radius, radius], false);
}
}
2023-11-11 19:47:32 -05:00
module screw_post(translation, h, d1, d2) {
2023-11-12 01:06:25 -05:00
color(case_color)
2023-11-11 19:47:32 -05:00
translate(translation)
difference() {
cylinder(h=h, r=d1/2.0);
cylinder(h=h, r=d2/2.0);
}
}
2023-11-12 21:19:19 -05:00
module ridges(width, height) {
2023-11-12 20:46:01 -05:00
horizontal = [
2023-11-12 21:13:58 -05:00
(bottom_length / 3),
(bottom_length / 3) * 2
2023-11-12 20:46:01 -05:00
];
vertical = [
2023-11-12 21:19:19 -05:00
(bottom_width / 3),
(bottom_width / 3) * 2
2023-11-12 20:46:01 -05:00
];
for (y = horizontal) {
side([0 - pcb_clearance_edge, y, 0],
2023-11-12 22:42:07 -05:00
[bottom_width, width, height]);
2023-11-12 20:46:01 -05:00
}
for (x = vertical) {
side([x, 0 - pcb_clearance_edge, 0],
2023-11-12 22:42:07 -05:00
[width, bottom_length, height]);
2023-11-12 20:46:01 -05:00
}
}
2023-11-12 23:09:49 -05:00
/* Upper wall */
side([-pcb_clearance_edge - thickness + corner_radius,
pcb_clearance_edge + pcb_length,
0],
[wall_width, thickness, wall_height]);
/* Right wall */
side([ pcb_clearance_edge + pcb_width,
-pcb_clearance_edge - thickness + corner_radius,
0],
[thickness, wall_length, wall_height]);
/* Lower wall */
side([-pcb_clearance_edge - thickness + corner_radius,
-pcb_clearance_edge - thickness,
0],
[wall_width, thickness, wall_height]);
/* Left wall */
side([-pcb_clearance_edge - thickness,
-pcb_clearance_edge - thickness + corner_radius,
0],
[thickness, wall_length, wall_height]);
2023-11-11 15:37:03 -05:00
/* Upper right corner */
2023-11-12 23:09:49 -05:00
/*round_corner([pcb_clearance_edge + thickness + pcb_width - corner_radius,
2023-11-12 22:42:07 -05:00
pcb_clearance_edge + thickness + pcb_length - corner_radius,
2023-11-12 03:11:54 -05:00
-thickness/2],
2023-11-12 23:09:49 -05:00
[90, 90, 90]);*/
2023-11-11 14:21:39 -05:00
2023-11-11 15:37:03 -05:00
/* Lower right corner */
2023-11-12 23:09:49 -05:00
/*round_corner([ pcb_clearance_edge + thickness + pcb_width - corner_radius,
2023-11-12 22:42:07 -05:00
-pcb_clearance_edge - thickness + corner_radius,
-thickness/2],
2023-11-12 23:09:49 -05:00
[180, 90, 90]);*/
2023-11-11 20:53:22 -05:00
/* Lower left corner */
2023-11-12 23:09:49 -05:00
/*round_corner([-pcb_clearance_edge - thickness + corner_radius,
2023-11-12 22:42:07 -05:00
-pcb_clearance_edge - thickness + corner_radius,
-thickness/2],
2023-11-12 23:09:49 -05:00
[-90, 90, 90]);*/
2023-11-11 20:53:22 -05:00
/* Upper left corner */
2023-11-12 23:09:49 -05:00
/*round_corner([-pcb_clearance_edge - thickness + corner_radius,
2023-11-12 22:42:07 -05:00
pcb_clearance_edge + thickness + pcb_length - corner_radius,
-thickness/2],
2023-11-12 23:09:49 -05:00
[0, 90, 90]);*/
2023-11-11 14:21:39 -05:00
2023-11-11 18:12:21 -05:00
/* Upper edge */
2023-11-12 23:09:49 -05:00
/*round_edge([0 - thickness - pcb_clearance_edge + corner_radius,
2023-11-12 22:42:07 -05:00
thickness + pcb_clearance_edge + pcb_length - corner_radius,
-thickness/2],
[0, 90, 0],
2023-11-12 23:09:49 -05:00
bottom_width + 2 * corner_radius);*/
2023-11-11 15:37:03 -05:00
2023-11-11 14:21:39 -05:00
/* Right edge */
2023-11-12 23:09:49 -05:00
/*round_edge([ thickness + pcb_clearance_edge + pcb_width - corner_radius,
2023-11-12 22:42:07 -05:00
0 - thickness - pcb_clearance_edge + corner_radius,
-thickness/2],
[270, 0, 0],
2023-11-12 23:09:49 -05:00
bottom_length + 2 * corner_radius);*/
2023-11-11 15:37:03 -05:00
2023-11-11 18:12:21 -05:00
/* Lower edge */
2023-11-12 23:09:49 -05:00
/*round_edge([-pcb_clearance_edge - thickness + corner_radius,
2023-11-12 22:42:07 -05:00
-pcb_clearance_edge - thickness + corner_radius,
-thickness/2],
[90, 180, 90],
2023-11-12 23:09:49 -05:00
bottom_width + 2 * corner_radius);*/
2023-11-11 15:37:03 -05:00
2023-11-11 14:21:39 -05:00
/* Left edge */
2023-11-12 23:09:49 -05:00
/*round_edge([-pcb_clearance_edge - thickness + corner_radius,
2023-11-12 22:42:07 -05:00
-pcb_clearance_edge - thickness + corner_radius,
-thickness/2],
[270, 90, 0],
2023-11-12 23:09:49 -05:00
bottom_length + 2 * corner_radius);*/
2023-11-11 14:21:39 -05:00
2023-11-12 00:33:42 -05:00
/* Upper right wall corner */
2023-11-12 23:09:49 -05:00
/*wall_corner([thickness + pcb_clearance_edge + pcb_width - corner_radius,
2023-11-12 22:42:07 -05:00
thickness + pcb_clearance_edge + pcb_length - corner_radius,
2023-11-12 03:11:54 -05:00
-thickness/2],
2023-11-11 18:53:21 -05:00
[0, 0, 0],
corner_radius,
2023-11-12 23:09:49 -05:00
wall_height);*/
2023-11-11 18:53:21 -05:00
/* Lower right wall corner */
2023-11-12 23:09:49 -05:00
/*wall_corner([ thickness + pcb_clearance_edge + pcb_width - corner_radius,
2023-11-12 22:42:07 -05:00
0 - thickness - pcb_clearance_edge + corner_radius,
2023-11-12 03:11:54 -05:00
-thickness/2],
2023-11-11 18:53:21 -05:00
[0, 0, 270],
corner_radius,
2023-11-12 23:09:49 -05:00
wall_height);*/
2023-11-11 18:53:21 -05:00
/* Lower left wall corner */
2023-11-12 23:09:49 -05:00
/*wall_corner([0 - thickness - pcb_clearance_edge + corner_radius,
2023-11-12 22:42:07 -05:00
0 - thickness - pcb_clearance_edge + corner_radius,
2023-11-12 03:11:54 -05:00
-thickness/2],
2023-11-11 18:53:21 -05:00
[0, 0, 180],
corner_radius,
2023-11-12 23:09:49 -05:00
wall_height);*/
2023-11-11 18:53:21 -05:00
/* Upper left wall corner */
2023-11-12 23:09:49 -05:00
/*wall_corner([-pcb_clearance_edge - corner_radius,
2023-11-12 22:42:07 -05:00
pcb_clearance_edge + corner_radius + pcb_length,
-thickness/2],
2023-11-11 18:53:21 -05:00
[0, 0, 90],
corner_radius,
2023-11-12 23:09:49 -05:00
wall_height);*/
2023-11-11 18:53:21 -05:00
2023-11-11 18:12:21 -05:00
/* Bottom plate */
2023-11-12 23:09:49 -05:00
/*side([-pcb_clearance_edge - corner_radius,
2023-11-12 22:42:07 -05:00
-pcb_clearance_edge - corner_radius,
-thickness],
[bottom_width + 2 * corner_radius,
2023-11-12 23:09:49 -05:00
bottom_length + 2 * corner_radius, thickness]);*/
2023-11-11 19:47:32 -05:00
/* Screw holes */
2023-11-12 23:09:49 -05:00
/*for (screw_hole = screw_holes) {
screw_post([screw_hole[0], screw_hole[1], 0],
pcb_clearance_bottom * 2,
2023-11-11 19:47:32 -05:00
pcb_screw_hole_diameter * 2,
pcb_screw_hole_diameter);
2023-11-12 23:09:49 -05:00
}*/
2023-11-12 20:46:01 -05:00
2023-11-12 21:19:19 -05:00
/* Ridges (for rigidity!) */
ridges(thickness * 2, pcb_clearance_bottom / 2);
2023-11-11 14:21:39 -05:00
}
2023-11-12 21:13:58 -05:00
keyboard_base_plate(pcb_width, pcb_length);