diff --git a/README.md b/README.md index 26ed0ed..c30bd33 100644 --- a/README.md +++ b/README.md @@ -124,8 +124,6 @@ That's it, if you have any questions feel free to open an issue or leave a comme ## TODO: - * pull out side sculpting options to let people tweak them? - * can now measure keycaps very accurately. need to redo measurements: [x] SA [ ] DCS [X] DSA [X] OEM? - * Add inset stem to all profiles that need it. [x] OEM [ ] DCS? - * customizer version where everything is copy/pasted in. needs to be last. + * replace linear_extrude_shape_hull with skin_extrude_shape_hull or something + * replace current ISO enter shape with one that works for `skin()` * generate dishes via math? kind of hard, maybe later diff --git a/keys.scad b/keys.scad index 4cecd6a..cc1cd8d 100644 --- a/keys.scad +++ b/keys.scad @@ -20,29 +20,24 @@ module translate_u(x=0, y=0, z=0){ translate([x * unit, y*unit, z*unit]) children(); } -// basic -cherry() key(); +// row 5 is commonly the top row, for whatever reason +key_profiles = ["dcs", "oem", "sa", "g20", "dsa"]; -translate_u(1) sa_row(2) cherry() key("q"); -translate_u(2) oem_row(2) alps() key("q", inset=true); -translate_u(3) dsa_row() flat_support() rounded_cherry() key(); - -translate_u(1, 1) sa_row(3) lshift() cherry() key(inset=true) { - sphere(1); -}; - -translate_u(3, 2) sa_row(3) bar_support() spacebar() cherry() key("space bar"); - -translate_u(3,1) sa_row(3) 2u() cherry() { - $key_shape_type = "oblong"; - $support_type = false; - $inverted_dish = true; - key(); +module one_single_key(profile, row, unsculpted) { + key_profile(profile, unsculpted ? 3 : row) cherry() key(); } +module one_row_profile(profile, unsculpted = false) { + rows = [5, 1, 2, 3, 4]; + for(row = [0:len(rows)-1]) { + translate_u(0, -row) one_single_key(profile, rows[row], unsculpted); + } +} -/* // g20 / dsa sculpting test -for (x = [1:5]) { - translate_u(0, x) dsa_row(x) cherry() key(); - translate_u(1, x) g20_row(x) cherry() key(); -} */ +for (p = [0:len(key_profiles)-1]) { + translate_u(p){ + /* one_row_profile(key_profiles[p]); */ + } +} + +/* translate_u(0, 0) one_row_profile("oem"); */ diff --git a/keysets.scad b/keysets.scad index 0c500b4..497c9f0 100644 --- a/keysets.scad +++ b/keysets.scad @@ -19,14 +19,17 @@ for (row = [0:len(60_percent)-1]){ for(column = [0:len(60_percent[row])-1]) { columnDist = sum([for (x = [0 : column]) 60_percent[row][x]]); a = 60_percent[row][column]; - translate_u(columnDist - (a/2), -row) dishless() dcs_row((row+4) % 5 + 1) u(a) cherry() { - $width_difference = 0; - $height_difference = 0; - $key_shape_type = "spherical"; - if (a != 6.25) { - key(); - } else { + translate_u(columnDist - (a/2), -row) g20_row(3) u(a) cherry() { // (row+4) % 5 + 1 + if (a == 6.25) { spacebar() key(); + } else if (a == 2.25) { + lshift() key(); + } else if (a == 2) { + backspace() key(); + } else if (a == 2.75) { + rshift() key(); + } else { + key(); } } } diff --git a/src/dishes/spherical.scad b/src/dishes/spherical.scad index 9dfbd7c..6d7b151 100644 --- a/src/dishes/spherical.scad +++ b/src/dishes/spherical.scad @@ -16,10 +16,10 @@ module spherical_dish(width, height, depth, inverted){ geodesic_sphere(r=depth); } } else { - $fa=7; + $fa=6.5; // rotate 1 because the bottom of the sphere looks like trash. scale([chord/2/depth, chord/2/depth]) { - geodesic_sphere(r=depth); + sphere(r=depth); } } } diff --git a/src/key.scad b/src/key.scad index 058b868..f00585a 100644 --- a/src/key.scad +++ b/src/key.scad @@ -13,7 +13,7 @@ color1 = [.2667,.5882,1]; color2 = [.5412, .4784, 1]; color3 = [.4078, .3569, .749]; color4 = [1, .6941, .2]; -transparent_red = [1,0,0, 0.5]; +transparent_red = [1,0,0, 0.15]; // derived values. can't be variables if we want them to change when the special variables do @@ -29,21 +29,19 @@ function top_total_key_height() = $bottom_key_height + (unit * ($key_height - 1) // key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height module shape(thickness_difference, depth_difference){ dished(depth_difference, $inverted_dish) { - color(color1) shape_hull(thickness_difference, depth_difference, 1); + color(color1) shape_hull(thickness_difference, depth_difference, 2); } } // shape of the key but with soft, rounded edges. much more realistic, MUCH more complex. orders of magnitude more complex module rounded_shape() { - render(){ - color(color1) minkowski(){ - // half minkowski. that means the shape is neither circumscribed nor inscribed. - shape($minkowski_radius * 2, $minkowski_radius/2); - difference(){ - sphere(r=$minkowski_radius, $fn=24); - translate([0,0,-$minkowski_radius]){ - cube($minkowski_radius * 2, center=true); - } + color(color1) minkowski(){ + // half minkowski in the z direction + shape($minkowski_radius * 2, $minkowski_radius/2); + difference(){ + sphere(r=$minkowski_radius, $fn=20); + translate([0,0,-$minkowski_radius]){ + cube($minkowski_radius * 2, center=true); } } } diff --git a/src/key_profiles.scad b/src/key_profiles.scad index d906c6e..74cf701 100644 --- a/src/key_profiles.scad +++ b/src/key_profiles.scad @@ -6,3 +6,18 @@ include include include include + +// man, wouldn't it be so cool if functions were first order +module key_profile(key_profile_type, row) { + if (key_profile_type == "dcs") { + dcs_row(row) children(); + } else if (key_profile_type == "oem") { + oem_row(row) children(); + } else if (key_profile_type == "dsa") { + dsa_row(row) children(); + } else if (key_profile_type == "sa") { + sa_row(row) children(); + } else if (key_profile_type == "g20") { + g20_row(row) children(); + } +} diff --git a/src/key_profiles/dsa.scad b/src/key_profiles/dsa.scad index 904c00e..d3b993e 100644 --- a/src/key_profiles/dsa.scad +++ b/src/key_profiles/dsa.scad @@ -4,7 +4,7 @@ module dsa_row(n=3) { $width_difference = 6; // 5.7; $height_difference = 6; // 5.7; $total_depth = 8.1 + abs((n-3) * 1); - $top_tilt = (n-3) * -7; + $top_tilt = n == 5 ? -21 : (n-3) * 7; $top_skew = 0; $dish_type = "spherical"; $dish_depth = 1.2; diff --git a/src/key_profiles/g20.scad b/src/key_profiles/g20.scad index 9629cc9..212880a 100644 --- a/src/key_profiles/g20.scad +++ b/src/key_profiles/g20.scad @@ -3,9 +3,9 @@ module g20_row(n=3) { $bottom_key_height = 18.16; $width_difference = 2; $height_difference = 2; - $total_depth = 6; + $total_depth = 6 + abs((n-3) * 0.5); $top_tilt = 2.5; - $top_tilt = (n-3) * -7 + 2.5; + $top_tilt = n == 5 ? -18.5 : (n-3) * 7 + 2.5; $top_skew = 0.75; $dish_type = "no dish"; $dish_depth = 0; @@ -13,7 +13,7 @@ module g20_row(n=3) { $dish_skew_y = 0; $minkowski_radius = 1.75; //also, - /*$rounded_key = true;*/ + $rounded_key = true; children(); diff --git a/src/key_profiles/sa.scad b/src/key_profiles/sa.scad index 0808cfc..bdae3cd 100644 --- a/src/key_profiles/sa.scad +++ b/src/key_profiles/sa.scad @@ -13,8 +13,9 @@ module sa_row(n=1) { // might wanna change this if you don't minkowski // do you even minkowski bro $corner_radius = 0.25; - - if (n == 1){ + // 5th row is usually unsculpted or the same as the row below it + // making a super-sculpted top row (or bottom row!) would be real easy + if (n == 1 || n == 5){ $total_depth = 14.89; $top_tilt = -13; children(); @@ -22,7 +23,7 @@ module sa_row(n=1) { $total_depth = 12.925; $top_tilt = -7; children(); - } else if (n == 3) { + } else if (n == 3 || n == 5) { $total_depth = 12.5; $top_tilt = 0; children();