add customizer_base. move settings variables to make more sense, in customizer and outside of it. switch (back?) to using rounded_cherry instead of cherry_rounded

This commit is contained in:
Robert Sheldon 2018-06-27 01:12:43 -04:00
parent 16b7ec4a25
commit ff77b6492c
9 changed files with 767 additions and 742 deletions

File diff suppressed because it is too large Load Diff

13
customizer_base.scad Normal file
View File

@ -0,0 +1,13 @@
// entry point for customizer script. This probably isn't useful to most people,
// as it's just a wrapper that helps generate customizer.scad for thingiverse.
include <src/settings.scad>
include <src/key_sizes.scad>
include <src/key_profiles.scad>
include <src/key_types.scad>
include <src/key_transformations.scad>
use <src/key.scad>
key();

View File

@ -21,7 +21,7 @@ def expand(filename)
lines
end
lines = expand(ARGV[1] || 'keys.scad')
lines = expand(ARGV[1] || 'customizer_base.scad')
f = File.open('customizer.scad', 'w')
f.write lines.join

View File

@ -13,33 +13,6 @@ include <src/key_profiles.scad>
include <src/key_types.scad>
include <src/key_transformations.scad>
module translate_u(x=0, y=0, z=0){
translate([x * unit, y*unit, z*unit]) children();
}
// row 5 is commonly the top row, for whatever reason
key_profiles = ["dcs", "oem", "sa", "g20", "dsa"];
module one_single_key(profile, row, unsculpted) {
key_profile(profile, unsculpted ? 3 : row) cherry() key();
}
module one_row_profile(profile, unsculpted = false) {
rows = [5, 1, 2, 3, 4];
for(row = [0:len(rows)-1]) {
translate_u(0, -row) one_single_key(profile, rows[row], unsculpted);
}
}
for (p = [0:len(key_profiles)-1]) {
translate_u(p){
/* one_row_profile(key_profiles[p]); */
}
}
/* translate_u(0, 0) one_row_profile("oem"); */
/* dsa_row(3) u(1) uh(1) cherry() key(); */
translate_u(0, 0) sa_row(3) stepped_caps_lock() {
key();
}
@ -53,6 +26,3 @@ translate_u(0, 2) sa_row(1) spacebar() alps() {
$support_type = false;
key();
}
/* sculpted_square_shape([19,19], [0,0], 0.3);
translate([26,0,0]) rounded_square_shape([19,19], [0,0], 0.3); */

View File

@ -1,6 +1,7 @@
// key profile definitions
// unlike the other files with their own dedicated folders, this one doesn't need a selector. it just collects all the functions
// unlike the other files with their own dedicated folders, this one doesn't
// need a selector. I wrote one anyways for customizer support though
include <key_profiles/dcs.scad>
include <key_profiles/oem.scad>
include <key_profiles/dsa.scad>

View File

