]> git.scottworley.com Git - tattlekey/blob - housing/tattlekey.scad
housing: Grip board tighter
[tattlekey] / housing / tattlekey.scad
1 use <cherryVoid.scad>
2
3 key_interface_size = 18;
4 key_interface_corner_r = 5;
5 key_interface_thickness = 1.484;
6
7 // Chosen to let board fit inside
8 housing_inner_h = 6;
9 housing_inner_w = 21;
10 housing_flat = 8;
11
12 thickness = 1.7;
13
14 board_gap = 0.125;
15
16 wiring_l = 12;
17 extra_flare = wiring_l;
18
19 pico_board_l = 51.0;
20 pico_board_w = 21.0;
21 pico_board_h = 1.0;
22 pico_total_h = 3.7;
23
24 $fs = .1;
25 $fa = 3;
26
27 slop = 128;
28 epsilon = 1/64;
29
30 module pico_hole(d, x, y) {
31 translate([x, y, -slop/2])
32 cylinder(h=slop, d = d);
33 }
34
35 module pico_board(gap = 0) {
36 translate([-gap, 0, -gap])
37 cube([pico_board_l + 2*gap, pico_board_w, pico_board_h + 2*gap]);
38 }
39
40 module pico_w(hole_d = 2.1) {
41 // Dimensions from measuring and/or
42 // https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf
43 board_l = pico_board_l;
44 board_w = pico_board_w;
45
46 hole_x1 = 2.0;
47 hole_x2 = board_l - 2.0;
48 hole_y_spacing = 11.4;
49 hole_y = (board_w - hole_y_spacing)/2;
50
51 difference() {
52 color("green")
53 pico_board();
54
55 pico_hole(hole_d, hole_x1, hole_y);
56 pico_hole(hole_d, hole_x2, hole_y);
57 pico_hole(hole_d, hole_x1, hole_y + hole_y_spacing);
58 pico_hole(hole_d, hole_x2, hole_y + hole_y_spacing);
59
60 }
61
62 total_l = 52.3;
63 total_h = pico_total_h;
64 usb_w = 8.0;
65 usb_l = 5.6;
66 usb_h = 3.0;
67 color("lightgray")
68 translate([board_l - total_l, (board_w-usb_w)/2, total_h-usb_h])
69 cube([usb_l, usb_w, usb_h]);
70
71 button_l = 4.2;
72 button_w = 3.4;
73 button_h = 3.5;
74 button_x = 9.9;
75 button_y = 5.2;
76 color("white")
77 translate([button_x, button_y, epsilon])
78 cube([button_l, button_w, button_h]);
79
80 wifi_l = 10.0;
81 wifi_w = 12.0;
82 wifi_h = 2.8;
83 wifi_x = 33.0;
84 color("lightgray")
85 translate([wifi_x, (board_w-wifi_w)/2, epsilon])
86 cube([wifi_l, wifi_w, wifi_h]);
87 }
88
89 module at_key() {
90 translate([pico_board_l + wiring_l, 0, 0])
91 rotate([45, 0, 0])
92 rotate([0, 90, 0])
93 children();
94 }
95
96 module key_interface_shape(thick = key_interface_thickness, outline = thickness) {
97 inner = key_interface_size - 2*key_interface_corner_r;
98 linear_extrude(thick)
99 minkowski() {
100 square([inner, inner], center=true);
101 circle(r=key_interface_corner_r + outline);
102 }
103 }
104
105 module key_interface() {
106 at_key()
107 difference() {
108 key_interface_shape();
109
110 translate([0, 0, 6 - epsilon])
111 cherry_switch_void(tolerance=0.05);
112 }
113 }
114
115 module housing_shape(outline = thickness) {
116 housing_w = housing_inner_w + 2 * outline;
117 housing_h = housing_inner_h + 2 * outline;
118 squish = housing_h / (housing_w - housing_flat);
119
120 scale([1, squish])
121 minkowski() {
122 circle(d = housing_w - housing_flat);
123 square([housing_flat, epsilon], center=true);
124 }
125 }
126
127 module housing(length = pico_board_l - extra_flare) {
128 rotate([90, 0, 0])
129 rotate([0, 90, 0])
130 linear_extrude(length)
131 difference() {
132 housing_shape();
133 housing_shape(0);
134 }
135 }
136
137 module flare_shape(outline, extra_len) {
138 hull() {
139 at_key()
140 key_interface_shape(epsilon + extra_len, outline);
141 translate([pico_board_l-extra_flare, 0, 0])
142
143 translate([-extra_len, 0, 0])
144 rotate([90, 0, 0])
145 rotate([0, 90, 0])
146 linear_extrude(epsilon+extra_len)
147 housing_shape(outline);
148 }
149 }
150
151 module flare() {
152 difference() {
153 flare_shape(thickness, 0);
154 flare_shape(0, epsilon);
155 }
156 }
157
158 module at_board() {
159 translate([0, -pico_board_w/2, -pico_board_h])
160 children();
161 }
162
163 module tattlekey_case() {
164 key_interface();
165
166 difference() {
167 union() {
168 housing();
169 flare();
170 }
171 at_board()
172 pico_board(board_gap);
173 }
174 }
175
176 module preview() {
177 at_board() pico_w();
178 render() tattlekey_case();
179 }
180
181 //preview();
182
183 tattlekey_case();