Skip to content

Instantly share code, notes, and snippets.

@RavuAlHemio
Created November 17, 2019 00:52
Show Gist options
  • Save RavuAlHemio/ebb2b16589a161bb0abc3503fc0bd4cd to your computer and use it in GitHub Desktop.
Save RavuAlHemio/ebb2b16589a161bb0abc3503fc0bd4cd to your computer and use it in GitHub Desktop.
key cap for a standard EVVA 4KS key (SL)
// unit: 1mm
key_thickness = 2.25;
bow_width = 25.5;
bow_corner_radius = 6.0;
bow_corner_advance = 12.25;
bow_curve_advance = 10.0;
bow_curve_radius = 3.0;
bow_curve_outer_offset = 3.25;
stop_width = 13.0;
stop_advance = 5.517;
stop_tip_radius = 0.5;
ring_hole_radius = 3.25;
ring_hole_offset = 2.75;
keycap_thickness = 2.0;
code_window_advance = 10.0;
code_window_depth = 10.0;
$fn = $preview ? 8 : 32;
// code borrowed from nophead
// http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-td16537.html#a16556
module rounded_polygon(points)
difference() {
len = len(points);
union() {
for (i = [0:len-1])
if (points[i][2] > 0)
translate([points[i].x, points[i].y])
circle(points[i][2]);
polygon([
for (i = [0:len-1])
let (ends = tangent(points[i], points[(i + 1) % len]))
for (end = [0, 1])
ends[end]
]);
};
for (i = [0:len-1])
if (points[i][2] < 0)
translate([points[i].x, points[i].y])
circle(-points[i][2]);
}
;
function tangent(p1, p2) =
let (
r1 = p1[2],
r2 = p2[2],
dx = p2.x - p1.x,
dy = p2.y - p1.y,
d = sqrt(dx*dx + dy*dy),
theta = atan2(dy, dx) + acos((r1 - r2) / d),
xa = p1.x + (cos(theta) * r1),
ya = p1.y + (sin(theta) * r1),
xb = p2.x + (cos(theta) * r2),
yb = p2.y + (sin(theta) * r2)
)
[[xa, ya], [xb, yb]];
// end borrowed code
module evva_4ks(
key_thickness = key_thickness,
bow_width = bow_width,
bow_corner_radius = bow_corner_radius,
bow_corner_advance = bow_corner_advance,
bow_curve_advance = bow_curve_advance,
bow_curve_radius = bow_curve_radius,
bow_curve_outer_offset = bow_curve_outer_offset,
stop_width = stop_width,
stop_advance = stop_advance,
stop_tip_radius = stop_tip_radius,
ring_hole_radius = ring_hole_radius,
ring_hole_offset = ring_hole_offset
)
{
key_points = [
[
// bottom left corner
0,
0,
bow_corner_radius
],
[
// left "midpoint"
0,
bow_corner_advance,
bow_corner_radius
],
[
// middle of left curve circle
bow_curve_outer_offset - bow_corner_radius,
bow_corner_advance + bow_curve_advance,
-bow_curve_radius
],
[
// left stop tip
-bow_corner_radius + bow_width/2 - stop_width/2 + stop_tip_radius,
bow_corner_advance + bow_curve_advance + stop_advance,
stop_tip_radius
],
[
// right stop tip
-bow_corner_radius + bow_width/2 + stop_width/2 - stop_tip_radius,
bow_corner_advance + bow_curve_advance + stop_advance,
stop_tip_radius
],
[
// middle of right curve circle
bow_width - bow_corner_radius - bow_curve_outer_offset,
bow_corner_advance + bow_curve_advance,
-bow_curve_radius
],
[
// right "midpoint"
bow_width - 2*bow_corner_radius,
bow_corner_advance,
bow_corner_radius
],
[
// bottom right corner
bow_width - 2*bow_corner_radius,
0,
bow_corner_radius
],
];
difference()
{
// bore keyhole
linear_extrude(height=key_thickness)
rounded_polygon(key_points);
translate([
-bow_corner_radius + bow_width/2,
-bow_corner_radius + ring_hole_offset + ring_hole_radius,
-10
])
cylinder(
r=ring_hole_radius,
h=20
);
};
};
difference()
{
// keycap
translate([0, 0, -keycap_thickness])
evva_4ks(
key_thickness = key_thickness + 2*keycap_thickness,
bow_width = bow_width + 2*keycap_thickness,
bow_corner_radius = bow_corner_radius + keycap_thickness,
ring_hole_offset = ring_hole_offset + keycap_thickness,
bow_curve_radius = bow_curve_radius - 0.1,
stop_advance = 0.0
);
// key inside
evva_4ks();
// insertion slit
translate([-bow_corner_radius, -bow_corner_radius-2*keycap_thickness, 0])
cube([
bow_width,
6*keycap_thickness,
key_thickness
]);
// code window
translate([
-bow_corner_radius,
-bow_corner_radius + code_window_advance,
key_thickness
])
cube([
bow_width,
code_window_depth,
keycap_thickness
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment