Hah! Capslock! Though... well... I'm not that sure this key will work (it looks kinda...
[Model-M.git] / shift.scad
blobeb3693ec4c544e9d23b32057d2ba135d6b28a88e
1 //measures are in millimeters
2 AY=23.0;
3 AX=19.0;
4 BY=18.0;
5 BLX=14.5;
6 EZ=11.0;
7 FLZ=14.0;
8 H=12.75;
9 CYL_OFF_Z=70;
10 CYL_DEPTH=0.1;
11 CLIP_X=2;
12 CLIP_Y=0.75;
13 CLIP_H=3*CLIP_Y;
14 CORNER_RADIUS=2;
15 INNER_GUARD_RADIUS=6.5;
16 OUTER_GUARD_RADIUS=7.5;
17 SHAFT_X=8.0;
18 SHAFT_Y=6.0;
19 SHAFT_LENGTH=9.0;
20 SHAFT_THICKNESS=1.0;
21 SHAFT_CLIP_WIDTH=3.0;
22 SHAFT_CLIP_THICKNESS=0.75;
23 SHAFT_CLIP_HEIGHT=2.0;
24 SHAFT_CLIP_SLOPE_DEPTH=1.0;
25 SHAFT_CLIP_ANGLE=45;
26 SHAFT_END_CUTOUT_HEIGHT=1.5;
27 SHAFT_LARGE_SLOT_TO_BASE=1.5;
28 SHAFT_SMALL_SLOT_LENGTH=7.25;
29 SHAFT_SMALL_SLOT_WIDTH=2.5;
30 SHAFT_SPRING_HOLDER_WIDTH=3.0;
31 SHAFT_SPRING_HOLDER_TO_BASE=4.0;
32 SHAFT_SPRING_GUIDE_WIDTH=1.0;
33 SHAFT_SPRING_GUIDE_SIDES_HEIGHT=3.5;
34 STRUT_THICKNESS=1;
35 STRUT_HEIGHT=3;
36 STRUT_SPACING=1;
37 SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT=1;
38 SHAFT_SPRING_HOLDER_NIPPLE_RADIUS=0.75;
40 SHAFT_SMALL_SLOT_BEVEL=0.5;
42 WallThickness=0.75;
43 ClipWidth=2.2;
44 ClipDepth=0.75;
46 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
47 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
49 alpha=asin((H-EZ)/BLX);
50 beta=asin(H/FLZ);
51 gamma=90-asin((0.5*(AY-BY))/EZ);
53 module keycap(){
54         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
55         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
56         minkowski(){
57                 difference(){
58                         cube([AX,AY,H]);
59                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
60                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
61                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
62                         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);
63                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
64                 }
65                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
66                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
67         }
70 module blind_shaft(){
74 module shaft(){
75         spring_guide_length = SHAFT_X-SHAFT_THICKNESS-SHAFT_SPRING_HOLDER_WIDTH;
76         spring_guide_height = SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_LARGE_SLOT_TO_BASE;
77         translate([0,0,-SHAFT_LENGTH]) difference(){
78                 union(){
79                         difference(){
80                                 union(){
81                                         difference(){
82                                                 intersection(){
83                                                         cylinder(h=100,r=SHAFT_X/2,$fs=0.3);
84                                                         translate([-SHAFT_X/2,-SHAFT_Y/2,0]) cube([SHAFT_X,SHAFT_Y,100]);
85                                                 }
86                                                 intersection(){
87                                                         cylinder(h=100,r=SHAFT_X/2-SHAFT_THICKNESS,$fs=0.3);
88                                                         translate([-SHAFT_X/2+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([SHAFT_X-2*SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,100]);
89                                                 }
90                                         }
91                                         translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
92                                         translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
93                                 }
94                                 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]);
95                                 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]);
96                                 translate([0,-50,0]) cube([100,100,SHAFT_END_CUTOUT_HEIGHT]);
97                                 translate([0,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([100,SHAFT_Y-SHAFT_THICKNESS*2,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]);
98                                 //small slot cutout
99                                 translate([0,-SHAFT_SMALL_SLOT_WIDTH/2,0]){
100                                         mirror([1,0,0]) cube([100,SHAFT_SMALL_SLOT_WIDTH,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]);
101                                 }
102                                 //small slot cutout
103                                 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);
104                         }
105                         //spring holder
106                         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);
107                         intersection(){
108                                 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);
109                                 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);
110                         }
111                         intersection(){
112                                 difference(){
113                                         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]);
114                                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE])
115                                         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]);
116                                 }
117                                 cube([SHAFT_X-SHAFT_THICKNESS,SHAFT_Y,100],center=true);
118                         }
119                         //side spring guides
120                         difference(){
121                                 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]);
122                                 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]);
123                         }
124                         difference(){
125                                 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]);
126                                 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]);
127                         }
128                 }
129                 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]);
130         }
133 module guard(){
134         difference(){
135                 union(){
136                         cube([STRUT_THICKNESS,100,100],center=true);
137                         cube([100,STRUT_THICKNESS,100],center=true);
138                         cylinder(r=OUTER_GUARD_RADIUS,h=100);
139                 }
140                 difference(){
141                         cylinder(r=INNER_GUARD_RADIUS,h=100);
142                         translate([-STRUT_SPACING/2-STRUT_THICKNESS,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
143                         translate([STRUT_SPACING/2,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
144                         translate([-50,-STRUT_SPACING/2-STRUT_THICKNESS,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
145                         translate([-50,STRUT_SPACING/2,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
146                 }
147         }
150 difference(){
151         keycap();
152         difference(){
153                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
154                 translate([OUTER_GUARD_RADIUS+WallThickness,AY/2]) guard();
155         }
157 intersection(){
158         union(){
159                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
160                 translate([-50,-50,-99.9]) cube([100,100,100]);
161         }
162         translate([OUTER_GUARD_RADIUS+WallThickness,AY/2]) union(){
163                 shaft();
164         }