added some stuff (backspaceesque keys and standard keys)
[Model-M.git] / key-std.scad
blobac3388af3e0344d63d718b9676ac6d5a8e2681e9
1 //measures are in millimeters
2 //(feel free to cocnvert them to attoparsecs)
3 WallThickness=0.75;
4 AY=18.5;
5 AX=19.0;
6 BY=12.5;
7 BLX=14.5;
8 EZ=11.0;
9 FLZ=14.0;
10 H=12.75;
11 CYL_OFF_Z=50;
12 CYL_DEPTH=0.1;
13 CLIP_X=2;
14 CLIP_Y=0.75;
15 CLIP_H=3*CLIP_Y;
16 CORNER_RADIUS=2;
17 SHAFT_OFF_Y=(AY-2*WallThickness)/2;
18 INNER_GUARD_RADIUS=6.5;
19 OUTER_GUARD_RADIUS=7.5;
20 BLIND_SHAFT_OUTER_DIAMETER=4.0;
21 BLIND_SHAFT_INNER_DIAMETER=2.0;
22 SHAFT_X=8.0;
23 SHAFT_Y=6.0;
24 SHAFT_LENGTH=9.0;
25 SHAFT_THICKNESS=1.0;
26 SHAFT_CLIP_WIDTH=3.0;
27 SHAFT_CLIP_THICKNESS=0.75;
28 SHAFT_CLIP_HEIGHT=2.0;
29 SHAFT_CLIP_SLOPE_DEPTH=1.0;
30 SHAFT_CLIP_ANGLE=45;
31 SHAFT_END_CUTOUT_HEIGHT=1.5;
32 SHAFT_LARGE_SLOT_TO_BASE=1.5;
33 SHAFT_SMALL_SLOT_LENGTH=7.25;
34 SHAFT_SMALL_SLOT_WIDTH=2.5;
35 SHAFT_SPRING_HOLDER_WIDTH=3.0;
36 SHAFT_SPRING_HOLDER_TO_BASE=4.0;
37 SHAFT_SPRING_GUIDE_WIDTH=1.0;
38 SHAFT_SPRING_GUIDE_SIDES_HEIGHT=3.5;
39 STRUT_THICKNESS=1;
40 STRUT_HEIGHT=3;
41 STRUT_SPACING=1;
42 SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT=1;
43 SHAFT_SPRING_HOLDER_NIPPLE_RADIUS=0.75;
44 SHAFT_SMALL_SLOT_BEVEL=0.5;
46 CLIP_NOTCH_DEPTH=1.0;
47 CLIP_NOTCH_WIDTH=3.0;
48 CLIP_NOTCH_HEIGHT=1.5;
50 ClipWidth=2.2;
51 ClipDepth=0.75;
53 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
54 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
56 alpha=asin((H-EZ)/BLX);
57 beta=asin(H/FLZ);
58 gamma=90-asin((0.5*(AY-BY))/EZ);
60 module keycap(){
61         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
62         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
63         minkowski(){
64                 difference(){
65                         cube([AX,AY,H]);
66                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
67                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
68                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
69                         translate([0,AY/2,EZ+CYL_OFF_Z]) rotate(a=90-alpha,v=[0,1,0]) cylinder(h=100,center=true,r=CYL_OFF_Z+CYL_DEPTH,$fa=1);
70                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
71                 }
72                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
73                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
74         }
77 module blind_shaft(){
78         translate([0,0,-SHAFT_LENGTH]) difference(){
79                 cylinder(r=BLIND_SHAFT_OUTER_DIAMETER/2,h=100,$fs=0.3);
80                 cylinder(r=BLIND_SHAFT_INNER_DIAMETER/2,h=100,$fs=0.3);
81         }
84 module shaft(){
85         spring_guide_length = SHAFT_X-SHAFT_THICKNESS-SHAFT_SPRING_HOLDER_WIDTH;
86         spring_guide_height = SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_LARGE_SLOT_TO_BASE;
87         translate([0,0,-SHAFT_LENGTH]) difference(){
88                 union(){
89                         difference(){
90                                 union(){
91                                         difference(){
92                                                 intersection(){
93                                                         cylinder(h=100,r=SHAFT_X/2,$fs=0.3);
94                                                         translate([-SHAFT_X/2,-SHAFT_Y/2,0]) cube([SHAFT_X,SHAFT_Y,100]);
95                                                 }
96                                                 intersection(){
97                                                         cylinder(h=100,r=SHAFT_X/2-SHAFT_THICKNESS,$fs=0.3);
98                                                         translate([-SHAFT_X/2+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([SHAFT_X-2*SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,100]);
99                                                 }
100                                         }
101                                         translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
102                                         translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
103                                 }
104                                 translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2+SHAFT_CLIP_SLOPE_DEPTH,0]) rotate(a=90+SHAFT_CLIP_ANGLE,v=[1,0,0]) cube([SHAFT_CLIP_WIDTH/2,100,100]);
105                                 translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2+SHAFT_CLIP_THICKNESS-SHAFT_CLIP_SLOPE_DEPTH,0]) mirror([0,1,0]) rotate(a=90+SHAFT_CLIP_ANGLE,v=[1,0,0]) cube([SHAFT_CLIP_WIDTH/2,100,100]);
106                                 translate([0,-50,0]) cube([100,100,SHAFT_END_CUTOUT_HEIGHT]);
107                                 translate([0,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([100,SHAFT_Y-SHAFT_THICKNESS*2,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]);
108                                 //small slot cutout
109                                 translate([0,-SHAFT_SMALL_SLOT_WIDTH/2,0]){
110                                         mirror([1,0,0]) cube([100,SHAFT_SMALL_SLOT_WIDTH,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]);
111                                 }
112                                 //small slot cutout
113                                 translate([0,0,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]) rotate(a=-90,v=[0,1,0]) cylinder(r=SHAFT_SMALL_SLOT_WIDTH/2,h=SHAFT_X/2,$fs=0.3);
114                         }
115                         //spring holder
116                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH/2+SHAFT_THICKNESS,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) cylinder(r=SHAFT_SPRING_HOLDER_WIDTH/2,h=100,$fs=0.3);
117                         intersection(){
118                                 translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH/2+SHAFT_THICKNESS,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT]) cylinder(r=SHAFT_SPRING_HOLDER_NIPPLE_RADIUS,h=100,$fs=0.3);
119                                 translate([0,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT*1.5]) rotate(v=[0,1,0], a=atan(SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT/(SHAFT_SPRING_HOLDER_NIPPLE_RADIUS*2))) translate([-50,-50,0]) cube(100,100,100);
120                         }
121                         intersection(){
122                                 difference(){
123                                         translate([SHAFT_X/2-SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]) mirror([1,0,0]) cube([100,SHAFT_SPRING_GUIDE_WIDTH,100]);
124                                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE])
125                                         mirror([1,0,0]) rotate(a=90-asin(spring_guide_height/spring_guide_length),v=[0,1,0]) mirror([0,0,1]) translate([0,0,-50]) cube([100,SHAFT_SPRING_GUIDE_WIDTH,100]);
126                                 }
127                                 cube([SHAFT_X-SHAFT_THICKNESS,SHAFT_Y,100],center=true);
128                         }
129                         //side spring guides
130                         difference(){
131                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_GUIDE_SIDES_HEIGHT]) cube([SHAFT_SPRING_GUIDE_WIDTH,SHAFT_Y-2*SHAFT_THICKNESS,EZ-SHAFT_SPRING_HOLDER_TO_BASE+SHAFT_SPRING_GUIDE_SIDES_HEIGHT]);
132                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_SPRING_HOLDER_WIDTH/2,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) rotate(a=-asin(((SHAFT_Y-SHAFT_SPRING_HOLDER_WIDTH)/2-SHAFT_THICKNESS)/SHAFT_SPRING_GUIDE_SIDES_HEIGHT),v=[1,0,0]) translate([0,0,-50]) cube([SHAFT_SPRING_GUIDE_WIDTH,100,100]);
133                         }
134                         difference(){
135                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_GUIDE_SIDES_HEIGHT]) cube([SHAFT_SPRING_GUIDE_WIDTH,SHAFT_Y-2*SHAFT_THICKNESS,EZ-SHAFT_SPRING_HOLDER_TO_BASE+SHAFT_SPRING_GUIDE_SIDES_HEIGHT]);
136                                 mirror([0,1,0]) translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_SPRING_HOLDER_WIDTH/2,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) rotate(a=-asin(((SHAFT_Y-SHAFT_SPRING_HOLDER_WIDTH)/2-SHAFT_THICKNESS)/SHAFT_SPRING_GUIDE_SIDES_HEIGHT),v=[1,0,0]) translate([0,0,-50]) cube([SHAFT_SPRING_GUIDE_WIDTH,100,100]);
137                         }
138                 }
139                 translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) mirror([1,0,0]) rotate(a=90-asin(spring_guide_height/spring_guide_length),v=[0,1,0]) mirror([0,0,1]) cube([SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,100]);
140         }
143 module guard(){
144         difference(){
145                 union(){
146                         cube([100,STRUT_THICKNESS,100],center=true);
147                         cylinder(r=OUTER_GUARD_RADIUS,h=100);
148                 }
149                 difference(){
150                         cylinder(r=INNER_GUARD_RADIUS,h=100);
151                         translate([-STRUT_SPACING/2-STRUT_THICKNESS,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
152                         translate([STRUT_SPACING/2,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
153                         translate([-50,-STRUT_SPACING/2-STRUT_THICKNESS,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
154                         translate([-50,STRUT_SPACING/2,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
155                 }
156         }
159 difference(){
160         scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
161         difference(){
162                 translate([WallThickness, WallThickness, 0]) scale(v=[1-4*WallThickness/AX, 1-4*WallThickness/AY, 1-2*WallThickness/H]) keycap();
163                 translate([OUTER_GUARD_RADIUS,0,0]){
164                         translate([0,SHAFT_OFF_Y]) guard();
165                         difference(){
166                                  cube([CLIP_NOTCH_WIDTH+2*WallThickness,100,100],center=true);
167                                  translate([0,SHAFT_OFF_Y]) cube([100,2*OUTER_GUARD_RADIUS-WallThickness,100],center=true);
168                         }
169                 }
170         }
172         translate([OUTER_GUARD_RADIUS-CLIP_NOTCH_WIDTH/2,0,0]){
173                 cube([CLIP_NOTCH_WIDTH,CLIP_NOTCH_DEPTH,CLIP_NOTCH_HEIGHT]);
174                 translate([0,AY-2*WallThickness-CLIP_NOTCH_DEPTH,0]) cube([CLIP_NOTCH_WIDTH,CLIP_NOTCH_DEPTH,CLIP_NOTCH_HEIGHT]);
175         }
178 intersection(){
179         union(){
180                 translate([WallThickness, WallThickness, 0]) scale(v=[1-4*WallThickness/AX, 1-4*WallThickness/AY, 1-2*WallThickness/H]) keycap();
181                 translate([-50,-50,-99.9]) cube([100,100,100]);
182         }
183         translate([OUTER_GUARD_RADIUS,0,0]){
184                 translate([0,SHAFT_OFF_Y]) shaft();
185         }