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