diff --git a/customizer.scad b/customizer.scad index 19b1ba5..0d0cf72 100644 --- a/customizer.scad +++ b/customizer.scad @@ -2496,6 +2496,8 @@ module supports(type, stem_type, loft, height) { echo("Warning: unsupported $support_type"); } } +// features are any premade self-contained objects that go on top or inside + module keybump(depth = 0, edge_inset=0.4) { radius = 0.5; translate([0, -top_total_key_height()/2 + edge_inset, depth]){ @@ -2503,6 +2505,56 @@ module keybump(depth = 0, edge_inset=0.4) { translate([0,0,-radius]) cube([$font_size, radius*2, radius*2], true); } } +// a fake cherry keyswitch, abstracted out to maybe replace with a better one later +module cherry_keyswitch() { + union() { + hull() { + cube([15.6, 15.6, 0.01], center=true); + translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true); + } + hull() { + cube([15.6, 15.6, 0.01], center=true); + translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true); + } + } +} + +//approximate (fully depressed) cherry key to check clearances +module clearance_check() { + if($stem_type == "cherry" || $stem_type == "cherry_rounded"){ + color($warning_color){ + translate([0,0,3.6 + $stem_inset - 5]) { + cherry_keyswitch(); + } + } + } +} +module keytext(text, position, font_size, depth) { + woffset = (top_total_key_width()/3.5) * position[0]; + hoffset = (top_total_key_height()/3.5) * -position[1]; + translate([woffset, hoffset, -depth]){ + color($tertiary_color) linear_extrude(height=$dish_depth){ + text(text=text, font=$font, size=font_size, halign="center", valign="center"); + } + } +} + +module legends(depth=0) { + if (len($front_legends) > 0) { + front_of_key() { + for (i=[0:len($front_legends)-1]) { + rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth); + } + } + } + if (len($legends) > 0) { + top_of_key() { + for (i=[0:len($legends)-1]) { + keytext($legends[i][0], $legends[i][1], $legends[i][2], depth); + } + } + } +} // from https://www.thingiverse.com/thing:1484333 // public domain license @@ -3703,16 +3755,6 @@ module top_of_key(){ } } -module keytext(text, position, font_size, depth) { - woffset = (top_total_key_width()/3.5) * position[0]; - hoffset = (top_total_key_height()/3.5) * -position[1]; - translate([woffset, hoffset, -depth]){ - color($tertiary_color) linear_extrude(height=$dish_depth){ - text(text=text, font=$font, size=font_size, halign="center", valign="center"); - } - } -} - module keystem_positions(positions) { for (connector_pos = positions) { translate(connector_pos) { @@ -3738,53 +3780,6 @@ module stems_for(positions, stem_type) { } } -// a fake cherry keyswitch, abstracted out to maybe replace with a better one later -module cherry_keyswitch() { - union() { - hull() { - cube([15.6, 15.6, 0.01], center=true); - translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true); - } - hull() { - cube([15.6, 15.6, 0.01], center=true); - translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true); - } - } -} - -//approximate (fully depressed) cherry key to check clearances -module clearance_check() { - if($stem_type == "cherry" || $stem_type == "cherry_rounded"){ - color($warning_color){ - translate([0,0,3.6 + $stem_inset - 5]) { - cherry_keyswitch(); - } - } - } -} - -module legends(depth=0) { - if (len($front_legends) > 0) { - front_placement() { - if (len($front_legends) > 0) { - for (i=[0:len($front_legends)-1]) { - rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth); - } - } - } - } - if (len($legends) > 0) { - top_of_key() { - // outset legend - if (len($legends) > 0) { - for (i=[0:len($legends)-1]) { - keytext($legends[i][0], $legends[i][1], $legends[i][2], depth); - } - } - } - } -} - // legends / artisan support module artisan(depth) { top_of_key() { diff --git a/src/features.scad b/src/features.scad new file mode 100644 index 0000000..b0ae94a --- /dev/null +++ b/src/features.scad @@ -0,0 +1,5 @@ +// features are any premade self-contained objects that go on top or inside + +include +include +include diff --git a/src/features/clearance_check.scad b/src/features/clearance_check.scad new file mode 100644 index 0000000..96c4d70 --- /dev/null +++ b/src/features/clearance_check.scad @@ -0,0 +1,24 @@ +// a fake cherry keyswitch, abstracted out to maybe replace with a better one later +module cherry_keyswitch() { + union() { + hull() { + cube([15.6, 15.6, 0.01], center=true); + translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true); + } + hull() { + cube([15.6, 15.6, 0.01], center=true); + translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true); + } + } +} + +//approximate (fully depressed) cherry key to check clearances +module clearance_check() { + if($stem_type == "cherry" || $stem_type == "cherry_rounded"){ + color($warning_color){ + translate([0,0,3.6 + $stem_inset - 5]) { + cherry_keyswitch(); + } + } + } +} diff --git a/src/features/legends.scad b/src/features/legends.scad new file mode 100644 index 0000000..e657218 --- /dev/null +++ b/src/features/legends.scad @@ -0,0 +1,26 @@ +module keytext(text, position, font_size, depth) { + woffset = (top_total_key_width()/3.5) * position[0]; + hoffset = (top_total_key_height()/3.5) * -position[1]; + translate([woffset, hoffset, -depth]){ + color($tertiary_color) linear_extrude(height=$dish_depth){ + text(text=text, font=$font, size=font_size, halign="center", valign="center"); + } + } +} + +module legends(depth=0) { + if (len($front_legends) > 0) { + front_of_key() { + for (i=[0:len($front_legends)-1]) { + rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth); + } + } + } + if (len($legends) > 0) { + top_of_key() { + for (i=[0:len($legends)-1]) { + keytext($legends[i][0], $legends[i][1], $legends[i][2], depth); + } + } + } +} diff --git a/src/key.scad b/src/key.scad index f8ecc95..8b87f16 100644 --- a/src/key.scad +++ b/src/key.scad @@ -5,7 +5,7 @@ include include include include -include +include include @@ -271,16 +271,6 @@ module top_of_key(){ } } -module keytext(text, position, font_size, depth) { - woffset = (top_total_key_width()/3.5) * position[0]; - hoffset = (top_total_key_height()/3.5) * -position[1]; - translate([woffset, hoffset, -depth]){ - color($tertiary_color) linear_extrude(height=$dish_depth){ - text(text=text, font=$font, size=font_size, halign="center", valign="center"); - } - } -} - module keystem_positions(positions) { for (connector_pos = positions) { translate(connector_pos) { @@ -306,53 +296,6 @@ module stems_for(positions, stem_type) { } } -// a fake cherry keyswitch, abstracted out to maybe replace with a better one later -module cherry_keyswitch() { - union() { - hull() { - cube([15.6, 15.6, 0.01], center=true); - translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true); - } - hull() { - cube([15.6, 15.6, 0.01], center=true); - translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true); - } - } -} - -//approximate (fully depressed) cherry key to check clearances -module clearance_check() { - if($stem_type == "cherry" || $stem_type == "cherry_rounded"){ - color($warning_color){ - translate([0,0,3.6 + $stem_inset - 5]) { - cherry_keyswitch(); - } - } - } -} - -module legends(depth=0) { - if (len($front_legends) > 0) { - front_placement() { - if (len($front_legends) > 0) { - for (i=[0:len($front_legends)-1]) { - rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth); - } - } - } - } - if (len($legends) > 0) { - top_of_key() { - // outset legend - if (len($legends) > 0) { - for (i=[0:len($legends)-1]) { - keytext($legends[i][0], $legends[i][1], $legends[i][2], depth); - } - } - } - } -} - // legends / artisan support module artisan(depth) { top_of_key() {