chiark / gitweb /
90964cabbc3471b4202ad73d724d83d614c0da72
[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
34 // calculated
35
36 top_z = max( phone[2] + wall[2],
37              phone_button_z + minwall )
38   + phone_slop[2];
39
40 plugkeeper_x_maxw = phone[0] - plug_totlen;
41
42 plugkeeper_p_max = [ 0, plug_maxw/2 ];
43 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
44 plugkeeper_d_u = unitvector2d(
45                  clockwise2d(
46                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
47                              )
48                              );
49
50 module MainProfileInnerHalf(){
51   p = phone + phone_slop;
52   pb = phone_button_z + phone_slop[2];
53   polygon([[ -2,                 0    ],
54            [ p[1]/2,             0    ],
55            [ p[1]/2,             p[2] ],
56            [ button_dy_outer/2,  p[2] ],
57            [ button_dy_outer/2,  pb   ],
58            [ button_dy_inner/2,  pb   ],
59            [ button_dy_inner/2,  p[2] ],
60            [ button_dy_centre/2, p[2] ],
61            [ button_dy_centre/2, pb   ],
62            [ -2,                 pb   ]]);
63 }
64
65 module MainProfile(){
66   p = phone + phone_slop;
67   for (m=[0,1]) mirror([m,0]) {
68       difference(){
69         translate([-1, -wall[2] ])
70           square([ p[1]/2 + wall[1] + 1, top_z + wall[2] ]);
71         MainProfileInnerHalf();
72       }
73     }
74 }
75
76 module BoxMain(){
77   rotate([0,0,90]) rotate([90,0,0]) {
78     linear_extrude(height = phone[0] + wall[0], convexity=20)
79       MainProfile();
80     translate([0,0, phone[0]])
81       linear_extrude(height = wall[0], convexity=20)
82       hull() MainProfile();
83   }
84 }
85
86 module PlugKeeperProfileHalf(){
87   p_max = plugkeeper_p_max;
88   p_min = plugkeeper_p_min;
89   d = plugkeeper_d_u * keeper_prong;
90   
91   translate([ plugkeeper_x_maxw, 0 ]) {
92     polygon([ p_min,
93               p_max,
94               p_max + d,
95               p_min + d ]);
96   }
97 }
98
99 module PlugKeeperStalkProfile(){
100   hull(){
101     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
102     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
103       square([ 0.1, keeper_stalk_basewidth/2 ], center=true);
104   }
105 }
106
107 module PlugKeeper(){
108   for (m=[0,1]) mirror([0,m,0]) {
109       translate([0,0, -wall[2]])
110         linear_extrude(height=plug_h + wall[2])
111         PlugKeeperProfileHalf();
112
113       translate([0, 0, plug_h - plug_tooth_h])
114         linear_extrude(height= plug_tooth_h)
115         translate(plugkeeper_d_u * -plug_tooth_dy)
116         PlugKeeperProfileHalf();
117
118     }
119   %PlugKeeperStalkProfile();
120 }
121
122 module Box(){
123   difference(){
124     BoxMain();
125
126     translate([ led[0], phone[1]/2 - led[1], 1 ])
127       cylinder(r = led_dia/2, h= phone[2]*2, $fn=20);
128   }
129
130   PlugKeeper();
131 }
132
133 //MainProfileInner();
134 Box();
135