chiark / gitweb /
anke-gps-bracket: NestleCube: add doveclip
[reprap-play.git] / anke-gps-bracket.scad
1 // -*- C -*-
2
3 include <doveclip.scad>
4
5 // Dimensions of the main GPS body
6 outerw = 120 + 2.5;
7 outerh =  75 - 0.2;
8 outert =  15 - 1.0;
9 outerbackbevel = 3;
10
11 // Dimensions of the bezel area round the edges
12 bezelw =    11 - 0.5;
13 bezelboth = 11 - 0.5;
14 bezeltoph =  7 - 0.5;
15
16 // Dimensions of the speaker at the back
17 spkrdia =  22;
18 spkr2bot = 19;
19 spkr2rhs = 25;
20
21 // Dimensions of the plug and wire
22 plugw =      12;
23 plugh =       9;
24 plug2bot =   11;
25 plug2lhs =   11;
26 plugtotald = 15;
27 pluggapd =    5;
28
29 // Dimensions of the hole in the tray
30 //   width and height (vertical) at the top
31 nestleh = 53;
32 nestlew = 55.4 - 0.5;
33 //   depths (back to front distance):
34 nestledl = 38.8 - 0.5;
35 nestledr = 42.7 - 0.5;
36 //   differences in width, depth, at bottom:
37 nestledwl = 3.0;
38 nestledwr = 2.4;
39 nestleddf = 4.0;
40 nestleddbl = 3.3;
41 nestleddbr = 3.6;
42
43 nestlewallmin = 4;
44 nestleceilmin = 4;
45
46 // Adjustment for the GPS attitude
47 gpsazimuth = 45;
48 gpsrightwardoffset = 5;
49 gpsrearwardoffset = 2;
50
51 // Amount of wire protrusion to allow for
52 plugwiremoreh = 25;
53
54 // Slops and steps etc.
55 plugslop = 0.5;
56 plughstep = 1.5;
57 bodylhsrhsslop = 0.5;
58
59 // Dimensions for strength only
60 screent = 1.0;
61 plugstrutw = 4;
62 plugstrutt = min(outert, 5);
63 nestledoveclipw = 20;
64
65 module GpsPlugPlug(slop){
66   effhslop = slop - plughstep;
67   effplugw = plugw + slop*2;
68   effplugh = plugh + effhslop*2;
69   translate([plug2lhs-slop, plug2bot-effhslop, -1])
70     cube([effplugw, effplugh, outert+2]);
71 }
72
73 module GpsBodyOuterBevel(len){
74   translate([0,-1,0]) {
75     rotate([-90,0,0]) {
76       linear_extrude(height=len+2) {
77         polygon([[-outerbackbevel, 0],
78                  [ 0, outerbackbevel],
79                  [outerbackbevel, 0],
80                  [ 0, -outerbackbevel]]);
81       }
82     }
83   }
84 }
85
86 module GpsBody() { ////toplevel
87   difference(){
88     union(){
89       difference(){
90         cube([outerw, outerh, outert]);
91         translate([bezelw, bezelboth, screent])
92           cube([outerw-bezelw*2, outerh-bezelboth-bezeltoph, outert]);
93         translate([outerw-spkr2rhs, spkr2bot, -1])
94           cylinder(r=spkrdia/2, h=outert+2);
95       }
96       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
97         cylinder(r=(plugw+plugh)/2, h=outert);
98       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
99         translate([x, 0.1, 0])
100           cube([plugstrutw, outerh-0.2, plugstrutt-0.10]);
101     }
102     GpsPlugPlug(0);
103     for (x=[0,outerw]) translate([x,0,0]) GpsBodyOuterBevel(outerh);
104     for (y=[0,outerh]) translate([0,y,0])
105       rotate([0,0,-90]) GpsBodyOuterBevel(outerw);
106   }
107 }
108
109 module GpsPlug() {
110   plugwireh = plug2bot + plugwiremoreh;
111   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
112   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
113     cube([plugw, plugh, plugtotald-0.05]);
114     translate([0, -plugwireh, pluggapd])
115       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
116   }
117 }
118
119 lhsteethu = 2;
120
121 module GpsLHSMask(xslop=0){
122   translate([plug2lhs + plugw+plugh+plugstrutw,
123              0,
124              -50]) {
125     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
126       translate([0, iter*lhsteethu*2, 0]) {
127         linear_extrude(height=100) {
128           polygon([[-300,     0],
129                    [   0,     0],
130                    [lhsteethu,lhsteethu],
131                    [   0,     lhsteethu*2],
132                    [-300,     lhsteethu*2+0.1]]);
133         }
134       }
135     }
136   }
137 }
138
139 module GpsAssembled(){ ////toplevel
140   GpsBody();
141   GpsPlug();
142 }
143
144 module GpsBodyLT(){
145   intersection(){
146     GpsBody();
147     GpsLHSMask();
148   }
149 }
150
151 module GpsBodyRT(){
152   difference(){
153     GpsBody();
154     GpsLHSMask(bodylhsrhsslop);
155   }
156 }
157
158 module GpsPlugT(){ ////toplevel
159   rotate([0,-90,0]) GpsPlug();
160 }
161
162 module NestleCubeCutout(ca,cb,d){
163   dist = cb - ca;
164   mirror([0,1,0]){
165     rotate([90,0,0]){
166       linear_extrude(height=d){
167         polygon([[ca, -nestleh-1],
168                  [ca, -dist/2],
169                  [(ca+cb)/2, 0],
170                  [cb, -dist/2],
171                  [cb, -nestleh-1]]);
172       }
173     }
174   }
175 }
176
177 module NestleCube(){
178   midw = nestlew/2;
179   midd = min(nestledl,nestledr);
180   midddb = max(nestleddbl,nestleddbr);
181
182   based0 = nestleddf;
183   based1 = midd - midddb;
184   basew0 = -nestledwr;
185   basew1 = +nestledwl-nestlew;
186
187   cutd0 = based0 + nestlewallmin;
188   cutd1 = based1 - nestlewallmin;
189   cutw0 = basew0 - nestlewallmin;
190   cutw1 = basew1 + nestlewallmin;
191
192   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) difference(){
193     polyhedron
194       (points=[[          +0      ,            +0,        0], // 0
195                [          +0      ,            +nestledr, 0], // 1
196                [          -midw   ,            +midd,     0], // 2
197                [          -nestlew,            +nestledl, 0], // 3
198                [          -nestlew,            +0,        0], // 4
199                [-nestledwr+0      , +nestleddf +0,        -nestleh], // 5
200                [-nestledwr+0      , -nestleddbr+nestledr, -nestleh], // 6
201                [          -midw   , -midddb    +midd,     -nestleh], // 7
202                [+nestledwl-nestlew, -nestleddbl+nestledl, -nestleh], // 8
203                [+nestledwl-nestlew, +nestleddf +0,        -nestleh]], // 9
204        triangles=[[0,1,6],[6,5,0],
205                   [1,2,7],[7,6,1],
206                   [2,3,8],[8,7,2],
207                   [3,4,9],[9,8,3],
208                   [4,0,5],[5,9,4],
209                   [4,3,2],[2,1,0],[0,4,2],
210                   [7,8,9],[5,6,7],[7,9,5]],
211        convexity=3);
212     intersection(){
213       NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
214       rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
215     }
216   }
217
218   translate([gpsrightwardoffset,-gpsrearwardoffset,0])
219     rotate([0,0,gpsazimuth])
220     translate([nestledoveclipw/2,0,DoveClip_depth()-0.5])
221     rotate([0,-90,0])
222     DoveClipPairSane(count=3, h=nestledoveclipw);
223 }
224
225 //GpsPlugT();
226 //GpsAssembled();
227 //GpsBody();
228
229 NestleCube();