chiark / gitweb /
sleepphone-cable-box: separate button_dz (nfc)
[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 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 // calculated
46
47 top_z = max( phone[2] + wall[2],
48              phone_button_z + minwall )
49   + phone_slop[2];
50
51 plugkeeper_x_maxw = phone[0] - plug_totlen;
52
53 plugkeeper_p_max = [ 0, plug_maxw/2 ];
54 plugkeeper_p_min = [ -plug_sllen, plug_minw/2 ];;
55 plugkeeper_d_u = unitvector2d(
56                  clockwise2d(
57                  vecdiff2d( plugkeeper_p_max, plugkeeper_p_min )
58                              )
59                              );
60
61 module MainProfileInnerHalf(){
62   p = phone + phone_slop;
63   pbc = p[2] + button_dz_centre;
64   pbo = p[2] + button_dz_outer;
65   polygon([[ -2,                 0    ],
66            [ p[1]/2,             0    ],
67            [ p[1]/2,             p[2] ],
68            [ button_dy_outer/2,  p[2] ],
69            [ button_dy_outer/2,  pbo  ],
70            [ button_dy_inner/2,  pbo  ],
71            [ button_dy_inner/2,  p[2] ],
72            [ button_dy_centre/2, p[2] ],
73            [ button_dy_centre/2, pbc  ],
74            [ -2,                 pbc  ]]);
75 }
76
77 module MainProfile(){
78   p = phone + phone_slop;
79   difference(){
80     for (m=[0,1]) mirror([m,0]) {
81         minkowski(){
82           translate([ -wall[1], -wall_bot ])
83             square([ wall[1]*2, wall_bot + wall[2] ]);
84           MainProfileInnerHalf();
85         }
86       }
87     for (m=[0,1]) mirror([m,0]) {
88         MainProfileInnerHalf();
89       }
90   }
91 }
92
93 module BoxMain(){
94   rotate([0,0,90]) rotate([90,0,0]) {
95     linear_extrude(height = phone[0] + wall[0], convexity=20)
96       MainProfile();
97     translate([0,0, phone[0]])
98       linear_extrude(height = wall[0], convexity=20)
99       hull() MainProfile();
100   }
101 }
102
103 module PlugKeeperProfileHalf(){
104   p_max = plugkeeper_p_max;
105   p_min = plugkeeper_p_min;
106   d = plugkeeper_d_u * keeper_prong;
107   
108   translate([ plugkeeper_x_maxw, 0 ]) {
109     polygon([ p_min,
110               p_max,
111               p_max + d,
112               p_min + d ]);
113   }
114 }
115
116 module PlugKeeperStalkProfile(){
117   hull(){
118     for (m=[0,1]) mirror([0,m,0]) PlugKeeperProfileHalf();
119     translate([ plugkeeper_x_maxw + keeper_stalk_len, 0,0 ])
120       square([ 0.1, keeper_stalk_basewidth ], center=true);
121   }
122 }
123
124 module PlugKeeper(){
125   for (m=[0,1]) mirror([0,m,0]) {
126       translate([0,0, -keeper_stalk_thick])
127         linear_extrude(height=plug_h + keeper_stalk_thick)
128         PlugKeeperProfileHalf();
129
130       translate([0, 0, plug_h - plug_tooth_h])
131         linear_extrude(height= plug_tooth_h)
132         translate(plugkeeper_d_u * -plug_tooth_dy)
133         PlugKeeperProfileHalf();
134
135     }
136 }
137
138 module Box(){
139   difference(){
140     BoxMain();
141
142     translate([ led[0], phone[1]/2 - led[1], 1 ])
143       rotate([0,0, 360/8/2])
144       cylinder(r = led_dia/2 / cos(360/8/2), h= phone[2]*2, $fn=8);
145
146     for (ys=[-1,+1]) {
147       translate([ -0.1, ys * keeper_stalk_gap, -wall[2]*2])
148         linear_extrude(height = wall[2]*3)
149         PlugKeeperStalkProfile();
150
151       translate([ phone[0] + wall[0],
152                   ys * (cutout_between/2 + cutout_dia/2),
153                   -10 ])
154         cylinder( r= cutout_dia/2, h = 50, $fn = 20 );
155     }
156   }
157
158   PlugKeeper();
159
160   translate([0,0, -keeper_stalk_thick])
161     linear_extrude(height = keeper_stalk_thick)
162     PlugKeeperStalkProfile();
163 }
164
165 module BoxPrint(){
166   // This makes' Cura's support more optimal: specifically,
167   // it then doesn't seem to touch the back (bottom) wall
168   rotate([0,90,0])
169     Box();
170 }
171
172 //MainProfileInnerHalf();
173 //MainProfile();
174 //Box();
175 BoxPrint();