chiark / gitweb /
sleepphone-cable-box: note from v1, wip
[reprap-play.git] / sleepphone-cable-box.scad
1 // -*- C -*-
2
3 include <funcs.scad>
4
5 wall = 0.75 * [1,1,1];
6 phone = [ 76.40, 30.96, 6.00 ]; // includes socket
7 phone_button_z = 6.58;
8 minwall = 0.50;
9
10 button_dz = 1.35;
11
12 button_dy_outer = 28.42;
13 button_dy_inner = 19.05;
14 button_dy_centre = 5.65;
15
16 phone_slop = 0.5 * [1,1,0]
17            + 0.5 * [0,0,1];
18
19 led = [25.9, 9.44]; // y is from edge
20 led_dia = 4.4;
21
22 // next values include slop
23 plug_maxw = 10.95 + 0.35;
24 plug_minw=   6.53 + 0.35;
25 plug_sllen=  6.50;
26 plug_totlen = 84.90; // to maxw, including phone
27
28 plug_h = 6.5;
29 plug_tooth_h = 0.5;
30 plug_tooth_dy = 0.5;
31
32 keeper_prong = 2;
33 keeper_stalk_basewidth = 4;
34 keeper_stalk_len = 70;
35 keeper_stalk_gap = 2;
36
37 // calculated
38
39 top_z = max( phone[2] + wall[2],
40              phone_button_z + minwall )
41   + phone_slop[2];
42
43 plugkeeper_x_maxw = phone[0] - plug_totlen;
44
45 plugkeeper_p_max = [ 0, plug_maxw/2 ];
46 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
47 plugkeeper_d_u = unitvector2d(
48                  clockwise2d(
49                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
50                              )
51                              );
52
53 module MainProfileInnerHalf(){
54   p = phone + phone_slop;
55   pb = phone_button_z + phone_slop[2];
56   polygon([[ -2,                 0    ],
57            [ p[1]/2,             0    ],
58            [ p[1]/2,             p[2] ],
59            [ button_dy_outer/2,  p[2] ],
60            [ button_dy_outer/2,  pb   ],
61            [ button_dy_inner/2,  pb   ],
62            [ button_dy_inner/2,  p[2] ],
63            [ button_dy_centre/2, p[2] ],
64            [ button_dy_centre/2, pb   ],
65            [ -2,                 pb   ]]);
66 }
67
68 module MainProfile(){
69   p = phone + phone_slop;
70   for (m=[0,1]) mirror([m,0]) {
71       difference(){
72         translate([-1, -wall[2] ])
73           square([ p[1]/2 + wall[1] + 1, top_z + wall[2] ]);
74         MainProfileInnerHalf();
75       }
76     }
77 }
78
79 module BoxMain(){
80   rotate([0,0,90]) rotate([90,0,0]) {
81     linear_extrude(height = phone[0] + wall[0], convexity=20)
82       MainProfile();
83     translate([0,0, phone[0]])
84       linear_extrude(height = wall[0], convexity=20)
85       hull() MainProfile();
86   }
87 }
88
89 module PlugKeeperProfileHalf(){
90   p_max = plugkeeper_p_max;
91   p_min = plugkeeper_p_min;
92   d = plugkeeper_d_u * keeper_prong;
93   
94   translate([ plugkeeper_x_maxw, 0 ]) {
95     polygon([ p_min,
96               p_max,
97               p_max + d,
98               p_min + d ]);
99   }
100 }
101
102 module PlugKeeperStalkProfile(){
103   hull(){
104     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
105     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
106       square([ 0.1, keeper_stalk_basewidth/2 ], center=true);
107   }
108 }
109
110 module PlugKeeper(){
111   for (m=[0,1]) mirror([0,m,0]) {
112       translate([0,0, -wall[2]])
113         linear_extrude(height=plug_h + wall[2])
114         PlugKeeperProfileHalf();
115
116       translate([0, 0, plug_h - plug_tooth_h])
117         linear_extrude(height= plug_tooth_h)
118         translate(plugkeeper_d_u * -plug_tooth_dy)
119         PlugKeeperProfileHalf();
120
121     }
122
123   translate([0,0, -wall[2]])
124     linear_extrude(height = wall[2])
125     PlugKeeperStalkProfile();
126 }
127
128 module Box(){
129   difference(){
130     BoxMain();
131
132     translate([ led[0], phone[1]/2 - led[1], 1 ])
133       cylinder(r = led_dia/2, h= phone[2]*2, $fn=20);
134
135     for (ys=[-1,+1])
136       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
137         linear_extrude(height = wall[2]*3)
138         PlugKeeperStalkProfile();
139   }
140
141   PlugKeeper();
142 }
143
144 //MainProfileInner();
145 Box();
146