diff --git a/src/key.scad b/src/key.scad index a5a84c3..49fe0c7 100644 --- a/src/key.scad +++ b/src/key.scad @@ -185,7 +185,7 @@ module keystem_positions() { module keystems() { keystem_positions() { - color(color4) stem($stem_type, $total_depth, $has_brim); + color(color4) stem($stem_type, $total_depth, $has_brim, $stem_slop); } } diff --git a/src/key_transformations.scad b/src/key_transformations.scad index ae8abc9..c939379 100644 --- a/src/key_transformations.scad +++ b/src/key_transformations.scad @@ -68,20 +68,20 @@ module blank() { children(); } -module cherry(slop = 0.3) { - $stem_slop = slop; +module cherry(slop) { + $stem_slop = slop ? slop : $stem_slop; $stem_type = "cherry"; children(); } -module alps(slop = 0.3) { - $stem_slop = slop; +module alps(slop) { + $stem_slop = slop ? slop : $stem_slop; $stem_type = "alps"; children(); } -module rounded_cherry(slop = 0.3) { - $stem_slop = slop; +module rounded_cherry(slop) { + $stem_slop = slop ? slop : $stem_slop; $stem_type = "cherry_rounded"; children(); } diff --git a/src/settings.scad b/src/settings.scad index d6b2fd0..a7b8ef9 100644 --- a/src/settings.scad +++ b/src/settings.scad @@ -91,17 +91,6 @@ $brim_height = 0.4; // how far the throw distance of the switch is. determines how far the 'cross' in the cherry switch digs into the stem, and how long the keystem needs to be before supports can start. luckily, alps and cherries have a pretty similar throw. can modify to have stouter keycaps for low profile switches, etc $stem_throw = 4; -// cherry stem dimensions -$cherry_stem = [7.2 - $stem_slop * 2, 5.5 - $stem_slop * 2]; - -// .005 purely for aesthetics, to get rid of that ugly crosshatch -$cherry_cross = [ - // horizontal tine - [4.03 + $stem_slop, 1.15 + $stem_slop / 3], - // vertical tine - [1.25 + $stem_slop / 3, $cherry_stem[1] + .005], -]; - // diameter of the outside of the rounded cherry stem $rounded_cherry_stem_d = 5.5; diff --git a/src/stems.scad b/src/stems.scad index 26fcd11..aae556e 100644 --- a/src/stems.scad +++ b/src/stems.scad @@ -5,13 +5,13 @@ include //whole stem, alps or cherry, trimmed to fit -module stem(stem_type, depth, has_brim){ +module stem(stem_type, depth, has_brim, slop){ if (stem_type == "alps") { - alps_stem(depth, has_brim); + alps_stem(depth, has_brim, slop); } else if (stem_type == "cherry_rounded") { - rounded_cherry_stem(depth, has_brim); + rounded_cherry_stem(depth, has_brim, slop); } else if (stem_type == "cherry") { - cherry_stem(depth, has_brim); + cherry_stem(depth, has_brim, slop); } else if (stem_type == "filled") { filled_stem(); } else { diff --git a/src/stems/alps.scad b/src/stems/alps.scad index c743bee..7b0debd 100644 --- a/src/stems/alps.scad +++ b/src/stems/alps.scad @@ -1,4 +1,4 @@ -module alps_stem(depth, has_brim){ +module alps_stem(depth, has_brim, slop){ if(has_brim) { linear_extrude(height=$brim_height) { offset(r=1){ diff --git a/src/stems/cherry.scad b/src/stems/cherry.scad index ed8ad9a..097883f 100644 --- a/src/stems/cherry.scad +++ b/src/stems/cherry.scad @@ -1,10 +1,21 @@ -module cherry_stem(depth, has_brim) { +// cherry stem dimensions +function outer_cherry_stem(slop) = [7.2 - slop * 2, 5.5 - slop * 2]; + +// .005 purely for aesthetics, to get rid of that ugly crosshatch +function cherry_cross(slop) = [ + // horizontal tine + [4.03 + slop, 1.15 + slop / 3], + // vertical tine + [1.25 + slop / 3, 5.5 - slop * 2 + .005], +]; + +module cherry_stem(depth, has_brim, slop) { difference(){ union() { // outside shape linear_extrude(height = depth) { offset(r=1){ - square($cherry_stem - [2,2], center=true); + square(outer_cherry_stem(slop) - [2,2], center=true); } } @@ -12,7 +23,7 @@ module cherry_stem(depth, has_brim) { if(has_brim) { linear_extrude(height = $brim_height){ offset(r=1){ - square($cherry_stem + [2,2], center=true); + square(outer_cherry_stem(slop) + [2,2], center=true); } } } @@ -22,11 +33,11 @@ module cherry_stem(depth, has_brim) { // translation purely for aesthetic purposes, to get rid of that awful lattice translate([0,0,-0.005]) { linear_extrude(height = $stem_throw) { - square($cherry_cross[0], center=true); - square($cherry_cross[1], center=true); + square(cherry_cross(slop)[0], center=true); + square(cherry_cross(slop)[1], center=true); } // Guides to assist insertion and mitigate first layer squishing - for (i = $cherry_cross) hull() { + for (i = cherry_cross(slop)) hull() { linear_extrude(height = 0.01, center = false) offset(delta = 0.4) square(i, center=true); translate([0, 0, 0.5]) linear_extrude(height = 0.01, center = false) square(i, center=true); } diff --git a/src/stems/rounded_cherry.scad b/src/stems/rounded_cherry.scad index faadf9f..54ca492 100644 --- a/src/stems/rounded_cherry.scad +++ b/src/stems/rounded_cherry.scad @@ -1,4 +1,12 @@ -module rounded_cherry_stem(depth, has_brim) { +// .005 purely for aesthetics, to get rid of that ugly crosshatch +function cherry_cross(slop) = [ + // horizontal tine + [4.03 + slop, 1.15 + slop / 3], + // vertical tine + [1.25 + slop / 3, 5.5 - slop * 2 + .005], +]; + +module rounded_cherry_stem(depth, has_brim, slop) { difference(){ union(){ cylinder(d=$rounded_cherry_stem_d, h=depth); @@ -11,8 +19,8 @@ module rounded_cherry_stem(depth, has_brim) { // translation purely for aesthetic purposes, to get rid of that awful lattice translate([0,0,-0.005]) { linear_extrude(height = $stem_throw) { - square($cherry_cross[0], center=true); - square($cherry_cross[1], center=true); + square(cherry_cross(slop)[0], center=true); + square(cherry_cross(slop)[1], center=true); } } } diff --git a/src/supports/flared.scad b/src/supports/flared.scad index f43749e..1aed5c6 100644 --- a/src/supports/flared.scad +++ b/src/supports/flared.scad @@ -1,3 +1,7 @@ +// cherry stem dimensions +// don't wanna introduce slop here so $stem_slop it is I guess +function outer_cherry_stem() = [7.2 - $stem_slop * 2, 5.5 - $stem_slop * 2]; + // figures out the scale factor needed to make a 45 degree wall function scale_for_45(height, starting_size) = (height * 2 + starting_size) / starting_size; @@ -6,10 +10,10 @@ function scale_for_45(height, starting_size) = (height * 2 + starting_size) / st module flared_support(stem_type, loft, height) { translate([0,0,loft]){ if(stem_type == "cherry") { - cherry_scale = [scale_for_45(height, $cherry_stem[0]), scale_for_45(height, $cherry_stem[1])]; + cherry_scale = [scale_for_45(height, outer_cherry_stem()[0]), scale_for_45(height, outer_cherry_stem()[1])]; linear_extrude(height=height, scale = cherry_scale){ offset(r=1){ - square($cherry_stem - [2,2], center=true); + square(outer_cherry_stem() - [2,2], center=true); } } } else if (stem_type == "cherry_rounded") {