-
Notifications
You must be signed in to change notification settings - Fork 0
/
smartipi_touch_2_speaker_dock.scad
231 lines (188 loc) · 7.76 KB
/
smartipi_touch_2_speaker_dock.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/********************************************************
* SmartiPi Touch 2 Speaker Dock - vsergeev
* https://github.com/vsergeev/3d-smartipi-touch-2-speaker-dock
* CC-BY-4.0
*
* Uses four M4x8 bolts and M4 nuts to attach the SmartiPi Touch 2 case to the
* dock.
*
* Release Notes
* * v1.0 - 06/20/2023
* * Initial release.
********************************************************/
/* [Part Selection] */
part = "dock"; // [dock, antitip]
/* [Advanced] */
dock_x_width = 221.61;
dock_y_depth = 65;
dock_xyz_thickness = 3;
dock_top_xyz_thickness = 6;
dock_xy_radius = 5;
dock_feet_x_width = 10;
dock_feet_z_offset = 2;
dock_feet_x_offset = 0.80;
dock_feet_yz_angle = 12.5;
speaker_xyz_clearance = 2;
speaker_x_width = 180 + speaker_xyz_clearance;
speaker_y_depth = 35;
speaker_z_height = 48 + speaker_xyz_clearance;
speaker_lip_z_height = 5;
mounting_hole_nut_xy_clearance = 0.5;
mounting_hole_nut_xy_width = 7.66;
mounting_hole_nut_z_height = 4;
mounting_hole_bore_xy_diameter = 4.25;
// reportedly 159.02, but was too wide
mounting_hole_x_pitch = 156.00;
mounting_hole_y_pitch = 30;
mounting_hole_x_offset = (dock_x_width - 221.61) / 2 + 16.50;
mounting_hole_y_offset = (dock_y_depth - 30) / 2;
anti_tip_bracket_x_width = 20;
anti_tip_bracket_y_depth = 15;
anti_tip_bracket_yz_thickness = 3;
anti_tip_bracket_yz_clearance = 0.3;
anti_tip_bracket_yz_angle = 45;
anti_tip_bracket_yz_radius = 1;
/* [Hidden] */
$fn = 100;
overlap_epsilon = 0.01;
/******************************************************************************/
/* Derived Variables */
/******************************************************************************/
dock_z_height = dock_xyz_thickness + speaker_z_height + dock_top_xyz_thickness;
mounting_hole_positions = [ for (x = [0, 1], y = [0, 1])
[mounting_hole_x_offset + x * mounting_hole_x_pitch,
mounting_hole_y_offset + y * mounting_hole_y_pitch] ];
/******************************************************************************/
/* Helper Operations */
/******************************************************************************/
module radius(r) {
offset(r=r)
offset(delta=-r)
children();
}
/******************************************************************************/
/* 2D Profiles */
/******************************************************************************/
module profile_dock_xy_footprint() {
union() {
/* Radius in the front */
radius(dock_xy_radius)
square([dock_x_width, dock_y_depth], center=true);
/* Rectangular in the back */
translate([0, dock_y_depth / 4])
square([dock_x_width, dock_y_depth / 2], center=true);
}
}
module profile_speaker_body_xz_footprint() {
square([speaker_x_width, speaker_z_height], center=true);
}
module profile_speaker_back_xz_footprint() {
difference() {
profile_speaker_body_xz_footprint();
translate([0, -(speaker_z_height - speaker_lip_z_height) / 2])
square([speaker_x_width + overlap_epsilon, speaker_lip_z_height + overlap_epsilon], center=true);
}
}
module profile_dock_feet_yz_footprint() {
polygon([[0, 0], [0, dock_y_depth], [-dock_feet_z_offset, dock_y_depth], [-dock_feet_z_offset + -dock_y_depth * tan(dock_feet_yz_angle), 0]]);
}
module profile_mounting_hole_nut_xy_footprint() {
circle(d=mounting_hole_nut_xy_width + mounting_hole_nut_xy_clearance, $fn=6);
}
module profile_mounting_hole_bore_xy_footprint() {
circle(d = mounting_hole_bore_xy_diameter);
}
module profile_mounting_access_cutout_xy_footprint() {
circle(d = mounting_hole_nut_xy_width * 2);
}
module profile_anti_tip_bracket_yz_footprint() {
lip_width = anti_tip_bracket_y_depth + anti_tip_bracket_yz_thickness;
lip_height = anti_tip_bracket_yz_thickness * 2 + dock_top_xyz_thickness;
leg_height = dock_feet_z_offset + dock_z_height + (lip_height - dock_top_xyz_thickness) / 2;
leg_x_adjustment = cos(dock_feet_yz_angle);
leg_y_adjustment = tan(anti_tip_bracket_yz_angle) * sin(dock_feet_yz_angle);
union() {
difference() {
/* Lip Profile */
translate([-lip_width / 2, 0])
square([lip_width, lip_height], center=true);
/* Cutout for Dock Top */
translate([-(anti_tip_bracket_y_depth + anti_tip_bracket_yz_thickness - anti_tip_bracket_yz_clearance / 2), 0])
square([anti_tip_bracket_y_depth * 2, dock_top_xyz_thickness + anti_tip_bracket_yz_clearance], center=true);
}
translate([0, lip_height / 2]) {
/* Leg Profile */
polygon([[0, 0],
[leg_height * tan(anti_tip_bracket_yz_angle) * leg_x_adjustment, -leg_height + leg_height * leg_y_adjustment],
[(leg_height - lip_height) * tan(anti_tip_bracket_yz_angle) * leg_x_adjustment, -leg_height + (leg_height - lip_height) * leg_y_adjustment],
[0, -lip_height]]);
}
}
}
/******************************************************************************/
/* 3D Extrusions */
/******************************************************************************/
module speaker_cutout() {
union() {
/* Speaker body */
translate([0, speaker_y_depth, speaker_z_height / 2 + dock_xyz_thickness])
rotate([90, 0, 0])
linear_extrude(speaker_y_depth + overlap_epsilon)
profile_speaker_body_xz_footprint();
/* Speaker opening for back */
translate([0, dock_y_depth * 1.5, speaker_z_height / 2 + dock_xyz_thickness])
rotate([90, 0, 0])
linear_extrude(dock_y_depth * 1.5)
profile_speaker_back_xz_footprint();
}
}
module dock() {
difference() {
union() {
/* Dock frame */
translate([0, dock_y_depth / 2, 0])
linear_extrude(dock_z_height)
profile_dock_xy_footprint();
/* Dock feet */
for (i = [-1, 1]) {
translate([dock_feet_x_width / 2 + i * dock_feet_x_offset * dock_x_width / 2, 0])
rotate([0, -90, 0])
linear_extrude(dock_feet_x_width)
profile_dock_feet_yz_footprint();
}
}
/* Speaker cutout */
speaker_cutout();
/* Mounting hole bores */
for (pos = mounting_hole_positions) {
translate([pos[0] - dock_x_width / 2, pos[1], dock_z_height - dock_top_xyz_thickness * 1.5])
linear_extrude(dock_top_xyz_thickness * 2)
profile_mounting_hole_bore_xy_footprint();
}
/* Mounting hole nuts */
for (pos = mounting_hole_positions) {
translate([pos[0] - dock_x_width / 2, pos[1], dock_z_height - dock_top_xyz_thickness - overlap_epsilon])
linear_extrude(mounting_hole_nut_z_height + overlap_epsilon)
profile_mounting_hole_nut_xy_footprint();
}
/* Mounting hole access cutouts */
for (pos = mounting_hole_positions) {
translate([pos[0] - dock_x_width / 2, pos[1], dock_z_height - dock_top_xyz_thickness - mounting_hole_nut_z_height - overlap_epsilon])
linear_extrude(mounting_hole_nut_z_height + overlap_epsilon)
profile_mounting_access_cutout_xy_footprint();
}
}
}
module anti_tip_bracket() {
linear_extrude(anti_tip_bracket_x_width)
radius(anti_tip_bracket_yz_radius)
profile_anti_tip_bracket_yz_footprint();
}
/******************************************************************************/
/* Top Level */
/******************************************************************************/
if (part == "dock") {
dock();
} else if (part == "antitip") {
anti_tip_bracket();
}