mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-01-22 17:30:57 +00:00
Merge pull request #44 from rsheldiii/key-features
Key features are a full feature
This commit is contained in:
commit
a523c45f4a
5 changed files with 108 additions and 115 deletions
109
customizer.scad
109
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() {
|
||||
|
|
5
src/features.scad
Normal file
5
src/features.scad
Normal file
|
@ -0,0 +1,5 @@
|
|||
// features are any premade self-contained objects that go on top or inside
|
||||
|
||||
include <features/key_bump.scad>
|
||||
include <features/clearance_check.scad>
|
||||
include <features/legends.scad>
|
24
src/features/clearance_check.scad
Normal file
24
src/features/clearance_check.scad
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
src/features/legends.scad
Normal file
26
src/features/legends.scad
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
src/key.scad
59
src/key.scad
|
@ -5,7 +5,7 @@ include <stems.scad>
|
|||
include <stem_supports.scad>
|
||||
include <dishes.scad>
|
||||
include <supports.scad>
|
||||
include <key_features.scad>
|
||||
include <features.scad>
|
||||
|
||||
include <libraries/geodesic_sphere.scad>
|
||||
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue