]> git.scottworley.com Git - tattlekey/blob - housing/tattlekey.scad
4567a3dc691c274016d51967a194002fc6617906
[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 = 8;
9 housing_inner_w = 21;
10
11 thickness = 1.7;
12
13 board_gap = 0.125;
14
15 wiring_l = 12;
16 extra_flare = wiring_l;
17
18 pico_board_l = 51.0;
19 pico_board_w = 21.0;
20 pico_total_h = 3.7;
21
22 $fs = .1;
23 $fa = 3;
24
25 slop = 128;
26 epsilon = 1/64;
27
28 module pico_hole(d, x, y) {
29 translate([x, y, -slop/2])
30 cylinder(h=slop, d = d);
31 }
32
33 module 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
39 module pico_w(hole_d = 2.1) {
40 // Dimensions from measuring and/or
41 // https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf
42 board_l = pico_board_l;
43 board_w = pico_board_w;
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")
52 pico_board();
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
88 module 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
95 module key_interface_shape(thick = key_interface_thickness, outline = thickness) {
96 inner = key_interface_size - 2*key_interface_corner_r;
97 linear_extrude(thick)
98 minkowski() {
99 square([inner, inner], center=true);
100 circle(r=key_interface_corner_r + outline);
101 }
102 }
103
104 module key_interface() {
105 at_key()
106 difference() {
107 key_interface_shape();
108
109 translate([0, 0, 6 - epsilon])
110 cherry_switch_void(tolerance=0.05);
111 }
112 }
113
114 module housing_shape(outline = thickness) {
115 inner_squish = housing_inner_h / housing_inner_w;
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
124 module housing(length = pico_board_l - extra_flare) {
125 rotate([90, 0, 0])
126 rotate([0, 90, 0])
127 linear_extrude(length)
128 difference() {
129 housing_shape();
130 housing_shape(0);
131 }
132 }
133
134 module 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 }
147
148 module flare() {
149 difference() {
150 flare_shape(thickness, 0);
151 flare_shape(0, epsilon);
152 }
153 }
154
155 module at_board() {
156 translate([0, -pico_board_w/2, -1])
157 children();
158 }
159
160 module tattlekey_case() {
161 key_interface();
162
163 difference() {
164 union() {
165 housing();
166 flare();
167 }
168 at_board()
169 pico_board(board_gap);
170 }
171 }
172
173 module preview() {
174 at_board() pico_w();
175 render() tattlekey_case();
176 }
177
178 //preview();
179
180 tattlekey_case();