chiark / gitweb /
sleepphone-cable-box: new button arrangements
[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   difference(){
71     for (m=[0,1]) mirror([m,0]) {
72         minkowski(){
73           square(2 * [wall[1], wall[2]], center=true);
74           MainProfileInnerHalf();
75         }
76       }
77     for (m=[0,1]) mirror([m,0]) {
78         MainProfileInnerHalf();
79       }
80   }
81 }
82
83 module BoxMain(){
84   rotate([0,0,90]) rotate([90,0,0]) {
85     linear_extrude(height = phone[0] + wall[0], convexity=20)
86       MainProfile();
87     translate([0,0, phone[0]])
88       linear_extrude(height = wall[0], convexity=20)
89       hull() MainProfile();
90   }
91 }
92
93 module PlugKeeperProfileHalf(){
94   p_max = plugkeeper_p_max;
95   p_min = plugkeeper_p_min;
96   d = plugkeeper_d_u * keeper_prong;
97   
98   translate([ plugkeeper_x_maxw, 0 ]) {
99     polygon([ p_min,
100               p_max,
101               p_max + d,
102               p_min + d ]);
103   }
104 }
105
106 module PlugKeeperStalkProfile(){
107   hull(){
108     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
109     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
110       square([ 0.1, keeper_stalk_basewidth/2 ], center=true);
111   }
112 }
113
114 module PlugKeeper(){
115   for (m=[0,1]) mirror([0,m,0]) {
116       translate([0,0, -wall[2]])
117         linear_extrude(height=plug_h + wall[2])
118         PlugKeeperProfileHalf();
119
120       translate([0, 0, plug_h - plug_tooth_h])
121         linear_extrude(height= plug_tooth_h)
122         translate(plugkeeper_d_u * -plug_tooth_dy)
123         PlugKeeperProfileHalf();
124
125     }
126
127   translate([0,0, -wall[2]])
128     linear_extrude(height = wall[2])
129     PlugKeeperStalkProfile();
130 }
131
132 module Box(){
133   difference(){
134     BoxMain();
135
136     translate([ led[0], phone[1]/2 - led[1], 1 ])
137       cylinder(r = led_dia/2, h= phone[2]*2, $fn=20);
138
139     for (ys=[-1,+1])
140       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
141         linear_extrude(height = wall[2]*3)
142         PlugKeeperStalkProfile();
143   }
144
145   PlugKeeper();
146 }
147
148 //MainProfileInner();
149 Box();
150