@ -82,7 +82,7 @@ module alps(slop) {
module rounded_cherry(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "cherry_rounded";
$stem_type = "rounded_cherry";
children();
}
@ -112,3 +112,14 @@ module bump(depth=undef) {
$key_bump_depth = depth == undef ? $key_bump_depth : depth;
children();
}
module one_single_key(profile, row, unsculpted) {
key_profile(profile, unsculpted ? 3 : row) key();
}
module one_row_profile(profile, unsculpted = false) {
rows = [5, 1, 2, 3, 4];
for(row = [0:len(rows)-1]) {
translate_u(0, -row) one_single_key(profile, rows[row], unsculpted);
}
}

View File

@ -1,18 +1,50 @@
/* [Key] */
//length in units of key
$key_length = 1;
//height in units of key. should remain 1 for most uses
$key_height = 1;
/* [Brim] */
//print brim for connector to help with bed adhesion
$has_brim = false;
// how tall in mm the brim is, if there is one. brim sits around the keystem and helps to secure it while printing.
$brim_height = 0.4;
// what type of stem you want. To turn off stems pass false. "cherry", "alps", and "cherry_rounded" supported
/* [Stem] */
// What stem do you want to use?
$stem_type = "cherry"; // [cherry, alps, rounded_cherry, filled]
// how much higher the stem is than the bottom of the keycap.
// inset stem requires support but is more accurate in some profiles
$stem_inset = 0;
// how many degrees to rotate the stems. useful for sideways keycaps, maybe
$stem_rotation = 0;
// the stem is the hardest part to print, so this variable controls how much 'slop' there is in the stem
$stem_slop = 0.3;
/* [Support] */
// support type. default is "flared" for easy FDM printing. to disable pass false
$support_type = "flared"; // [flared, bars, flat]
/* [Misc] */
// font size used for text
$font_size = 6;
/* [Advanced Features] */
/* Key */
// keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
$keytop_thickness = 1;
// wall thickness, aka the thickness of the sides of the keycap. note this is the total thickness, aka 3 = 1.5mm walls
$wall_thickness = 3;
//whether stabilizer connectors are enabled
$stabilizers = false;
// font used for text
$font="DejaVu Sans Mono:style=Book";
// font size used for text
$font_size = 6;
// whether or not to render fake keyswitches to check clearances
$clearance_check = false;
/* [Key profile] */
// radius of corners of keycap
$corner_radius = 1;
// width of the very bottom of the key
$bottom_key_width = 18.16;
// height (from the front) of the very bottom of the ke
@ -27,79 +59,68 @@ $total_depth = 11.5;
$top_tilt = -6;
// how skewed towards the back the top is (0 for center)
$top_skew = 1.7;
/* Stem */
// where the stems are in relation to the center of the keycap, in units. default is one in the center
$stem_positions = [[0,0]];
// how far the throw distance of the switch is. determines how far the 'cross' in the cherry switch digs into the stem, and how long the keystem needs to be before supports can start. luckily, alps and cherries have a pretty similar throw. can modify to have stouter keycaps for low profile switches, etc
$stem_throw = 4;
// diameter of the outside of the rounded cherry stem
$rounded_cherry_stem_d = 5.5;
// dimensions of alps stem
$alps_stem = [4.45, 2.25];
/* Stabilizers */
// array of positions of stabilizers
$stabilizers = [[-50,0],[50,0]];
// what type of stem you want for the stabilizers. false disables
$stabilizer_type = false;
/* Shape */
// key shape type, determines the shape of the key. default is 'rounded square'
$key_shape_type = "rounded_square";
// ISO enter needs to be linear extruded NOT from the center. this tells the program how far up 'not from the center' is
$linear_extrude_height_adjustment = 0;
// how many slices will be made, to approximate curves on corners. Leave at 1 if you are not curving corners
// if you're doing fancy bowed keycap sides, this controls how many slices you take
$height_slices = 1;
/* Dish */
// what type of dish the key has. note that unlike stems and supports a dish ALWAYS gets rendered.
$dish_type = "cylindrical";
$dish_type = "cylindrical"; // [cylindrical, spherical, sideways cylindrical, old spherical]
// how deep the dish 'digs' into the top of the keycap. this is max depth, so you can't find the height from total_depth - dish_depth. besides the top is skewed anyways
$dish_depth = 1;
// how skewed in the x direction the dish is
$dish_skew_x = 0;
// how skewed in the y direction (height) the dish is
$dish_skew_y = 0;
//length in units of key
$key_length = 1;
//height in units of key. should remain 1 for most uses
$key_height = 1;
//print brim for connector to help with bed adhesion
$has_brim = false;
//when $has_brim this is the height of the brim
$brim_height = 0.2;
// invert dishing. mostly for spacebar
$inverted_dish = false;
// array of positions of stabilizers
// ternary is a bad hack to keep the stabilizers flag working
$stabilizers = [[-50,0],[50,0]];
// if you need the dish to extend further, you can 'overdraw' the rectangle it will hit
$dish_overdraw_width = 0;
// same as width but for height
$dish_overdraw_height = 0;
/* Misc */
// font used for text
$font="DejaVu Sans Mono:style=Book";
// whether or not to render fake keyswitches to check clearances
$clearance_check = false;
// use linear_extrude instead of hull slices to make the shape of the key
// should be faster, also required for concave shapes
$linear_extrude_shape = false;
//should the key be rounded? unnecessary for most printers, and very slow
$rounded_key = false;
// what type of stem you want. To turn off stems pass false. "cherry", "alps", and "cherry_rounded" supported
$stem_type = "cherry";
// where the stems are in relation to the center of the keycap, in units. default is one in the center
$stem_positions = [[0,0]];
// what type of stem you want for the stabilizers. false disables
$stabilizer_type = false;
// how much higher the stem is than the bottom of the keycap.
// inset stem requires support but is more accurate in some profiles
$stem_inset = 0;
// how many degrees to rotate the stems. useful for sideways keycaps, maybe
$stem_rotation = 0;
// radius of corners of keycap
$corner_radius = 1;
// support type. default is "flared" for easy FDM printing. to disable pass false
$support_type = "flared";
// key shape type, determines the shape of the key. default is 'rounded square'
$key_shape_type = "rounded_square";
// ISO enter needs to be linear extruded NOT from the center. this tells the program how far up 'not from the center' is
$linear_extrude_height_adjustment = 0;
// if you need the dish to extend further, you can 'overdraw' the rectangle it will hit
$dish_overdraw_width = 0;
// same as width but for height
$dish_overdraw_height = 0;
// how many slices will be made, to approximate curves on corners. Leave at 1 if you are not curving corners
// if you're doing fancy bowed keycap sides, this controls how many slices you take
$height_slices = 1;
//minkowski radius. radius of sphere used in minkowski sum for minkowski_key function. 1.75 for G20
$minkowski_radius = .33;
// [ Stem Variables ]
// the stem is the hardest part to print, so this variable controls how much 'slop' there is in the stem
$stem_slop = 0.3;
// how tall in mm the brim is, if there is one. brim sits around the keystem and helps to secure it while printing.
$brim_height = 0.4;
// how far the throw distance of the switch is. determines how far the 'cross' in the cherry switch digs into the stem, and how long the keystem needs to be before supports can start. luckily, alps and cherries have a pretty similar throw. can modify to have stouter keycaps for low profile switches, etc
$stem_throw = 4;
// diameter of the outside of the rounded cherry stem
$rounded_cherry_stem_d = 5.5;
// dimensions of alps stem
$alps_stem = [4.45, 2.25];
/* Features */
//list of legends to place on a key format: [text, halign, valign, size]
//halign = "left" or "center" or "right"

View File

@ -8,7 +8,7 @@ include <stems/filled.scad>
module stem(stem_type, depth, has_brim, slop){
if (stem_type == "alps") {
alps_stem(depth, has_brim, slop);
} else if (stem_type == "cherry_rounded") {
} else if (stem_type == "rounded_cherry") {
rounded_cherry_stem(depth, has_brim, slop);
} else if (stem_type == "cherry") {
cherry_stem(depth, has_brim, slop);

View File

@ -9,7 +9,7 @@ function scale_for_45(height, starting_size) = (height * 2 + starting_size) / st
// also kind of messy... oh well
module flared(stem_type, loft, height) {
translate([0,0,loft]){
if (stem_type == "cherry_rounded") {
if (stem_type == "rounded_cherry") {
linear_extrude(height=height, scale = scale_for_45(height, $rounded_cherry_stem_d)){
circle(d=$rounded_cherry_stem_d);
}