-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadafruit-trellis-m4-case-top.scad
138 lines (126 loc) · 3.67 KB
/
adafruit-trellis-m4-case-top.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
$fn=36;
$corner_diameter=10;
$num_x = 8;
$num_y = 4;
$notch_width = 40;
$notch_top_padding = 2.5;
$edge_gap = 1.4;
$edge_width = 0.5;
module button_hole(height) {
minkowski() {
cube([9.4,9.4,height], center=true);
cylinder(h=height, d1=1, d2=1);
}
}
module buttons(num_x, num_y, height) {
for (x = [0:num_x-1]) {
for (y = [0:num_y-1]) {
translate([x*15, y*15, 0])
button_hole(height);
}
}
}
module notch(depth, width, height) {
notch_depth=$corner_diameter/2;
points = [
[$notch_top_padding, 0, 0],
[$notch_width + $notch_top_padding, 0, 0],
[$notch_width + ($notch_top_padding * 2), notch_depth, 0],
[0, notch_depth, 0],
[$notch_top_padding, 0, height],
[$notch_width + $notch_top_padding, 0, height],
[$notch_width + ($notch_top_padding * 2), notch_depth, height],
[0, notch_depth, height]
];
faces = [
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3]
]; // left
translate([depth/2-$notch_top_padding-($notch_width/2), width, 0]) {
polyhedron(points, faces);
}
}
module top(num_x, num_y, height) {
width = num_y * 15;
depth = num_x * 15;
difference() {
// Surface
minkowski() {
cube([depth, width, height]);
cylinder(h=0.0000001, d1=$corner_diameter,
d2=$corner_diameter);
}
// Button cutouts
translate([$corner_diameter/2+2.5, $corner_diameter/2+2.5, 0])
buttons(num_x, num_y, height);
// Connector cutout
notch(depth, width, height);
}
}
module board_guide(num_x, num_y, height) {
width = num_y * 15;
depth = num_x * 15;
edge_padding = $corner_diameter/2-$edge_gap-$edge_width;
difference() {
// Surface
minkowski() {
translate([$edge_gap, $edge_gap, 0])
cube([depth-$edge_gap*2, width-$edge_gap*2, height]);
cylinder(h=0.0000001, d1=$corner_diameter,
d2=$corner_diameter);
}
// Connector cutout
notch(depth, width, height);
// Board area
translate([-edge_padding/2, -edge_padding/2, 0])
cube([depth + edge_padding, width + edge_padding, height]);
// Snapfit grooves
grooves($num_x, $num_y);
}
}
module snap_groove(depth, width) {
size=1.6;
rotate([90,0,0]) {
hull() {
cylinder(h=depth, d1=size, d2=size);
translate([width, 0, 0])
cylinder(h=depth, d1=size, d2=size);
}
translate([0,0,depth/2])
hull() {
cylinder(h=depth, d1=size, d2=size);
translate([width, 0, 0])
cylinder(h=depth, d1=size, d2=size);
translate([0,-4,0]) {
cylinder(h=depth, d1=size, d2=size);
translate([width, 0, 0])
cylinder(h=depth, d1=size, d2=size);
}
}
}
}
module grooves(num_x, num_y) {
depth = num_y * 15;
width = num_x * 15;
length = 10;
offset = 20;
left = width-offset-length;
right = offset;
top = -$edge_gap-$edge_width-1;
bottom = depth+$edge_gap+$edge_width+1;
translate([left, top, 4]) snap_groove(1, 10);
translate([right, top, 4]) snap_groove(1, 10);
translate([left, bottom, 4])
mirror([0,1,0]) snap_groove(1, 10);
translate([right, bottom, 4])
mirror([0,1,0]) snap_groove(1, 10);
}
rotate([0,180,0]) {
top($num_x, $num_y, 6);
translate([0,0,-6])
board_guide($num_x, $num_y, 6);
}