Refactoring for reasons

This commit is contained in:
XANTRONIX 2023-11-13 15:14:25 -05:00
parent 20c3784c67
commit 9d734d80d5

View file

@ -2,28 +2,9 @@ $fn = 72;
pcb_width = 257.175; pcb_width = 257.175;
pcb_length = 95.250; pcb_length = 95.250;
pcb_thickness = 1.6; pcb_height = 1.600;
module keyboard_base_plate(pcb_width, pcb_length) { pcb_screw_holes = [
pcb_clearance_edge = 1.0;
pcb_clearance_bottom = 2.0;
pcb_screw_hole_diameter = 1.5;
thickness = 1.75;
corner_radius = 0.2;
case_color = [0.5, 0.5, 0.5, 1.0];
wall_width = pcb_width + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
wall_length = pcb_length + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
wall_height = 14.0;
bottom_width = 2 * (pcb_clearance_edge) + pcb_width;
bottom_length = 2 * (pcb_clearance_edge) + pcb_length;
bottom_height = thickness;
screw_holes = [
[ 4.7625, 85.7250], [ 4.7625, 85.7250],
[ 66.6750, 85.7250], [ 66.6750, 85.7250],
[161.9250, 85.7250], [161.9250, 85.7250],
@ -36,6 +17,37 @@ module keyboard_base_plate(pcb_width, pcb_length) {
[238.1250, 9.5250] [238.1250, 9.5250]
]; ];
switch_leg_length = 3.30;
switch_height = 11.10;
module keyboard_base_plate(pcb_dimensions, switch_z_range, screw_holes) {
pcb_width = pcb_dimensions[0];
pcb_length = pcb_dimensions[1];
pcb_height = pcb_dimensions[2];
switch_z_min = switch_z_range[0];
switch_z_max = switch_z_range[1];
pcb_clearance_edge = 1.0;
pcb_clearance_bottom = -switch_z_min - pcb_height + 0.5;
pcb_screw_diameter = 1.5;
pcb_screw_hole_diameter = 1.5;
pcb_screw_height = 3.0;
thickness = 1.75;
corner_radius = 0.2;
case_color = [0.5, 0.5, 0.5, 1.0];
wall_width = pcb_width + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
wall_length = pcb_length + 2 * (pcb_clearance_edge + thickness) - 2 * corner_radius;
wall_height = pcb_screw_height + pcb_height + switch_z_max;
bottom_width = 2 * (pcb_clearance_edge) + pcb_width;
bottom_length = 2 * (pcb_clearance_edge) + pcb_length;
bottom_height = thickness;
module round_corner(translation, rotation) { module round_corner(translation, rotation) {
color(case_color) color(case_color)
translate(translation) translate(translation)
@ -77,12 +89,15 @@ module keyboard_base_plate(pcb_width, pcb_length) {
} }
} }
module screw_post(translation, h, d1, d2) { module screw_post(translation, h, d) {
diameter_outer = 3 * d;
diameter_inner = d;
color(case_color) color(case_color)
translate(translation) translate(translation)
difference() { difference() {
cylinder(h=h, r1=(d1/2.0) * 1.5); cylinder(h=h, r1 = (diameter_outer / 2.0) * 1.5);
cylinder(h=h, r= d2/2.0); cylinder(h=h, r = diameter_inner / 2.0);
} }
} }
@ -227,13 +242,14 @@ module keyboard_base_plate(pcb_width, pcb_length) {
/* Screw holes */ /* Screw holes */
for (screw_hole = screw_holes) { for (screw_hole = screw_holes) {
screw_post([screw_hole[0], screw_hole[1], 0], screw_post([screw_hole[0], screw_hole[1], 0],
pcb_clearance_bottom * 2, pcb_screw_height,
pcb_screw_hole_diameter * 3, pcb_screw_diameter);
pcb_screw_hole_diameter);
} }
/* Ridges (for rigidity!) */ /* Ridges (for rigidity!) */
ridges(thickness * 2, pcb_clearance_bottom / 2); ridges(thickness * 2, pcb_clearance_bottom / 2);
} }
keyboard_base_plate(pcb_width, pcb_length); keyboard_base_plate([pcb_width, pcb_length, pcb_height],
[-switch_leg_length, switch_height],
pcb_screw_holes);