You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
276 lines
12 KiB
276 lines
12 KiB
/*
|
|
* Copyright 2022 Thomas Buck - thomas@xythobuz.de
|
|
* Philipp Schönberger - mail@phschoen.de
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* See <http://www.gnu.org/licenses/>.
|
|
*/
|
|
include <config.scad>;
|
|
include <constant.scad>;
|
|
|
|
use <switch_cutout.scad>;
|
|
use <switch_holder.scad>;
|
|
use <switch.scad>;
|
|
use <pcb/amoeba-royale.scad>;
|
|
|
|
function switch_rc_point(switch_config, c, r, a, h, offset=[0,0,0]) =
|
|
v_rot(switch_config[c][r][r_pos]) *
|
|
(switch_point(a,h) + offset) +
|
|
switch_config[c][r][t_pos];
|
|
|
|
function switch_bz(switch_config, c, r, a, h, offset=[0,-10,0]) = [
|
|
[
|
|
switch_rc_point(switch_config, c, r, a[0], h, [0,0,0]),
|
|
switch_rc_point(switch_config, c, r, a[1], h, [0,0,0]),
|
|
],
|
|
[
|
|
switch_rc_point(switch_config, c, r, a[0], h, offset),
|
|
switch_rc_point(switch_config, c, r, a[1], h, offset),
|
|
],
|
|
[
|
|
zero_axis("z", switch_rc_point(switch_config, c, r, a[0], h, offset), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, c, r, a[1], h, offset), -20)
|
|
],
|
|
];
|
|
function switch_bz_edge(switch_config, c, r, a, h, offset1=[0,-10,0],offset2=[0,-10,0]) = [
|
|
[
|
|
switch_rc_point(switch_config, c, r, a, h, $e*offset1),
|
|
switch_rc_point(switch_config, c, r, a, h, 0*offset1),
|
|
switch_rc_point(switch_config, c, r, a, h, $e*offset2),
|
|
],
|
|
[
|
|
switch_rc_point(switch_config, c, r, a, h, offset1),
|
|
switch_rc_point(switch_config, c, r, a, h, offset1+offset2),
|
|
switch_rc_point(switch_config, c, r, a, h, offset2),
|
|
],
|
|
[
|
|
zero_axis("z", switch_rc_point(switch_config, c, r, a, h, offset1), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, c, r, a, h, offset1+offset2), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, c, r, a, h, offset2), -20)
|
|
],
|
|
];
|
|
|
|
|
|
function switch_bz_between(switch_config, colums, rows, a, h, offset_bz=[2,0,0], offset_out=[0,-10,0]) = [
|
|
[
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]-offset_bz),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]+offset_bz),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]-offset_bz),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]+offset_bz),
|
|
],
|
|
[
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]-offset_bz+offset_out),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]+offset_out),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]+offset_bz+offset_out),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]-offset_bz+offset_out),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]+offset_out),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]+offset_bz+offset_out),
|
|
],
|
|
[
|
|
zero_axis("z", switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]-offset_bz+offset_out), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]+offset_out), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, colums[0], rows[0], a[0], h, [0,0,0]+offset_bz+offset_out), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]-offset_bz+offset_out), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]+offset_out), -20),
|
|
zero_axis("z", switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1], h, [0,0,0]+offset_bz+offset_out), -20),
|
|
],
|
|
];
|
|
|
|
function switch_line_connection(switch_config, colums, rows, a) = [
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][0], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][1], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1][1], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1][0], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][0], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][1], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1][1], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[len(colums) == 1 ? 0 : 1], rows[len(rows) == 1 ? 0 : 1], a[1][0], "bot", [0,0,0]),
|
|
];
|
|
|
|
function switch_line_connection_cross(switch_config, colums, rows, a,h,offset_bz=[2,0,0]) = [
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][0], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[1], a[0][1], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[1], rows[1], a[1][1], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[1], rows[0], a[1][0], "top", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[0], a[0][0], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[0], rows[1], a[0][1], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[1], rows[1], a[1][1], "bot", [0,0,0]),
|
|
switch_rc_point(switch_config, colums[1], rows[0], a[1][0], "bot", [0,0,0]),
|
|
];
|
|
function reverse_bz(points) = [for(i = [len(points)-1:-1:0]) points[i], ];
|
|
|
|
|
|
switch_holder_plate(switch_config[0], 10);
|
|
|
|
module switch_holder_plate(switch_config, w_extra)
|
|
{
|
|
t_step = 0.1;
|
|
thickness = switch_holder_height+1;
|
|
|
|
c_max=len(switch_config)-1;
|
|
function r_max(c) = len(switch_config[c])-1;
|
|
|
|
ctrl_pts_S = [
|
|
for(c=[0:c_max], r=[r_max(c)])
|
|
switch_bz(switch_config, c, r, ["SW","SE"], "top", [0,-w_extra,0]),
|
|
];
|
|
|
|
// North curve
|
|
ctrl_pts_N = [
|
|
for(c=[0:c_max], r=[0])
|
|
switch_bz(switch_config, c, r, ["NE","NW"], "top", [0,w_extra,0]),
|
|
];
|
|
// West curve
|
|
ctrl_pts_W = [
|
|
for(c=[0], r=[0:r_max(c)])
|
|
switch_bz(switch_config, c, r, ["NW","SW"], "top", [-w_extra,0,0]),
|
|
];
|
|
// East curve
|
|
ctrl_pts_E = [
|
|
for(c=[c_max], r=[0:r_max(c)])
|
|
switch_bz(switch_config, c, r, ["SE","NE"], "top", [+w_extra,0,0]),
|
|
];
|
|
// edge
|
|
ctrl_pts_EDGE = [
|
|
switch_bz_edge(switch_config, 0, r_max(0), "SW", "top", [-w_extra,0,0], [0,-w_extra,0]),
|
|
switch_bz_edge(switch_config, c_max, 0, "NE", "top", [ w_extra,0,0], [0, w_extra,0]),
|
|
reverse_bz(switch_bz_edge(switch_config, c_max, r_max(c_max), "SE", "top", [ w_extra,0,0], [0,-w_extra,0])),
|
|
reverse_bz(switch_bz_edge(switch_config, 0, 0, "NW", "top", [-w_extra,0,0], [0, w_extra,0])),
|
|
];
|
|
|
|
// between the s curves
|
|
//
|
|
ctrl_pts_S_B = [
|
|
for(c=[0:c_max-1], r=[r_max(c)])
|
|
switch_bz_between(switch_config, [c, c+1], [r], ["SE","SW"], "top", [1,0,0], [0,-w_extra,0]),
|
|
];
|
|
|
|
|
|
// North curve between the keys
|
|
ctrl_pts_N_B = [
|
|
for(c=[0:c_max-1], r=[0])
|
|
switch_bz_between(switch_config, [c+1,c], [r], ["NW","NE"], "top", [-1,0,0], [0,+w_extra,0]),
|
|
];
|
|
|
|
|
|
/* // West curve between the keys */
|
|
ctrl_pts_W_B = [
|
|
for(c=[0], r=[0:r_max(c)])
|
|
switch_bz_between(switch_config, [c], [r,r+1], ["SW","NW"], "top", [1,0,0], [-w_extra,0,0]),
|
|
];
|
|
|
|
|
|
/* // East curve between the keys */
|
|
ctrl_pts_E_B = [
|
|
for(c=[c_max], r=[0:r_max(c)])
|
|
switch_bz_between(switch_config, [c], [r+1,r], ["NE","SE"],"top",[1,0,0],[w_extra,0,0]),
|
|
];
|
|
|
|
|
|
// North-South between the keys
|
|
ctrl_pts_NS_IN = [
|
|
for(c=[0:c_max], r=[0:r_max(c)-1])
|
|
switch_line_connection(switch_config, [c], [r,r+1], [ ["SW", "SE"], ["NW", "NE"], ], "top")
|
|
];
|
|
|
|
// East West between the keys
|
|
ctrl_pts_EW_IN = [
|
|
for(c=[0:c_max-1], r=[0:r_max(c)])
|
|
switch_line_connection(switch_config, [c,c+1], [r], [["NE", "SE"],["NW", "SW"] ,], "top"),
|
|
];
|
|
|
|
// the cross section between 4 keys
|
|
//
|
|
//
|
|
ctrl_pts_CROSS_IN = [
|
|
for(c=[0:c_max-1], r=[0:r_max(c)-1])
|
|
switch_line_connection_cross(switch_config, [c,c+1], [r,r+1], [["SE", "NE"],["SW", "NW"] ,]),
|
|
];
|
|
|
|
ctrl_pts = [
|
|
ctrl_pts_S ,
|
|
ctrl_pts_N,
|
|
ctrl_pts_W,
|
|
ctrl_pts_E,
|
|
ctrl_pts_EDGE,
|
|
ctrl_pts_S_B ,
|
|
ctrl_pts_N_B ,
|
|
ctrl_pts_W_B ,
|
|
ctrl_pts_E_B ,
|
|
];
|
|
echo("ctrlptr sB",ctrl_pts_S_B);
|
|
poly_pts = [
|
|
ctrl_pts_NS_IN,
|
|
ctrl_pts_EW_IN,
|
|
ctrl_pts_CROSS_IN,
|
|
];
|
|
|
|
|
|
for(c=[0:len(switch_config)-1], r=[0:len(switch_config[c])-1])
|
|
translate(switch_config[c][r][t_pos])
|
|
rotate(switch_config[c][r][r_pos]) {
|
|
if($show_switches == true)
|
|
switch(0, $show_keycaps ? switch_config[c][r][k_pos][0]: "none", switch_config[c][r][k_pos][1] );
|
|
|
|
if($show_switch_pcb == true)
|
|
translate([0,0,-switch_holder_height-amoeba_royale_pcb_h-$c])
|
|
amoeba_royale_pcb();
|
|
|
|
switch_holder_with_cutouts(type="B");
|
|
}
|
|
|
|
if($show_case == true)
|
|
for(j=[0:len(ctrl_pts)-1]) {
|
|
for(k=[0:len(ctrl_pts[j])-1]) {
|
|
g_S = bezier_surface(t_step, ctrl_pts[j][k]);
|
|
// g_S = sf_splines(t_step, ctrl_pts[j][k]);
|
|
sf_thicken(g_S, thickness,"FORWARD");
|
|
//function_grapher(g_S,thickness,"FORWARD");
|
|
}
|
|
}
|
|
|
|
if($show_case_plate == true)
|
|
for(j=[0:len(poly_pts)-1]) {
|
|
for(k=[0:len(poly_pts[j])-1]) {
|
|
all_cube_faces= [
|
|
[0,1,2,3], // bot
|
|
[4,5,1,0], // front
|
|
[7,6,5,4], // top
|
|
[5,6,2,1], // right
|
|
[6,7,3,2], // back
|
|
[7,4,0,3], // left
|
|
];
|
|
polyhedron(poly_pts[j][k], all_cube_faces);
|
|
}
|
|
}
|
|
// draw bezier_points
|
|
//if($show_case_debug == true)
|
|
%color("black")
|
|
for(k=[0:len(ctrl_pts)-1])
|
|
for(i=[0:len(ctrl_pts[k])-1])
|
|
for(j=[0:len(ctrl_pts[k][i])-1])
|
|
for(l=[0:len(ctrl_pts[k][i][j])-1])
|
|
translate(ctrl_pts[k][i][j][l])
|
|
{
|
|
//echo (ctrl_pts[k][i][j][l]);
|
|
sphere(d=1);
|
|
}
|
|
if($show_case_debug == false)
|
|
%color("blue")
|
|
for(k=[0:len(poly_pts)-1])
|
|
for(i=[0:len(poly_pts[k])-1])
|
|
for(j=[0:len(poly_pts[k][i])-1])
|
|
translate(poly_pts[k][i][j])
|
|
{
|
|
//echo (poly_pts[k][i][j][l]);
|
|
sphere(d=1);
|
|
}
|
|
}
|
|
|
|
|