-
Notifications
You must be signed in to change notification settings - Fork 1
/
SKRH.scad
73 lines (59 loc) · 2.75 KB
/
SKRH.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
include <../settings.scad>;
use <../include/keycap.scad>;
/* tuned on a Prusa MK3 using .20 mm layer height. enable printing of external perimeters first for accurate dimensions.
* recommendation is to print upright and don't enable supports for the bridging over the switch hole (which plug the hole).
* if the keycap sits too high on the switch you can use the vertical slop to try to account for the droop in the bridging,
* otherwise you can try upside-down with supports.
* I experienced a lot of variability from print to print, especially upside-down.
* letting the machine cool somewhat between prints seemed to help.
*/
vertical_slop = 0.4;
inner_slop = printer == "prusa" ? .015 : "cr10" ? .25 : 0;
//outer_slop = 0.2;
stemdia = keycap_style == "bar" || keycap_style == "banana" || keycap_style == "dome" ? minimum_thickness : 6.6;
switch_stem_base = 3 - 1.85; // from datasheet
switch_stem_height = 2 + switch_stem_base; // from datasheet
switch_stem_clearance = 0.3; // from datasheet
switch_offset = switch_stem_base + switch_stem_clearance;
holedepth = switch_stem_height - switch_offset + vertical_slop;
stemheight = effective_height - height_offset() - switch_offset;
holeside_raw = 1.95; // from datasheet
// adjust for FDM imprecision
function holeside_x() = holeside_raw + inner_slop + (is_undef($inner_slop_x) ? 0 : $inner_slop_x);
function holeside_y() = holeside_raw + inner_slop + (is_undef($inner_slop_y) ? 0 : $inner_slop_y);
if (keycap_style == "trackpoint-lp") {
assert(stemheight >= holedepth, str("stem height ", stemheight, " must be at least ", holedepth, ", the depth of the switch stem hole"));
} else if(keycap_style != "bar") {
assert(stemheight >= minimum_thickness, str("stem height ", stemheight, " is less than the minimum thickness ", minimum_thickness));
}
module stemouter() {
if ( keycap_rotation.x != 0 || keycap_rotation.y != 0) {
// translate([0,0,stemheight]) sphere(d=stemdia);
h = 100;
difference() {
cylinder(stemheight+h, d=stemdia);
translate([0,0,stemheight]) rotate(keycap_rotation) translate([-h,-h,minimum_thickness/2]) cube([2*h,2*h,2*h]);
}
} else {
cylinder(stemheight+minimum_thickness/2, d=stemdia);
}
}
module stem() {
difference() {
stemouter();
translate([0,0,holedepth/2]) cube([holeside_x(),holeside_y(),holedepth], true);
}
}
module assembled() {
difference() {
union() {
stemouter();
translate([0,0,stemheight]) rotate(keycap_rotation) cap();
}
translate([0,0,holedepth/2]) cube([holeside_x(),holeside_y(),holedepth], true);
}
}
// preview
translate([0,0,switch_offset]) assembled($fn=24);
// see README for the gf*mm calculation from the SKRH datasheet values
echo(str(" Estimated operating force is ", 550 / effective_height, " gf"));