g_fn = 64; g_rounding = 1; g_button_d = 8; g_button_h = 12; g_contact_h = 5.0; module spherical_segment(d1, d2, h) { r1=d1/2; r2=d2/2; H=(r2^2 - r1^2 - h^2) / (2*h); R=sqrt(H^2 + r2^2); intersection() { translate([0,0,0]) cylinder(h=h, d=d2, center=false, $fn=g_fn); translate([0,0,-H]) sphere(r=R, $fn=g_fn); } } difference() { union() { cylinder(h=2, d=g_button_d+2, center=false, $fn=g_fn); cylinder(h=g_button_h-g_rounding, d=g_button_d, center=false, $fn=g_fn); translate([0 ,0, g_button_h-g_rounding]) spherical_segment(g_button_d-g_rounding, g_button_d, g_rounding); } cylinder(h=g_button_h-2, d=g_button_d-2, center=false, $fn=g_fn); } g_contact_support_h = g_button_h - 2; translate([0, 0, (g_contact_support_h+g_contact_h) / 2]) { cube([g_button_d-1, 1.5, (g_contact_support_h-g_contact_h)], center=true); cube([1.5, g_button_d-1, (g_contact_support_h-g_contact_h)], center=true); }