chiark / gitweb /
e1f018224b379f28e24e6a0d1e1d0468dd9314ab
[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 phone_slop = 0.5 * [1,1,0]
26            + 0.5 * [0,0,1];
27
28 led = [25.9, 9.44]; // y is from edge
29 led_dia = 4.4;
30
31 // next values include slop
32 plug_maxw = 10.95 + 0.35;
33 plug_minw=   6.53 + 0.35;
34 plug_sllen=  6.50;
35 plug_totlen = 84.90 + 1.5; // to maxw, including phone
36
37 plug_h = 6.5;
38 plug_tooth_h = 0.5;
39 plug_tooth_dy = 0.5;
40
41 keeper_prong = 2;
42 keeper_stalk_basewidth = 6;
43 keeper_stalk_len = 70;
44 keeper_stalk_gap = 1;
45 keeper_stalk_thick = wall_bot;
46
47 keeper_stalk_base_reinforce_len = 5;
48 keeper_stalk_base_reinforce_thick = 2.0;
49
50 // calculated
51
52 top_z = max( phone[2] + wall[2],
53              phone_button_z + minwall )
54   + phone_slop[2];
55
56 plugkeeper_x_maxw = phone[0] - plug_totlen;
57
58 plugkeeper_p_max = [ 0, plug_maxw/2 ];
59 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
60 plugkeeper_d_u = unitvector2d(
61                  clockwise2d(
62                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
63                              )
64                              );
65
66 module MainProfileInnerHalf(){
67   p = phone + phone_slop;
68   pbc = p[2] + button_dz_centre;
69   pbo = p[2] + button_dz_outer;
70   polygon([[ -2,                 0    ],
71            [ p[1]/2,             0    ],
72            [ p[1]/2,             p[2] ],
73            [ button_dy_outer/2,  p[2] ],
74            [ button_dy_outer/2,  pbo  ],
75            [ button_dy_inner/2,  pbo  ],
76            [ button_dy_inner/2,  p[2] ],
77            [ button_dy_centre/2, p[2] ],
78            [ button_dy_centre/2, pbc  ],
79            [ -2,                 pbc  ]]);
80 }
81
82 module MainProfile(){
83   p = phone + phone_slop;
84   difference(){
85     for (m=[0,1]) mirror([m,0]) {
86         minkowski(){
87           translate([ -wall[1], -wall_bot ])
88             square([ wall[1]*2, wall_bot + wall[2] ]);
89           MainProfileInnerHalf();
90         }
91       }
92     for (m=[0,1]) mirror([m,0]) {
93         MainProfileInnerHalf();
94       }
95   }
96 }
97
98 module BoxMain(){
99   rotate([0,0,90]) rotate([90,0,0]) {
100     translate([0,0, expose])
101       linear_extrude(height = phone[0] + wall[0] - expose, convexity=20)
102       MainProfile();
103     translate([0,0, phone[0]])
104       linear_extrude(height = wall[0], convexity=20)
105       hull() MainProfile();
106   }
107 }
108
109 module PlugKeeperProfileHalf(){
110   p_max = plugkeeper_p_max;
111   p_min = plugkeeper_p_min;
112   d = plugkeeper_d_u * keeper_prong;
113   
114   translate([ plugkeeper_x_maxw, 0 ]) {
115     polygon([ p_min,
116               p_max,
117               p_max + d,
118               p_min + d ]);
119   }
120 }
121
122 module PlugKeeperStalkProfile(){
123   hull(){
124     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
125     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
126       square([ 0.1, keeper_stalk_basewidth ], center=true);
127   }
128 }
129
130 module PlugKeeper(){
131   for (m=[0,1]) mirror([0,m,0]) {
132       translate([0,0, -keeper_stalk_thick])
133         linear_extrude(height=plug_h + keeper_stalk_thick)
134         PlugKeeperProfileHalf();
135
136       translate([0, 0, plug_h - plug_tooth_h])
137         linear_extrude(height= plug_tooth_h)
138         translate(plugkeeper_d_u * -plug_tooth_dy)
139         PlugKeeperProfileHalf();
140
141     }
142 }
143
144 module Box(){
145   sidewall_cutout_z = phone[2] + phone_slop[2] + button_dz_outer;
146
147   difference(){
148     BoxMain();
149
150     translate([ led[0], phone[1]/2 - led[1], 1 ])
151       rotate([0,0, 360/8/2])
152       cylinder(r = led_dia/2 / cos(360/8/2), h= phone[2]*2, $fn=8);
153
154     for (ys=[-1,+1]) {
155       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
156         linear_extrude(height = wall[2]*3)
157         PlugKeeperStalkProfile();
158
159       translate([ phone[0] + wall[0],
160                   ys * (cutout_between/2 + cutout_dia/2),
161                   -10 ])
162         cylinder( r= cutout_dia/2, h = 50, $fn = 20 );
163
164       translate([expose, ys*phone[1]/2, sidewall_cutout_z/2])
165         rotate([90,0,0])
166         translate([0,0,-3])
167         cylinder( r= sidewall_cutout_z/2 - 0.1, h=6 , $fn=20 );
168     }
169   }
170
171   PlugKeeper();
172
173   translate([0,0, -keeper_stalk_thick])
174     linear_extrude(height = keeper_stalk_thick)
175     PlugKeeperStalkProfile();
176
177   translate([ plugkeeper_x_maxw + keeper_stalk_len +
178                -keeper_stalk_base_reinforce_len/2,
179                -keeper_stalk_basewidth/2,
180                0 ])
181     mirror([0,0,1])
182     cube([ keeper_stalk_base_reinforce_len,
183            keeper_stalk_basewidth,
184            keeper_stalk_base_reinforce_thick ]);
185 }
186
187 module BoxPrint(){
188   // This makes' Cura's support more optimal: specifically,
189   // it then doesn't seem to touch the back (bottom) wall
190   translate([0,0,phone[0]])
191     rotate([0,90,0])
192     Box();
193 }
194
195 //MainProfileInnerHalf();
196 //MainProfile();
197 //Box();
198 BoxPrint();