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