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