chiark / gitweb /
95a1aa7f1708a34c56eab9da93e8c2e9dd2d9c65
[reprap-play.git] / digispark-with-cable.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 //tongue_w = 11.92 + 0.4;
6
7 usb_w = 12.01 + 0.19;
8 usb_wall_w = 0.51;
9 usb_tongue_d = 8.97 - 0.2;
10 usb_tongue_w_slop = +0.5;
11 usb_wall_h = 4.54 - 2.04;
12 usb_ceil_th = 0.425;
13
14 side_wall_th = 1.5;
15
16 board_l = 17.56 + 0.2;
17 board_w = 19.14 + 0.2;
18 board_th = 1.92 + 0.1;
19
20 sw_to_edge = board_w/2 + 0.1;
21
22 front_wall_th = 0.75;
23 // egress_w = 8.0;
24
25 wall_y_min = -board_l - side_wall_th; // XXXX remove
26 main_y_min = -board_l - side_wall_th;
27 ceil_y_min = wall_y_min - 5;;
28
29 small_walls = [
30                [ [0, 0], [-sw_to_edge, -1.0] ],
31                [ [sw_to_edge-4.5, -4.5], [sw_to_edge, -5.7] ],
32 //             [ [3.0, -11.72],              [sw_to_edge, -13.38] ],
33                [ [-sw_to_edge+3.85, -14.90], [sw_to_edge, -13.38] ],
34                ];
35 chip_cutout = [[ -sw_to_edge + 4.20,    -3.75 ],
36                [ -sw_to_edge + 11.95,  -11.90 ]];
37
38 strain_w = 2.0 + 0.5;
39 strain_t = 1.0 + 0.5;
40 strain_pitch_across = 5;
41 strain_pitch_along = 10;
42 strain_groove_d = 2;
43 strain_groove_w = 3;
44
45 cable_space_z = 6;
46 bottom_floor_th = 1.5;
47
48 fit_gap_z = 0.5;
49
50 // calculated
51
52 top_top_z = usb_wall_h;
53 top_base_z = -board_th;
54 bottom_base_z = top_base_z - cable_space_z - bottom_floor_th;;
55
56 front_y_max = front_wall_th;
57
58 strain_0_y_c = main_y_min - strain_w/2;
59 strain_1_y_c = strain_0_y_c - strain_pitch_along;
60 total_y_min = strain_1_y_c - strain_w/2 - side_wall_th;
61
62 bottom_wall_top_z = (top_top_z + top_base_z) * 0.5 - fit_gap_z/2;
63 cover_wall_top_z  = (top_top_z + top_base_z) * 0.5 + fit_gap_z/2;
64
65 top_side_wall_x = +board_w/2 + side_wall_th;
66
67 module BothSides(){
68   for (m=[0,1]) {
69     mirror([m,0]) {
70       children();
71     }
72   }
73 }
74 module FrontWallsPlan(slop) {
75   BothSides(){
76     rectfromto([ -board_w/2 - side_wall_th,    0             ],
77                [ -usb_w/2 - slop,              front_wall_th ]);
78   }
79 }
80 module TopSmallWallsPlan() {
81   for (m=[0,1]) {
82     mirror([m,0]) {
83       rectfromto([ -usb_w/2,              -0.01        ],
84                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
85     }
86   }
87   FrontWallsPlan(0);
88   for (w=small_walls) {
89     rectfromto(w[0], w[1]);
90   }
91 }
92 module TopCeilPlan() {
93   difference(){
94     BothSides(){
95       rectfromto([ -usb_w/2,              -0.01        ],
96                  [ 0.1,                   usb_tongue_d ]);
97       rectfromto([ -board_w/2 - side_wall_th, 0            ],
98                  [ 0.1,                       ceil_y_min   ]);
99     }
100     rectfromto(chip_cutout[0], chip_cutout[1]);
101   }
102 }
103 module TopMainWallsPlan() {
104   BothSides(){
105     rectfromto([ -board_w/2 - side_wall_th, 0          ],
106                [ -board_w/2,                wall_y_min ]);
107   }
108   FrontWallsPlan(usb_tongue_w_slop);
109   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
110              [ +board_w/2 + side_wall_th,            total_y_min ]);
111 }
112
113 module Top(){ ////toplevel
114   difference(){
115     union(){
116       linextr(0, usb_wall_h)
117         TopSmallWallsPlan();
118       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
119         TopCeilPlan();
120       linextr(-board_th, usb_wall_h)
121         TopMainWallsPlan();
122     }
123
124     for (y_c = [strain_0_y_c, strain_1_y_c]) {
125       for (x_c = [-1,+1] * strain_pitch_across/2) {
126         translate([x_c, y_c, 0])
127           linextr(-20, 20)
128           square([ strain_t, strain_w ], center=true);
129       }
130     }
131     linextr_y_xz(total_y_min-1, main_y_min)
132       translate([0, top_base_z])
133       scale([1, strain_groove_d/strain_groove_w])
134       circle(strain_groove_w/2, $fn = 8);
135   }
136 }
137
138 module BottomMainElevation(){ ////toplevel
139   difference(){
140     rectfromto([ -top_side_wall_x, bottom_base_z ],
141                [ +top_side_wall_x, top_base_z    ]);
142   }
143 }
144 module Bottom(){ ////toplevel
145   linextr_y_xz(total_y_min, front_y_max)
146     BottomMainElevation();
147 }
148
149 module BottomDemo(){ ////toplevel
150   Bottom();
151   translate([0, 0, 0.25]) %Top();
152 }