chiark / gitweb /
air-hockey-puck: wip
[reprap-play.git] / sleepphone-cable-box.scad
1 // -*- C -*-
2
3 include <funcs.scad>
4
5 wall = 0.75 * [1,1,1];
6 wall_bot = 1.0;
7
8 phone = [ 76.40, 30.96, 6.00 ]; // includes socket
9 phone_button_z = 6.58;
10 minwall = 0.50;
11
12 expose = 4.00;
13
14 cutout_dia = 7;
15 cutout_between = 5;
16
17 button_dz = 1.35;
18 button_dz_centre = 1.35 + 0.75;
19 button_dz_outer  = 1.35;
20
21 button_dy_outer = 28.42;
22 button_dy_inner = 19.05;
23 button_dy_centre = 5.65;
24
25 nrbutton_brace_x = 37.5;
26
27 phone_slop = 0.5 * [1,1,0]
28            + 0.5 * [0,0,1];
29
30 led = [25.9, 9.44]; // y is from edge
31 led_dia = 4.4;
32
33 // next values include slop
34 plug_maxw = 10.95 + 0.35;
35 plug_minw=   6.53 + 0.35;
36 plug_sllen=  6.50;
37 plug_totlen = 84.90 + 1.5 - 2.0; // to maxw, including phone
38
39 plug_h = 6.5;
40 plug_tooth_h = 0.5;
41 plug_tooth_dy = 0.5;
42
43 keeper_prong = 2;
44 keeper_stalk_basewidth = 12;
45 keeper_stalk_len = 70;
46 keeper_stalk_gap = 1;
47 keeper_stalk_thick = wall_bot;
48
49 keeper_stalk_base_reinforce_len = 5;
50 keeper_stalk_base_reinforce_thick = 2.0;
51
52 // calculated
53
54 top_z = max( phone[2] + wall[2],
55              phone_button_z + minwall )
56   + phone_slop[2];
57
58 plugkeeper_x_maxw = phone[0] - plug_totlen;
59
60 plugkeeper_p_max = [ 0, plug_maxw/2 ];
61 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
62 plugkeeper_d_u = unitvector2d(
63                  clockwise2d(
64                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
65                              )
66                              );
67
68 module MainProfileInnerHalf(){
69   p = phone + phone_slop;
70   pbc = p[2] + button_dz_centre;
71   pbo = p[2] + button_dz_outer;
72   polygon([[ -2,                 0    ],
73            [ p[1]/2,             0    ],
74            [ p[1]/2,             p[2] ],
75            [ button_dy_outer/2,  p[2] ],
76            [ button_dy_outer/2,  pbo  ],
77            [ button_dy_inner/2,  pbo  ],
78            [ button_dy_inner/2,  p[2] ],
79            [ button_dy_centre/2, p[2] ],
80            [ button_dy_centre/2, pbc  ],
81            [ -2,                 pbc  ]]);
82 }
83
84 module MainProfile(){
85   p = phone + phone_slop;
86   difference(){
87     for (m=[0,1]) mirror([m,0]) {
88         minkowski(){
89           translate([ -wall[1], -wall_bot ])
90             square([ wall[1]*2, wall_bot + wall[2] ]);
91           MainProfileInnerHalf();
92         }
93       }
94     for (m=[0,1]) mirror([m,0]) {
95         MainProfileInnerHalf();
96       }
97   }
98 }
99
100 module BraceProfileInitial(){
101   p = phone + phone_slop;
102   pbo = p[2] + button_dz_outer;
103   pbc = p[2] + button_dz_centre;
104   polygon([[ button_dy_outer/2 + 0.2,  p[2]           ],
105            [ button_dy_outer/2 + 0.2,  pbo  + wall[2] ],
106            [ button_dy_outer/2      ,  pbo  + wall[2] ],
107            [ button_dy_outer/2      ,  p[2]           ],
108            ]);
109 }  
110
111 module BraceProfileFinal(){
112   p = phone + phone_slop;
113   pbo = p[2] + button_dz_outer;
114   pbc = p[2] + button_dz_centre;
115   polygon([[ -1,                       p[2]           ],
116            [ -1,                       pbc  + wall[2] ],
117            [ 0,                        pbc  + wall[2] ],
118            [ 0,                        p[2]           ]
119            ]);
120 }  
121
122 module Brace(){
123   for (m=[0,1]) mirror([0,m,0]) {
124       hull(){
125         for (e=[0,1]) {
126           translate([ nrbutton_brace_x + e * phone[1]/2,
127                       0, 0 ]){
128             rotate([ 90,0,90 ]){
129               linear_extrude(height= (e==0 ? wall[0] : 0.1)){
130                 hull(){
131                   BraceProfileInitial();
132                   if (e==0) BraceProfileFinal();
133               }
134               }
135             }
136           }
137         }
138       }
139     }
140 }
141
142 module BoxMain(){
143   rotate([0,0,90]) rotate([90,0,0]) {
144     translate([0,0, expose])
145       linear_extrude(height = phone[0] + wall[0] - expose, convexity=20)
146       MainProfile();
147     translate([0,0, phone[0]])
148       linear_extrude(height = wall[0], convexity=20)
149       hull() MainProfile();
150   }
151 }
152
153 module PlugKeeperProfileHalf(){
154   p_max = plugkeeper_p_max;
155   p_min = plugkeeper_p_min;
156   d = plugkeeper_d_u * keeper_prong;
157   
158   translate([ plugkeeper_x_maxw, 0 ]) {
159     polygon([ p_min,
160               p_max,
161               p_max + d,
162               p_min + d ]);
163   }
164 }
165
166 module PlugKeeperStalkProfile(){
167   hull(){
168     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
169     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
170       square([ 0.1, keeper_stalk_basewidth ], center=true);
171   }
172 }
173
174 module PlugKeeper(){
175   for (m=[0,1]) mirror([0,m,0]) {
176       translate([0,0, -keeper_stalk_thick])
177         linear_extrude(height=plug_h + keeper_stalk_thick)
178         PlugKeeperProfileHalf();
179
180       translate([0, 0, plug_h - plug_tooth_h])
181         linear_extrude(height= plug_tooth_h)
182         translate(plugkeeper_d_u * -plug_tooth_dy)
183         PlugKeeperProfileHalf();
184
185     }
186 }
187
188 module Box(){
189   sidewall_cutout_z = phone[2] + phone_slop[2] + button_dz_outer;
190
191   difference(){
192     union(){
193       BoxMain();
194       Brace();
195     }
196
197     translate([ led[0], phone[1]/2 - led[1], 1 ])
198       rotate([0,0, 360/8/2])
199       cylinder(r = led_dia/2 / cos(360/8/2), h= phone[2]*2, $fn=8);
200
201     for (ys=[-1,+1]) {
202       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
203         linear_extrude(height = wall[2]*3)
204         PlugKeeperStalkProfile();
205
206       translate([ phone[0] + wall[0],
207                   ys * (cutout_between/2 + cutout_dia/2),
208                   -10 ])
209         cylinder( r= cutout_dia/2, h = 50, $fn = 20 );
210
211       translate([expose, ys*phone[1]/2, sidewall_cutout_z/2])
212         rotate([90,0,0])
213         translate([0,0,-3])
214         cylinder( r= sidewall_cutout_z/2 - 0.1, h=6 , $fn=20 );
215     }
216   }
217
218   PlugKeeper();
219
220   translate([0,0, -keeper_stalk_thick])
221     linear_extrude(height = keeper_stalk_thick)
222     PlugKeeperStalkProfile();
223
224   translate([ plugkeeper_x_maxw + keeper_stalk_len +
225                -keeper_stalk_base_reinforce_len/2,
226                -keeper_stalk_basewidth/2,
227                0 ])
228     mirror([0,0,1])
229     cube([ keeper_stalk_base_reinforce_len,
230            keeper_stalk_basewidth,
231            keeper_stalk_base_reinforce_thick ]);
232 }
233
234 module BoxPrint(){
235   // This makes' Cura's support more optimal: specifically,
236   // it then doesn't seem to touch the back (bottom) wall
237   translate([0,0,phone[0]])
238     rotate([0,90,0])
239     Box();
240 }
241
242 //MainProfileInnerHalf();
243 //MainProfile();
244 //translate([0,0,1]) color("black") BraceProfileInitial();
245 //translate([0,0,1]) color("black") BraceProfileFinal();
246 //Brace();
247 //Box();
248 BoxPrint();