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