keys.scad

download raw

// the point of this file is to be a sort of DSL for constructing keycaps.
// when you create a method chain you are just changing the parameters
// key.scad uses, it doesn't generate anything itself until the end. This
// lets it remain easy to use key.scad like before (except without key profiles)
// without having to rely on this file. Unfortunately that means setting tons of
// special variables, but that's a limitation of SCAD we have to work around

include <./includes.scad>

$font="Routed Gothic";

$adm_stem_angle = 15; // chris says this matches real well
$inset_legend_depth = 0.6;

// stem outside
// original part measured 6.9
// 1st print measured 7.25 (with model dimension 6.9)
stem_outside_compensation = 7.25 - 6.9;

// stem inside
// original part measured 4.9
// 1st print measured 4.9 (with model dimension 5.0)

// tab key gap 24.5
// tab key size 23.8
// -> key should be 1.7 less than gap
// 1 key gap is 33.2
// 33.2 - 1.7 = 32.5
// measured 32.3 is fine

// pinted key depth 18
// printed key height 17.9
module lx2(above, below) {
    translate([0,0,-below]) linear_extrude(above+below) children();
}

module adm_stem() {
    up = 8;
    down = 6.5;
    height = 12;
    children();
color("teal")
    for(pos = $stem_positions) {
echo(pos);
    translate(pos)
    //translate([0,0,up])
    rotate([$adm_stem_angle,0,0])
    lx2(up, down)
    //translate([0,0,-height])
    //linear_extrude(height)
    difference() {
        square(6.9 - stem_outside_compensation, center=true);
        square(5, center=true);
    }
    }
}

size=4.5;
offfs=.80;

// right side 9.45
// left side 7.00
module one() {
    sa_row(5)
    blank() // we make our own stem
    legend("!", position=[0,-offfs], size=size)
    legend("1", position=[0,offfs], size=size)
    adm_stem($stem_positions=[[-1.2,+.6]])
    key($bottom_key_width=32.3, $bottom_key_height=18);
}

rotate([-$adm_stem_angle,0,0]) one();

// example row
/* for (x = [0:1:4]) {
  translate_u(0,-x) dcs_row(x) key();
} */

// example layout
/* preonic_default("dcs") key(); */