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