chiark / gitweb /
sleepphone-cable-box: attempt at cutout, before rework
[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 cutout_depth = 5;
13
14 button_dz = 1.35;
15
16 button_dy_outer = 28.42;
17 button_dy_inner = 19.05;
18 button_dy_centre = 5.65;
19
20 phone_slop = 0.5 * [1,1,0]
21            + 0.5 * [0,0,1];
22
23 led = [25.9, 9.44]; // y is from edge
24 led_dia = 4.4;
25
26 // next values include slop
27 plug_maxw = 10.95 + 0.35;
28 plug_minw=   6.53 + 0.35;
29 plug_sllen=  6.50;
30 plug_totlen = 84.90 - 1.5; // to maxw, including phone
31
32 plug_h = 6.5;
33 plug_tooth_h = 0.5;
34 plug_tooth_dy = 0.5;
35
36 keeper_prong = 2;
37 keeper_stalk_basewidth = 4;
38 keeper_stalk_len = 70;
39 keeper_stalk_gap = 2;
40 keeper_stalk_thick = wall_bot;
41
42 // calculated
43
44 top_z = max( phone[2] + wall[2],
45              phone_button_z + minwall )
46   + phone_slop[2];
47
48 plugkeeper_x_maxw = phone[0] - plug_totlen;
49
50 plugkeeper_p_max = [ 0, plug_maxw/2 ];
51 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
52 plugkeeper_d_u = unitvector2d(
53                  clockwise2d(
54                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
55                              )
56                              );
57
58 module MainProfileInnerHalf(){
59   p = phone + phone_slop;
60   pb = p[2] + button_dz;
61   polygon([[ -2,                 0    ],
62            [ p[1]/2,             0    ],
63            [ p[1]/2,             p[2] ],
64            [ button_dy_outer/2,  p[2] ],
65            [ button_dy_outer/2,  pb   ],
66            [ button_dy_inner/2,  pb   ],
67            [ button_dy_inner/2,  p[2] ],
68            [ button_dy_centre/2, p[2] ],
69            [ button_dy_centre/2, pb   ],
70            [ -2,                 pb   ]]);
71 }
72
73 module MainProfile(){
74   p = phone + phone_slop;
75   difference(){
76     for (m=[0,1]) mirror([m,0]) {
77         minkowski(){
78           translate([ -wall[1], -wall_bot ])
79             square([ wall[1]*2, wall_bot + wall[2] ]);
80           MainProfileInnerHalf();
81         }
82       }
83     for (m=[0,1]) mirror([m,0]) {
84         MainProfileInnerHalf();
85       }
86   }
87 }
88
89 module BoxMain(){
90   rotate([0,0,90]) rotate([90,0,0]) {
91     linear_extrude(height = phone[0] + wall[0], convexity=20)
92       MainProfile();
93     translate([0,0, phone[0]])
94       linear_extrude(height = wall[0], convexity=20)
95       hull() MainProfile();
96   }
97 }
98
99 module PlugKeeperProfileHalf(){
100   p_max = plugkeeper_p_max;
101   p_min = plugkeeper_p_min;
102   d = plugkeeper_d_u * keeper_prong;
103   
104   translate([ plugkeeper_x_maxw, 0 ]) {
105     polygon([ p_min,
106               p_max,
107               p_max + d,
108               p_min + d ]);
109   }
110 }
111
112 module PlugKeeperStalkProfile(){
113   hull(){
114     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
115     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
116       square([ 0.1, keeper_stalk_basewidth ], center=true);
117   }
118 }
119
120 module PlugKeeper(){
121   for (m=[0,1]) mirror([0,m,0]) {
122       translate([0,0, -keeper_stalk_thick])
123         linear_extrude(height=plug_h + keeper_stalk_thick)
124         PlugKeeperProfileHalf();
125
126       translate([0, 0, plug_h - plug_tooth_h])
127         linear_extrude(height= plug_tooth_h)
128         translate(plugkeeper_d_u * -plug_tooth_dy)
129         PlugKeeperProfileHalf();
130
131     }
132 }
133
134 module KeeperProjection(){
135   projection()
136     rotate([0,90,0])
137     linear_extrude(height= 20)
138     projection()
139     PlugKeeper();
140 }
141
142 module Box(){
143   difference(){
144     BoxMain();
145
146     translate([ led[0], phone[1]/2 - led[1], 1 ])
147       cylinder(r = led_dia/2, h= phone[2]*2, $fn=20);
148
149     for (ys=[-1,+1])
150       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
151         linear_extrude(height = wall[2]*3)
152         PlugKeeperStalkProfile();
153
154     translate([ phone[0] - cutout_depth,
155                 0,
156                 -10 ])
157       linear_extrude(height=50)
158       KeeperProjection();
159   }
160
161   PlugKeeper();
162
163   translate([0,0, -keeper_stalk_thick])
164     linear_extrude(height = keeper_stalk_thick)
165     PlugKeeperStalkProfile();
166 }
167
168 //MainProfileInnerHalf();
169 //MainProfile();
170 //KeeperProjection();
171 Box();
172