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