chiark / gitweb /
sleepphone-cable-box: wip, keeper, etc.
[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 ];
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 keeper_prong = 2;
27
28 // calculated
29
30 top_z = max( phone[2] + wall[2],
31              phone_button_z + minwall )
32   + phone_slop[2];
33
34 plugkeeper_x_maxw = phone[0] - plug_totlen;
35
36 module MainProfileInnerHalf(){
37   p = phone + phone_slop;
38   pb = phone_button_z + phone_slop[2];
39   polygon([[ -2,                 0    ],
40            [ p[1]/2,             0    ],
41            [ p[1]/2,             p[2] ],
42            [ button_dy_outer/2,  p[2] ],
43            [ button_dy_outer/2,  pb   ],
44            [ button_dy_inner/2,  pb   ],
45            [ button_dy_inner/2,  p[2] ],
46            [ button_dy_centre/2, p[2] ],
47            [ button_dy_centre/2, pb   ],
48            [ -2,                 pb   ]]);
49 }
50
51 module MainProfile(){
52   p = phone + phone_slop;
53   for (m=[0,1]) mirror([m,0]) {
54       difference(){
55         translate([-1, -wall[2] ])
56           square([ p[1]/2 + wall[1] + 1, top_z + wall[2] ]);
57         MainProfileInnerHalf();
58       }
59     }
60 }
61
62 module BoxMain(){
63   rotate([0,0,90]) rotate([90,0,0]) {
64     linear_extrude(height = phone[0] + wall[0], convexity=20)
65       MainProfile();
66     translate([0,0, phone[0]])
67       linear_extrude(height = wall[0], convexity=20)
68       hull() MainProfile();
69   }
70 }
71
72 module PlugKeeperProfile(){
73   p_max = [ 0, plug_maxw/2 ];
74   p_min = [ -plug_sllen, plug_minw/2 ];
75   d = unitvector2d(clockwise2d(vecdiff2d(p_min, p_max))) * keeper_prong;
76   
77   translate([ plugkeeper_x_maxw, 0 ]) {
78     polygon([ p_min,
79               p_max,
80               p_max + d,
81               p_min + d ]);
82   }
83 }
84
85 module Box(){
86   difference(){
87     BoxMain();
88
89     translate([ led[0], phone[1]/2 - led[1], 1 ])
90       cylinder(r = led_dia/2, h= phone[2]*2, $fn=20);
91   }
92 }
93
94 //MainProfileInner();
95 Box();
96 linear_extrude(h=1) PlugKeeperProfile();