chiark / gitweb /
sleepphone-cable-box: reinforce keeper
[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 - 2.00, 30.96, 6.00 ]; // includes socket
9 phone_button_z = 6.58;
10 minwall = 0.50;
11
12 cutout_dia = 7;
13 cutout_between = 5;
14
15 button_dz = 1.35;
16 button_dz_centre = 1.35;
17 button_dz_outer  = 1.35;
18
19 button_dy_outer = 28.42;
20 button_dy_inner = 19.05;
21 button_dy_centre = 5.65;
22
23 phone_slop = 0.5 * [1,1,0]
24            + 0.5 * [0,0,1];
25
26 led = [25.9, 9.44]; // y is from edge
27 led_dia = 4.4;
28
29 // next values include slop
30 plug_maxw = 10.95 + 0.35;
31 plug_minw=   6.53 + 0.35;
32 plug_sllen=  6.50;
33 plug_totlen = 84.90 + 1.5; // to maxw, including phone
34
35 plug_h = 6.5;
36 plug_tooth_h = 0.5;
37 plug_tooth_dy = 0.5;
38
39 keeper_prong = 2;
40 keeper_stalk_basewidth = 6;
41 keeper_stalk_len = 70;
42 keeper_stalk_gap = 1;
43 keeper_stalk_thick = wall_bot;
44
45 keeper_stalk_base_reinforce_len = 5;
46 keeper_stalk_base_reinforce_thick = 2.0;
47
48 // calculated
49
50 top_z = max( phone[2] + wall[2],
51              phone_button_z + minwall )
52   + phone_slop[2];
53
54 plugkeeper_x_maxw = phone[0] - plug_totlen;
55
56 plugkeeper_p_max = [ 0, plug_maxw/2 ];
57 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
58 plugkeeper_d_u = unitvector2d(
59                  clockwise2d(
60                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
61                              )
62                              );
63
64 module MainProfileInnerHalf(){
65   p = phone + phone_slop;
66   pbc = p[2] + button_dz_centre;
67   pbo = p[2] + button_dz_outer;
68   polygon([[ -2,                 0    ],
69            [ p[1]/2,             0    ],
70            [ p[1]/2,             p[2] ],
71            [ button_dy_outer/2,  p[2] ],
72            [ button_dy_outer/2,  pbo  ],
73            [ button_dy_inner/2,  pbo  ],
74            [ button_dy_inner/2,  p[2] ],
75            [ button_dy_centre/2, p[2] ],
76            [ button_dy_centre/2, pbc  ],
77            [ -2,                 pbc  ]]);
78 }
79
80 module MainProfile(){
81   p = phone + phone_slop;
82   difference(){
83     for (m=[0,1]) mirror([m,0]) {
84         minkowski(){
85           translate([ -wall[1], -wall_bot ])
86             square([ wall[1]*2, wall_bot + wall[2] ]);
87           MainProfileInnerHalf();
88         }
89       }
90     for (m=[0,1]) mirror([m,0]) {
91         MainProfileInnerHalf();
92       }
93   }
94 }
95
96 module BoxMain(){
97   rotate([0,0,90]) rotate([90,0,0]) {
98     linear_extrude(height = phone[0] + wall[0], convexity=20)
99       MainProfile();
100     translate([0,0, phone[0]])
101       linear_extrude(height = wall[0], convexity=20)
102       hull() MainProfile();
103   }
104 }
105
106 module PlugKeeperProfileHalf(){
107   p_max = plugkeeper_p_max;
108   p_min = plugkeeper_p_min;
109   d = plugkeeper_d_u * keeper_prong;
110   
111   translate([ plugkeeper_x_maxw, 0 ]) {
112     polygon([ p_min,
113               p_max,
114               p_max + d,
115               p_min + d ]);
116   }
117 }
118
119 module PlugKeeperStalkProfile(){
120   hull(){
121     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
122     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
123       square([ 0.1, keeper_stalk_basewidth ], center=true);
124   }
125 }
126
127 module PlugKeeper(){
128   for (m=[0,1]) mirror([0,m,0]) {
129       translate([0,0, -keeper_stalk_thick])
130         linear_extrude(height=plug_h + keeper_stalk_thick)
131         PlugKeeperProfileHalf();
132
133       translate([0, 0, plug_h - plug_tooth_h])
134         linear_extrude(height= plug_tooth_h)
135         translate(plugkeeper_d_u * -plug_tooth_dy)
136         PlugKeeperProfileHalf();
137
138     }
139 }
140
141 module Box(){
142   difference(){
143     BoxMain();
144
145     translate([ led[0], phone[1]/2 - led[1], 1 ])
146       rotate([0,0, 360/8/2])
147       cylinder(r = led_dia/2 / cos(360/8/2), h= phone[2]*2, $fn=8);
148
149     for (ys=[-1,+1]) {
150       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
151         linear_extrude(height = wall[2]*3)
152         PlugKeeperStalkProfile();
153
154       translate([ phone[0] + wall[0],
155                   ys * (cutout_between/2 + cutout_dia/2),
156                   -10 ])
157         cylinder( r= cutout_dia/2, h = 50, $fn = 20 );
158     }
159   }
160
161   PlugKeeper();
162
163   translate([0,0, -keeper_stalk_thick])
164     linear_extrude(height = keeper_stalk_thick)
165     PlugKeeperStalkProfile();
166
167   translate([ plugkeeper_x_maxw + keeper_stalk_len +
168                -keeper_stalk_base_reinforce_len/2,
169                -keeper_stalk_basewidth/2,
170                0 ])
171     mirror([0,0,1])
172     cube([ keeper_stalk_base_reinforce_len,
173            keeper_stalk_basewidth,
174            keeper_stalk_base_reinforce_thick ]);
175 }
176
177 module BoxPrint(){
178   // This makes' Cura's support more optimal: specifically,
179   // it then doesn't seem to touch the back (bottom) wall
180   translate([0,0,phone[0]])
181     rotate([0,90,0])
182     Box();
183 }
184
185 //MainProfileInnerHalf();
186 //MainProfile();
187 //Box();
188 BoxPrint();