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