diff --git a/keys.scad b/keys.scad index dd13689..e39d471 100644 --- a/keys.scad +++ b/keys.scad @@ -13,9 +13,15 @@ include include include include -include +include -for (x = [1:1:5]) { - translate_u(0,-x) hipro_row(x) key(); - translate_u(1,-x) sa_row(x) key(); -} +// example key +dcs_row(5) legend("⇪", size=9) key(); + +// example row +/* for (x = [0:1:4]) { + translate_u(0,-x) dcs_row(x) key(); +} */ + +// example layout +/* preonic_default("dcs"); */ diff --git a/keysets.scad b/keysets.scad deleted file mode 100644 index 497c9f0..0000000 --- a/keysets.scad +++ /dev/null @@ -1,36 +0,0 @@ -/*use */ -// NEED to include, not use this, even with the default variables set. don't know why -include - -60_percent = [ - [1,1,1,1,1,1,1,1,1,1,1,1,1,2], - [1.5,1,1,1,1,1,1,1,1,1,1,1,1,1.5], - [1.75,1,1,1,1,1,1,1,1,1,1,1,2.25], - [2.25,1,1,1,1,1,1,1,1,1,1,2.75], - [1.25,1.25,1.25,6.25,1.25,1.25,1.25,1.25] -]; - -function sum(list, x=0) = - len(list) <= 1 ? - x + list[0] : - sum([for (x = [1: len(list) - 1]) list[x]], x+list[0]); - -for (row = [0:len(60_percent)-1]){ - for(column = [0:len(60_percent[row])-1]) { - columnDist = sum([for (x = [0 : column]) 60_percent[row][x]]); - a = 60_percent[row][column]; - translate_u(columnDist - (a/2), -row) g20_row(3) u(a) cherry() { // (row+4) % 5 + 1 - if (a == 6.25) { - spacebar() key(); - } else if (a == 2.25) { - lshift() key(); - } else if (a == 2) { - backspace() key(); - } else if (a == 2.75) { - rshift() key(); - } else { - key(); - } - } - } -} diff --git a/src/layouts.scad b/src/key_layouts.scad similarity index 50% rename from src/layouts.scad rename to src/key_layouts.scad index 0bc2653..42479b6 100644 --- a/src/layouts.scad +++ b/src/key_layouts.scad @@ -1,4 +1,13 @@ +include + +include include + +include include + include + include + +include diff --git a/src/key_profiles/dcs.scad b/src/key_profiles/dcs.scad index ffb3a9c..8fe76f1 100644 --- a/src/key_profiles/dcs.scad +++ b/src/key_profiles/dcs.scad @@ -10,7 +10,7 @@ module dcs_row(row=3, column=0) { $dish_skew_y = 0; $top_skew = 1.75; - $top_tilt_y = column * 3; + $top_tilt_y = column * 3.5; // hack so you can do these in a for loop if (row == 5 || row == 0) { diff --git a/src/layouts/60_percent/default.scad b/src/layouts/60_percent/default.scad new file mode 100644 index 0000000..f76e7af --- /dev/null +++ b/src/layouts/60_percent/default.scad @@ -0,0 +1,13 @@ +include <../layout.scad> + +60_percent = [ + [1,1,1,1,1,1,1,1,1,1,1,1,1,2], + [1.5,1,1,1,1,1,1,1,1,1,1,1,1,1.5], + [1.75,1,1,1,1,1,1,1,1,1,1,1,2.25], + [2.25,1,1,1,1,1,1,1,1,1,1,2.75], + [1.25,1.25,1.25,6.25,1.25,1.25,1.25,1.25] +]; + +module 60_percent_default(profile) { + layout(60_percent, profile); +} diff --git a/src/layouts/layout.scad b/src/layouts/layout.scad new file mode 100644 index 0000000..7769a09 --- /dev/null +++ b/src/layouts/layout.scad @@ -0,0 +1,41 @@ +// sums all values, unless a value is negative, in which case it makes it positive +// dirty hack to allow for large gaps in keysets +function abs_sum(list, x=0) = + len(list) <= 1 ? + x + abs(list[0]) : + abs_sum([for (x = [1: len(list) - 1]) list[x]], x+abs(list[0])); + +module layout(list, profile="dcs", row_sculpting_offset=0, row_override=undef) { + for (row = [0:len(list)-1]){ + echo("**ROW**:", row); + row_length = len(list[row]); + for(column = [0:len(list[row])-1]) { + row_sculpting = (row_override != undef ? row_override : row) + row_sculpting_offset; + key_length = list[row][column]; + + // check if column is smack in middle of row - if so, no sculpting + // otherwise try to make two half-moon shapes, one for each side of the board + // since we are zero indexed, the 7th row has an index of 6 and is the center of 13. 6*2+1 = 13 + double_sculpted_column = (column*2 + 1 == row_length) ? 0 : (column % (row_length/2)) - (row_length/4); + + echo("double_sculpted_column", double_sculpted_column); + column_distance = abs_sum([for (x = [0 : column]) list[row][x]]); + + if (key_length >= 1) { + translate_u(column_distance - (key_length/2), -row) key_profile(profile, row_sculpting, double_sculpted_column) u(key_length) cherry() { // (row+4) % 5 + 1 + if (key_length == 6.25) { + spacebar() key(); + } else if (key_length == 2.25) { + lshift() key(); + } else if (key_length == 2) { + backspace() key(); + } else if (key_length == 2.75) { + rshift() key(); + } else { + key(); + } + } + } + } + } +} diff --git a/src/layouts/lets_split/default.scad b/src/layouts/lets_split/default.scad index 6f457c5..30602ac 100644 --- a/src/layouts/lets_split/default.scad +++ b/src/layouts/lets_split/default.scad @@ -1,9 +1,13 @@ +include <../layout.scad> + +// negative numbers are used for spacing +lets_split_mapping = [ + [1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1] +]; + module lets_split_default(profile) { - for(x = [1:1:4]) { - for(y=[-2.5:0.5:3]) { - translate_u(y > 0 ? y * 2 + 1 : y * 2,-x) key_profile(profile, x,floor(y)) { - key(); - } - } - } + layout(lets_split_mapping, profile, row_sculpting_offset=1); } diff --git a/src/layouts/planck/default.scad b/src/layouts/planck/default.scad new file mode 100644 index 0000000..0278354 --- /dev/null +++ b/src/layouts/planck/default.scad @@ -0,0 +1,15 @@ +include <../layout.scad> + +// 0's are to make space for a middle row for just the spacebar so that it +// isn't sculpted with double sculpting. the 0's in the first three rows +// don't _need_ to be there but it's nice to keep track +planck_layout_mapping = [ + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1] +]; + +module planck_default(profile) { + layout(planck_layout_mapping, profile, row_sculpting_offset=1); +} diff --git a/src/layouts/planck/mit.scad b/src/layouts/planck/mit.scad index 3659608..681633e 100644 --- a/src/layouts/planck/mit.scad +++ b/src/layouts/planck/mit.scad @@ -1,9 +1,15 @@ +include <../layout.scad> + +// 0's are to make space for a middle row for just the spacebar so that it +// isn't sculpted with double sculpting. the 0's in the first three rows +// don't _need_ to be there but it's nice to keep track +planck_layout_mapping = [ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] +]; + module planck_mit(profile) { - for(x = [1:1:4]) { - for(y=[-2.5:0.5:3]) { - translate_u(y * 2,-x) key_profile(profile, x,floor(y)) { - key(); - } - } - } + layout(planck_layout_mapping, profile, row_sculpting_offset=1); } diff --git a/src/layouts/preonic/default.scad b/src/layouts/preonic/default.scad new file mode 100644 index 0000000..8090b21 --- /dev/null +++ b/src/layouts/preonic/default.scad @@ -0,0 +1,13 @@ +include <../layout.scad> + +preonic_layout_mapping = [ + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1] +]; + +module preonic_default(profile) { + layout(preonic_layout_mapping, profile); +} diff --git a/src/layouts/project_zen/default.scad b/src/layouts/project_zen/default.scad index 2813902..d48609e 100644 --- a/src/layouts/project_zen/default.scad +++ b/src/layouts/project_zen/default.scad @@ -1,41 +1,19 @@ -/* function addl(list, c = 0) = - c < len(list) - 1 ? - list[c] + addl(list, c + 1) - : - list[c]; */ +include <../layout.scad> -function addl(list, c = 0, max=undef) = - max < c ? 0 : - (c < len(list) - 1) ? list[c] + addl(list, c + 1, max=max) : - list[c]; +project_zen_main = [ + [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5], + [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5], + [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5], + [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5], + [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5] +]; -function slidingSum(list, c = 1, max = undef) = - c < 1 || c > len(list-1) ? 0 : - c > max ? 0 : - (list[c] + list[c-1])/2 + addl(list, c + 1, max=max); +project_zen_thumbs = [ + [2,2], + [2,2], +]; module project_zen_default(profile) { - widths = [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5]; - translations = [0,1.25,2.25,3.25,4.25,5.25,6.25,7.25,8.25,9.25,10.25,11.5]; - - for(row = [0:1:4]) { - $t = 0; - for(column=[-2.5:0.5:3]) { - normalized_column = column*2 + 5; - $key_length = widths[normalized_column]; - - translate_u(translations[normalized_column],-row) key_profile(profile, row,floor(column)) { - key(); - } - } - } - - for (row=[0:1:1]) { - for (column=[0:1:1]) { - $key_length = 2; - translate_u(4.75 + row*2, -5 - column) key_profile(profile, 3,0) { - key(); - } - } - } + layout(project_zen_main, profile); + translate_u(4.5,-5) layout(project_zen_thumbs, profile, row_override=3); }