forked from Lenbok/scad-keyboard-cases
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrkbd-case-minimal.scad
161 lines (137 loc) · 5.79 KB
/
crkbd-case-minimal.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
///////////////////////////////////////////////////
// Minimal Tilted Corne Keyboard case (alternate layout)
//
// * Simple top plate (no sides)
// * Simple angled bottom plate (no sides)
// * Supports bottom mount MCU e.g. nrfmicro/lipo combo
//
///////////////////////////////////////////////////
include <../keyboard-case.scad>
include <crkbd-common.scad>
theme = 3;
nrfmicro = false; // If true, make adjustments for nrfmicro and small lipo battery, rather than pro micro.
top_mount_mcu = false;
top_mount_reset = false;
wall_thickness = 2.5;
plate_thickness = 4; // (5mm - max diode height)
bottom_case_height = 0;
window_z = top_mount_mcu ? 13 : 6;
battery_bay = false;
battery_bay_size = [66.5, 15, 9];
battery_bay_offset = [-8, -mcu_size.y+0.5, 0];
mcu_size = [20.0, 35, 13.2]; // Adjusted depth according to sockets etc
screw_rad = 2.2 / 2;
screw_head_rad = 5.4 / 2;
//screw_head_depth = 1.5;
screw_head_depth = 0;
//standoff_rad = 4.0 / 2;
bottom_screws = true; // Default is to screw down from the top
tent_angle = 8;
micro_usb_hole_width = 14;
micro_usb_hole_height = 8;
cherry_clip_recess_height = 2.0; // How far down clip recess go, just go for the minimal
keycap_depth_offset = 6.6; // Distance from bottom of keycap to top of plate.
$fa = 1;
$fs = $preview ? 8 : 2;
module crkbd_top_case() {
top_plate(left_keys, crkbd_screw_holes) crkbd_left_top();
}
module crkbd_bottom_case() {
outer_height = 1.25;
standoff = 2.2;
min_inner_height = top_mount_mcu
? (battery_bay_size.z + wall_thickness)
: battery_bay ? (battery_bay_size.z + wall_thickness)
: outer_height;
min_angle = atan((min_inner_height - outer_height) / crkbd_pcb.x);
if (tent_angle < min_angle) {
echo(str("WARNING: min_angle=", min_angle, " tent_angle=", tent_angle, " inner_height=", inner_height));
}
inner_height = tan(tent_angle) * crkbd_pcb.x + outer_height;
c = crkbd_first_offset + [0, 30, -inner_height + outer_height];
rotate([0, tent_angle, 0]) translate([-c.x, -c.y, 0]) rotate([0, -tent_angle, 0]) translate([c.x, c.y, 0])
difference() {
translate([-c.x, -c.y, 0])
difference() {
translate(c)
linear_extrude(height = inner_height, convexity = 3)
crkbd_left_bottom();
rotate([0, tent_angle, 0])
translate([0, -100, -inner_height])
cube([crkbd_pcb.x * 2, 200, inner_height]);
}
translate([0, 0, 0]) {
if (battery_bay) {
// Hole for lipo battery
translate(-crkbd_first_offset)
translate([crkbd_pcb.x - battery_bay_size.x, -battery_bay_size.y, -battery_bay_size.z + outer_height + 0.01])
translate(battery_bay_offset) {
roundedcube(battery_bay_size, r = 1, center = false);
}
}
if (!top_mount_mcu) {
// Hole for mcu
translate(-crkbd_first_offset)
translate([crkbd_pcb.x - mcu_size.x + 0.01, -mcu_size.y, -mcu_size.z+outer_height+standoff]) {
cube(mcu_size, center = false);
}
}
if (!top_mount_reset) {
// Hole for reset access
reset_cutout = reset_size + [5, 3, 5];
translate(-crkbd_first_offset)
translate([crkbd_pcb.x - reset_cutout.x + 0.01, reset_y_off-reset_cutout.y/2, -reset_cutout.z+outer_height+standoff]) {
cube(reset_cutout, center = false);
}
}
}
screw_positions(crkbd_screw_holes) {
screw_head_depth = 80;
translate([0, 0, -0.1-screw_head_depth-1]) bolthole(r1=screw_head_rad, r2=screw_rad, h1=screw_head_depth, h2=screw_length, membrane = screw_head_depth > 0 ? 0.2 : 0);
}
}
}
part = "assembly";
explode = 0;
cross_section = false;
depressed = false;
if (part == "outer") { // To preview the outer profile, key hole, and screw hole positions
/* offset(r = -2.5) // Where top of camber would come to */
color("gray") translate([0, 0, -7.1]) crkbd_expand_profile(2) crkbd_left_bottom_mod();
color("blue") translate([0, 0, -5.1]) crkbd_left_bottom_mod();
translate([0, 0, -5]) crkbd_left_top();
//translate([0, 0, -5]) crkbd_left_top_window();
color("black") for (pos = crkbd_screw_holes) {
translate(pos) {
circle(r = 2.5 / 2, $fn=20);
//polyhole2d(r = 2.5 / 2);
}
}
#key_holes(left_keys, "plate");
} else if (part == "top") {
translate(crkbd_center_offset)
render() crkbd_top_case();
//%translate([0, 0, plate_thickness + -7 * explode]) key_holes(left_keys, "keycap");
} else if (part == "bottom") {
rotate([0, $preview ? 0 : -tent_angle, 0])
translate(crkbd_center_offset)
crkbd_bottom_case();
} else if (part == "assembly") difference(convexity=10) {
union() {
//rotate([0, -tent_angle, 0])
translate([-80, 60, plate_thickness]) {
%translate([0, 0, plate_thickness - (depressed ? 4 : 0) + 30 * explode]) key_holes(left_keys, "keycap");
%translate([0, 0, plate_thickness + 20 * explode]) key_holes(left_keys, "switch");
crkbd_top_case();
%translate([0, 0, -2.5 - 5 * explode]) crkbd_pcb_assembly(top_mount_mcu = top_mount_mcu, top_mount_reset = top_mount_reset, window_z = window_z);
}
translate([-80, 60, 0])
translate([0, 0, -bottom_case_height - 1 - (20 * explode)]) crkbd_bottom_case();
}
if (cross_section) {
translate([50, -250, -250]) cube([400, 500, 500], center = false);
}
}
// Requires my utility functions in your OpenSCAD lib or as local submodule
// https://github.com/Lenbok/scad-lenbok-utils.git
use<../Lenbok_Utils/utils.scad>