From aa204f4d6499851488659ffae63044b389d017a7 Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Mon, 5 Jul 2021 14:16:35 -0400 Subject: Mid-change commit. Added DM mini and carbonfet thumb clusters. Still tweaking screw locations and relative OLED, etc. Commiting to share progress. --- src/dactyl_manuform.py | 984 +++++++++++++++++++++++++++++++++++----- src/dactyl_manuform_cadquery.py | 6 + src/generate_configuration.py | 20 +- src/run.py | 7 +- src/run_config.json | 4 + 5 files changed, 894 insertions(+), 127 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 780c23a..352e0ad 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -13,6 +13,13 @@ def rad2deg(rad: float) -> float: return rad * 180 / pi + +## IMPORT DEFAULT CONFIG IN CASE NEW PARAMETERS EXIST +import src.generate_configuration as cfg +for item in cfg.shape_config: + locals()[item] = cfg.shape_config[item] + +## LOAD RUN CONFIGURATION FILE with open('run_config.json', mode='r') as fid: data = json.load(fid) for item in data: @@ -136,14 +143,27 @@ def sa_cap(Usize=1): # MODIFIED TO NOT HAVE THE ROTATION. NEEDS ROTATION DURING ASSEMBLY sa_length = 18.25 - bw2 = Usize * sa_length / 2 - bl2 = sa_length / 2 - m = 0 - pw2 = 6 * Usize + 1 - pl2 = 6 - if Usize == 1: + bl2 = 18.5/2 + bw2 = 18.5/2 m = 17 / 2 + pl2 = 6 + pw2 = 6 + + elif Usize == 2: + bl2 = sa_length + bw2 = sa_length / 2 + m = 0 + pl2 = 16 + pw2 = 6 + + elif Usize == 1.5: + bl2 = sa_length / 2 + bw2 = 27.94 / 2 + m = 0 + pl2 = 6 + pw2 = 11 + k1 = sl.polygon([[bw2, bl2], [bw2, -bl2], [-bw2, -bl2], [-bw2, bl2]]) k1 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(k1) @@ -202,6 +222,13 @@ column_radius = ( column_x_delta = -1 - column_radius * np.sin(beta) column_base_angle = beta * (centercol - 2) +def offset_for_column(col, row): + if pinky_1_5U and ( + col == lastcol and row <= last_1_5U and row >= first_1_5U + ): + return 4.7625 + else: + return 0 def apply_key_geometry( shape, @@ -235,7 +262,7 @@ def apply_key_geometry( shape = translate_fn(shape, [0, column_offset(column)[1], 0]) else: - shape = translate_fn(shape, [0, 0, -row_radius]) + shape = translate_fn(shape, [offset_for_column(column, row), 0, -row_radius]) shape = rotate_x_fn(shape, alpha * (centerrow - row)) shape = translate_fn(shape, [0, 0, row_radius]) shape = translate_fn(shape, [0, 0, -column_radius]) @@ -313,30 +340,47 @@ def web_post(): post_adj = post_size / 2 -def web_post_tr(): +def web_post_tr(wide=False): + if wide: + w_divide = 1.2 + else: + w_divide = 2.0 return sl.translate( - [(mount_width / 2) - post_adj, (mount_height / 2) - post_adj, 0] - )(web_post()) - + [(mount_width / w_divide) - post_adj, (mount_height / 2) - post_adj, 0] + )(web_post()) -def web_post_tl(): +def web_post_tl(wide=False): + if wide: + w_divide = 1.2 + else: + w_divide = 2.0 return sl.translate( - [-(mount_width / 2) + post_adj, (mount_height / 2) - post_adj, 0] + [-(mount_width / w_divide) + post_adj, (mount_height / 2) - post_adj, 0] )(web_post()) -def web_post_bl(): +def web_post_bl(wide=False): + if wide: + w_divide = 1.2 + else: + w_divide = 2.0 return sl.translate( - [-(mount_width / 2) + post_adj, -(mount_height / 2) + post_adj, 0] + [-(mount_width / w_divide) + post_adj, -(mount_height / 2) + post_adj, 0] )(web_post()) -def web_post_br(): +def web_post_br(wide=False): + if wide: + w_divide = 1.2 + else: + w_divide = 2.0 return sl.translate( - [(mount_width / 2) - post_adj, -(mount_height / 2) + post_adj, 0] + [(mount_width / w_divide) - post_adj, -(mount_height / 2) + post_adj, 0] )(web_post()) + + def triangle_hulls(shapes): hulls = [] for i in range(len(shapes) - 2): @@ -459,30 +503,73 @@ def thumb_15x_layout(shape): return sl.union()(thumb_tr_place(shape), thumb_tl_place(shape), ) -def double_plate(): +def double_plate_half(): plate_height = (sa_double_length - mount_height) / 3 # plate_height = (2*sa_length-mount_height) / 3 top_plate = sl.cube([mount_width, plate_height, web_thickness], center=True) top_plate = sl.translate( [0, (plate_height + mount_height) / 2, plate_thickness - (web_thickness / 2)] )(top_plate) + + return top_plate + + +def double_plate(): + # plate_height = (sa_double_length - mount_height) / 3 + # # plate_height = (2*sa_length-mount_height) / 3 + # top_plate = sl.cube([mount_width, plate_height, web_thickness], center=True) + # top_plate = sl.translate( + # [0, (plate_height + mount_height) / 2, plate_thickness - (web_thickness / 2)] + # )(top_plate) + top_plate = double_plate_half() return sl.union()(top_plate, sl.mirror([0, 1, 0])(top_plate)) +def thumb(side="right"): + if thumb_style == "MINI": + return mini_thumb(side) + elif thumb_style == "CARBONFET": + return carbonfet_thumb(side) + else: + return default_thumb(side) + + def thumbcaps(): + if thumb_style == "MINI": + return mini_thumbcaps() + elif thumb_style == "CARBONFET": + return carbonfet_thumbcaps() + else: + return default_thumbcaps() + +def thumb_connectors(): + if thumb_style == "MINI": + return mini_thumb_connectors() + elif thumb_style == "CARBONFET": + return carbonfet_thumb_connectors() + else: + return default_thumb_connectors() + + +def default_thumbcaps(): t1 = thumb_1x_layout(sa_cap(1)) t15 = thumb_15x_layout(sl.rotate(pi / 2, [0, 0, 1])(sa_cap(1.5))) return t1 + t15 -def thumb(side="right"): - # shape = thumb_1x_layout(single_plate(side=side)) - # shape += thumb_15x_layout(single_plate(side=side)) - # shape += thumb_15x_layout(double_plate()) + +def default_thumb(side="right"): shape = thumb_1x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) shape += thumb_15x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) shape += thumb_15x_layout(double_plate()) + + # shape = thumb_1x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) + # shape += thumb_tr_place(sl.rotate([0.0, 0.0, 90])(single_plate(side=side))) + # shape += thumb_tr_place(double_plate(side=side)) + # shape += thumb_tl_place(sl.rotate([0.0, 0.0, 90])(single_plate(side=side))) + # shape += thumb_tl_place(double_plate(side=side)) + return shape @@ -510,7 +597,7 @@ def thumb_post_br(): )(web_post()) -def thumb_connectors(): +def default_thumb_connectors(): hulls = [] # Top two @@ -648,6 +735,518 @@ def thumb_connectors(): return sl.union()(*hulls) +############################ +# MINI THUMB CLUSTER +############################ + + +def mini_thumb_tr_place(shape): + shape = sl.rotate(14, [1, 0, 0])(shape) + shape = sl.rotate(-15, [0, 1, 0])(shape) + shape = sl.rotate(10, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-15, -10, 5])(shape) + return shape + + +def mini_thumb_tl_place(shape): + shape = sl.rotate(10, [1, 0, 0])(shape) + shape = sl.rotate(-23, [0, 1, 0])(shape) + shape = sl.rotate(25, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-35, -16, -2])(shape) + return shape + + +def mini_thumb_mr_place(shape): + shape = sl.rotate(10, [1, 0, 0])(shape) + shape = sl.rotate(-23, [0, 1, 0])(shape) + shape = sl.rotate(25, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-23, -34, -6])(shape) + return shape + + +def mini_thumb_br_place(shape): + shape = sl.rotate(6, [1, 0, 0])(shape) + shape = sl.rotate(-34, [0, 1, 0])(shape) + shape = sl.rotate(35, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-39, -43, -16])(shape) + return shape + + +def mini_thumb_bl_place(shape): + shape = sl.rotate(6, [1, 0, 0])(shape) + shape = sl.rotate(-32, [0, 1, 0])(shape) + shape = sl.rotate(35, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-51, -25, -11.5])(shape) + return shape + + +def mini_thumb_1x_layout(shape): + return sl.union()( + mini_thumb_mr_place(shape), + mini_thumb_br_place(shape), + mini_thumb_tl_place(shape), + mini_thumb_bl_place(shape), + ) + + +def mini_thumb_15x_layout(shape): + return sl.union()(mini_thumb_tr_place(shape)) + + +def mini_thumbcaps(): + t1 = mini_thumb_1x_layout(sa_cap(1)) + t15 = mini_thumb_15x_layout(sl.rotate(pi / 2, [0, 0, 1])(sa_cap(1))) + return t1 + t15 + + +def mini_thumb(side="right"): + + # shape = thumb_1x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) + # shape += thumb_15x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) + shape = mini_thumb_1x_layout(single_plate(side=side)) + shape += mini_thumb_15x_layout(single_plate(side=side)) + + return shape + + +def mini_thumb_post_tr(): + return sl.translate( + [(mount_width / 2) - post_adj, (mount_height / 2) - post_adj, 0] + )(web_post()) + + +def mini_thumb_post_tl(): + return sl.translate( + [-(mount_width / 2) + post_adj, (mount_height / 2) - post_adj, 0] + )(web_post()) + + +def mini_thumb_post_bl(): + return sl.translate( + [-(mount_width / 2) + post_adj, -(mount_height / 2) + post_adj, 0] + )(web_post()) + + +def mini_thumb_post_br(): + return sl.translate( + [(mount_width / 2) - post_adj, -(mount_height / 2) + post_adj, 0] + )(web_post()) + + +def mini_thumb_connectors(): + hulls = [] + + # Top two + hulls.append( + triangle_hulls( + [ + mini_thumb_tl_place(web_post_tr()), + mini_thumb_tl_place(web_post_br()), + mini_thumb_tr_place(mini_thumb_post_tl()), + mini_thumb_tr_place(mini_thumb_post_bl()), + ] + ) + ) + + # bottom two on the right + hulls.append( + triangle_hulls( + [ + mini_thumb_br_place(web_post_tr()), + mini_thumb_br_place(web_post_br()), + mini_thumb_mr_place(web_post_tl()), + mini_thumb_mr_place(web_post_bl()), + ] + ) + ) + + # bottom two on the left + hulls.append( + triangle_hulls( + [ + mini_thumb_mr_place(web_post_tr()), + mini_thumb_mr_place(web_post_br()), + mini_thumb_tr_place(mini_thumb_post_br()), + ] + ) + ) + + # between top and bottom row + hulls.append( + triangle_hulls( + [ + mini_thumb_br_place(web_post_tl()), + mini_thumb_bl_place(web_post_bl()), + mini_thumb_br_place(web_post_tr()), + mini_thumb_bl_place(web_post_br()), + mini_thumb_mr_place(web_post_tl()), + mini_thumb_tl_place(web_post_bl()), + mini_thumb_mr_place(web_post_tr()), + mini_thumb_tl_place(web_post_br()), + mini_thumb_tr_place(web_post_bl()), + mini_thumb_mr_place(web_post_tr()), + mini_thumb_tr_place(web_post_br()), + ] + ) + ) + # top two to the main keyboard, starting on the left + hulls.append( + triangle_hulls( + [ + mini_thumb_tl_place(web_post_tl()), + mini_thumb_bl_place(web_post_tr()), + mini_thumb_tl_place(web_post_bl()), + mini_thumb_bl_place(web_post_br()), + mini_thumb_mr_place(web_post_tr()), + mini_thumb_tl_place(web_post_bl()), + mini_thumb_tl_place(web_post_br()), + mini_thumb_mr_place(web_post_tr()), + ] + ) + ) + # top two to the main keyboard, starting on the left + hulls.append( + triangle_hulls( + [ + mini_thumb_tl_place(web_post_tl()), + key_place(web_post_bl(), 0, cornerrow), + mini_thumb_tl_place(web_post_tr()), + key_place(web_post_br(), 0, cornerrow), + mini_thumb_tr_place(mini_thumb_post_tl()), + key_place(web_post_bl(), 1, cornerrow), + mini_thumb_tr_place(mini_thumb_post_tr()), + key_place(web_post_br(), 1, cornerrow), + key_place(web_post_tl(), 2, lastrow), + key_place(web_post_bl(), 2, lastrow), + mini_thumb_tr_place(mini_thumb_post_tr()), + key_place(web_post_bl(), 2, lastrow), + mini_thumb_tr_place(mini_thumb_post_br()), + key_place(web_post_br(), 2, lastrow), + key_place(web_post_bl(), 3, lastrow), + key_place(web_post_tr(), 2, lastrow), + key_place(web_post_tl(), 3, lastrow), + key_place(web_post_bl(), 3, cornerrow), + key_place(web_post_tr(), 3, lastrow), + key_place(web_post_br(), 3, cornerrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_br(), 1, cornerrow), + key_place(web_post_tl(), 2, lastrow), + key_place(web_post_bl(), 2, cornerrow), + key_place(web_post_tr(), 2, lastrow), + key_place(web_post_br(), 2, cornerrow), + key_place(web_post_bl(), 3, cornerrow), + ] + ) + ) + + # hulls.append( + # triangle_hulls( + # [ + # key_place(web_post_tr(), 3, lastrow), + # key_place(web_post_br(), 3, lastrow), + # key_place(web_post_tr(), 3, lastrow), + # key_place(web_post_bl(), 4, cornerrow), + # ] + # ) + # ) + + return sl.union()(*hulls) + + +############################ +# Carbonfet THUMB CLUSTER +############################ + + +def carbonfet_thumb_tl_place(shape): + shape = sl.rotate(10, [1, 0, 0])(shape) + shape = sl.rotate(-24, [0, 1, 0])(shape) + shape = sl.rotate(10, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-13, -9.8, 4])(shape) + + return shape + +def carbonfet_thumb_tr_place(shape): + shape = sl.rotate(6, [1, 0, 0])(shape) + shape = sl.rotate(-24, [0, 1, 0])(shape) + shape = sl.rotate(10, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-7.5, -29.5, 0])(shape) + return shape + +def carbonfet_thumb_ml_place(shape): + shape = sl.rotate(8, [1, 0, 0])(shape) + shape = sl.rotate(-31, [0, 1, 0])(shape) + shape = sl.rotate(14, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-30.5, -17, -6])(shape) + return shape + +def carbonfet_thumb_mr_place(shape): + shape = sl.rotate(4, [1, 0, 0])(shape) + shape = sl.rotate(-31, [0, 1, 0])(shape) + shape = sl.rotate(14, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-22.2, -41, -10.3])(shape) + return shape + +def carbonfet_thumb_br_place(shape): + shape = sl.rotate(2, [1, 0, 0])(shape) + shape = sl.rotate(-37, [0, 1, 0])(shape) + shape = sl.rotate(18, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-37, -46.4, -22])(shape) + return shape + +def carbonfet_thumb_bl_place(shape): + shape = sl.rotate(6, [1, 0, 0])(shape) + shape = sl.rotate(-37, [0, 1, 0])(shape) + shape = sl.rotate(18, [0, 0, 1])(shape) + shape = sl.translate(thumborigin())(shape) + shape = sl.translate([-47, -23, -19])(shape) + return shape + + +def carbonfet_thumb_1x_layout(shape): + return sl.union()( + # carbonfet_thumb_tr_place(sl.rotate(pi / 2, [0, 0, 1])(shape)), + carbonfet_thumb_tr_place(shape), + carbonfet_thumb_mr_place(shape), + carbonfet_thumb_br_place(shape), + # carbonfet_thumb_tl_place(sl.rotate(pi / 2, [0, 0, 1])(shape)), + carbonfet_thumb_tl_place(shape), + ) + + +def carbonfet_thumb_15x_layout(shape): + return sl.union()( + carbonfet_thumb_bl_place(shape), + carbonfet_thumb_ml_place(shape) + ) + + +def carbonfet_thumbcaps(): + t1 = carbonfet_thumb_1x_layout(sa_cap(1)) + t15 = carbonfet_thumb_15x_layout(sl.rotate(pi / 2, [0, 0, 1])(sa_cap(1.5))) + return t1 + t15 + + +def carbonfet_thumb(side="right"): + # shape = thumb_1x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) + # shape += thumb_15x_layout(sl.rotate([0.0, 0.0, -90])(single_plate(side=side))) + shape = carbonfet_thumb_1x_layout(single_plate(side=side)) + shape += carbonfet_thumb_15x_layout(double_plate_half()) + shape += carbonfet_thumb_15x_layout(single_plate(side=side)) + + return shape + +def carbonfet_thumb_post_tr(): + return sl.translate( + [(mount_width / 2) - post_adj, (mount_height / 1.15) - post_adj, 0] + )(web_post()) + + +def carbonfet_thumb_post_tl(): + return sl.translate( + [-(mount_width / 2) + post_adj, (mount_height / 1.15) - post_adj, 0] + )(web_post()) + + +def carbonfet_thumb_post_bl(): + return sl.translate( + [-(mount_width / 2) + post_adj, -(mount_height / 1.15) + post_adj, 0] + )(web_post()) + + +def carbonfet_thumb_post_br(): + return sl.translate( + [(mount_width / 2) - post_adj, -(mount_height / 2) + post_adj, 0] + )(web_post()) + +def carbonfet_thumb_connectors(): + hulls = [] + + # Top two + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_tl_place(web_post_tl()), + carbonfet_thumb_tl_place(web_post_bl()), + carbonfet_thumb_ml_place(carbonfet_thumb_post_tr()), + carbonfet_thumb_ml_place(web_post_br()), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_ml_place(carbonfet_thumb_post_tl()), + carbonfet_thumb_ml_place(web_post_bl()), + carbonfet_thumb_bl_place(carbonfet_thumb_post_tr()), + carbonfet_thumb_bl_place(web_post_br()), + ] + ) + ) + + # bottom two on the right + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_br_place(web_post_tr()), + carbonfet_thumb_br_place(web_post_br()), + carbonfet_thumb_mr_place(web_post_tl()), + carbonfet_thumb_mr_place(web_post_bl()), + ] + ) + ) + + # bottom two on the left + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_mr_place(web_post_tr()), + carbonfet_thumb_mr_place(web_post_br()), + carbonfet_thumb_tr_place(web_post_tl()), + carbonfet_thumb_tr_place(web_post_bl()), + ] + ) + ) + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_tr_place(web_post_br()), + carbonfet_thumb_tr_place(web_post_bl()), + carbonfet_thumb_mr_place(web_post_br()), + ] + ) + ) + + # between top and bottom row + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_br_place(web_post_tl()), + carbonfet_thumb_bl_place(web_post_bl()), + carbonfet_thumb_br_place(web_post_tr()), + carbonfet_thumb_bl_place(web_post_br()), + carbonfet_thumb_mr_place(web_post_tl()), + carbonfet_thumb_ml_place(web_post_bl()), + carbonfet_thumb_mr_place(web_post_tr()), + carbonfet_thumb_ml_place(web_post_br()), + carbonfet_thumb_tr_place(web_post_tl()), + carbonfet_thumb_tl_place(web_post_bl()), + carbonfet_thumb_tr_place(web_post_tr()), + carbonfet_thumb_tl_place(web_post_br()), + ] + ) + ) + # top two to the main keyboard, starting on the left + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_ml_place(carbonfet_thumb_post_tl()), + key_place(web_post_bl(), 0, cornerrow), + carbonfet_thumb_ml_place(carbonfet_thumb_post_tr()), + key_place(web_post_br(), 0, cornerrow), + carbonfet_thumb_tl_place(web_post_tl()), + key_place(web_post_bl(), 1, cornerrow), + carbonfet_thumb_tl_place(web_post_tr()), + key_place(web_post_br(), 1, cornerrow), + key_place(web_post_tl(), 2, lastrow), + key_place(web_post_bl(), 2, lastrow), + carbonfet_thumb_tl_place(web_post_tr()), + key_place(web_post_bl(), 2, lastrow), + carbonfet_thumb_tl_place(web_post_br()), + key_place(web_post_br(), 2, lastrow), + key_place(web_post_bl(), 3, lastrow), + carbonfet_thumb_tl_place(web_post_br()), + carbonfet_thumb_tr_place(web_post_tr()), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_tr(), 3, lastrow), + key_place(web_post_br(), 3, cornerrow), + key_place(web_post_tl(), 3, lastrow), + key_place(web_post_bl(), 3, cornerrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_tr(), 2, lastrow), + key_place(web_post_br(), 2, lastrow), + key_place(web_post_tl(), 3, lastrow), + key_place(web_post_bl(), 3, lastrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + carbonfet_thumb_tr_place(web_post_br()), + carbonfet_thumb_tr_place(web_post_tr()), + key_place(web_post_bl(), 3, lastrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_br(), 1, cornerrow), + key_place(web_post_tl(), 2, lastrow), + key_place(web_post_bl(), 2, cornerrow), + key_place(web_post_tr(), 2, lastrow), + key_place(web_post_br(), 2, cornerrow), + key_place(web_post_tl(), 3, lastrow), + key_place(web_post_bl(), 3, cornerrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_tr(), 3, lastrow), + key_place(web_post_br(), 3, lastrow), + key_place(web_post_bl(), 4, cornerrow), + ] + ) + ) + + hulls.append( + triangle_hulls( + [ + key_place(web_post_tr(), 3, lastrow), + key_place(web_post_br(), 3, cornerrow), + key_place(web_post_bl(), 4, cornerrow), + ] + ) + ) + + + return sl.union()(*hulls) + ########## ## Case ## ########## @@ -756,32 +1355,64 @@ def back_wall(): def right_wall(): - y = 0 - shape = key_wall_brace( - lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br() - ) - for i in range(lastrow - 1): - y = i + 1 - shape += key_wall_brace( - lastcol, y - 1, 1, 0, web_post_br(), lastcol, y, 1, 0, web_post_tr() - ) + if pinky_1_5U: + if first_1_5U_row > 0: + shape = key_wall_brace( + lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 1, 0, web_post_tr()) + else: + shape = key_wall_brace( + lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 0, 1, web_post_tr(wide=True)) + shape += key_wall_brace( + lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 1, 0, web_post_tr(wide=True)) shape += key_wall_brace( + lastcol, 0, 0, -1, web_post_br(), lastcol, 0, 1, 0, web_post_br()) + + if first_1_5U_row >= 2: + for y in range(first_1_5U_row - 1): + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br()) + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_br(), lastcol, y-1, 1, 0, web_post_tr()) + + if first_1_5U_row >= 1: + for i in range(2): + y = first_1_5U_row - 1 + i + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_tr(), lastcol, y-1, 1, 0, web_post_tr(wide=True)) + + for i in range(2): + y = first_1_5U_row + i + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_tr(wide=True), lastcol, y, 1, 0, web_post_br(wide=True)) + + for i in range(first_1_5U_row - last_1_5U_row): + y = first_1_5U_row + i + shape += key_wall_brace( + lastcol, y+1, 1, 0, web_post_tr(wide=True), lastcol, y, 1, 0, web_post_br(wide=True)) + + if first_1_5U_row >= 1: + for i in range(2): + y = first_1_5U_row - 1 + i + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_tr(), lastcol, y-1, 1, 0, web_post_tr(wide=True)) + + else: + y = 0 + shape = key_wall_brace( lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br() ) + for i in range(lastrow - 1): + y = i + 1 + shape += key_wall_brace( + lastcol, y - 1, 1, 0, web_post_br(), lastcol, y, 1, 0, web_post_tr()) + + shape += key_wall_brace( + lastcol, y, 1, 0, web_post_tr(), lastcol, y, 1, 0, web_post_br()) + + shape += key_wall_brace( + lastcol, cornerrow, 0, -1, web_post_br(), lastcol, cornerrow, 1, 0, web_post_br()) - shape += key_wall_brace( - lastcol, - cornerrow, - 0, - -1, - web_post_br(), - lastcol, - cornerrow, - 1, - 0, - web_post_br(), - ) return shape @@ -874,71 +1505,48 @@ def front_wall(): return shape - def thumb_walls(): + if thumb_style == "MINI": + return mini_thumb_walls() + elif thumb_style == "CARBONFET": + return carbonfet_thumb_walls() + else: + return default_thumb_walls() + +def thumb_connection(): + if thumb_style == "MINI": + return mini_thumb_connection() + elif thumb_style == "CARBONFET": + return carbonfet_thumb_connection() + else: + return default_thumb_connection() + +def default_thumb_walls(): # thumb, walls - shape = wall_brace( - thumb_mr_place, 0, -1, web_post_br(), thumb_tr_place, 0, -1, thumb_post_br() - ) - shape += wall_brace( - thumb_mr_place, 0, -1, web_post_br(), thumb_mr_place, 0, -1, web_post_bl() - ) - shape += wall_brace( - thumb_br_place, 0, -1, web_post_br(), thumb_br_place, 0, -1, web_post_bl() - ) - shape += wall_brace( - thumb_ml_place, -0.3, 1, web_post_tr(), thumb_ml_place, 0, 1, web_post_tl() - ) - shape += wall_brace( - thumb_bl_place, 0, 1, web_post_tr(), thumb_bl_place, 0, 1, web_post_tl() - ) - shape += wall_brace( - thumb_br_place, -1, 0, web_post_tl(), thumb_br_place, -1, 0, web_post_bl() - ) - shape += wall_brace( - thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, -1, 0, web_post_bl() - ) + shape = wall_brace(thumb_mr_place, 0, -1, web_post_br(), thumb_tr_place, 0, -1, thumb_post_br()) + shape += wall_brace(thumb_mr_place, 0, -1, web_post_br(), thumb_mr_place, 0, -1, web_post_bl()) + shape += wall_brace(thumb_br_place, 0, -1, web_post_br(), thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(thumb_ml_place, -0.3, 1, web_post_tr(), thumb_ml_place, 0, 1, web_post_tl()) + shape += wall_brace(thumb_bl_place, 0, 1, web_post_tr(), thumb_bl_place, 0, 1, web_post_tl()) + shape += wall_brace(thumb_br_place, -1, 0, web_post_tl(), thumb_br_place, -1, 0, web_post_bl()) + shape += wall_brace(thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, -1, 0, web_post_bl()) # thumb, corners - shape += wall_brace( - thumb_br_place, -1, 0, web_post_bl(), thumb_br_place, 0, -1, web_post_bl() - ) - shape += wall_brace( - thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, 0, 1, web_post_tl() - ) + shape += wall_brace(thumb_br_place, -1, 0, web_post_bl(), thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, 0, 1, web_post_tl()) # thumb, tweeners - shape += wall_brace( - thumb_mr_place, 0, -1, web_post_bl(), thumb_br_place, 0, -1, web_post_br() - ) - shape += wall_brace( - thumb_ml_place, 0, 1, web_post_tl(), thumb_bl_place, 0, 1, web_post_tr() - ) - shape += wall_brace( - thumb_bl_place, -1, 0, web_post_bl(), thumb_br_place, -1, 0, web_post_tl() - ) - shape += wall_brace( - thumb_tr_place, - 0, - -1, - thumb_post_br(), - (lambda sh: key_place(sh, 3, lastrow)), - 0, - -1, - web_post_bl(), - ) + shape += wall_brace(thumb_mr_place, 0, -1, web_post_bl(), thumb_br_place, 0, -1, web_post_br()) + shape += wall_brace(thumb_ml_place, 0, 1, web_post_tl(), thumb_bl_place, 0, 1, web_post_tr()) + shape += wall_brace(thumb_bl_place, -1, 0, web_post_bl(), thumb_br_place, -1, 0, web_post_tl()) + shape += wall_brace(thumb_tr_place, 0, -1, thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl()) return shape - -def thumb_connection(): +def default_thumb_connection(): # clunky bit on the top left thumb connection (normal connectors don't work well) shape = bottom_hull( [ - left_key_place( - sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1 - ), - left_key_place( - sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1 - ), + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), thumb_ml_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())), thumb_ml_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())), ] @@ -946,12 +1554,8 @@ def thumb_connection(): shape += sl.hull()( [ - left_key_place( - sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1 - ), - left_key_place( - sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1 - ), + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), thumb_ml_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())), thumb_ml_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())), thumb_tl_place(thumb_post_tl()), @@ -961,15 +1565,9 @@ def thumb_connection(): shape += sl.hull()( [ left_key_place(web_post(), cornerrow, -1), - left_key_place( - sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1 - ), - left_key_place( - sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1 - ), - left_key_place( - sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1 - ), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), thumb_tl_place(thumb_post_tl()), ] ) @@ -977,11 +1575,10 @@ def thumb_connection(): shape += sl.hull()( [ left_key_place(web_post(), cornerrow, -1), - left_key_place( - sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1 - ), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), key_place(web_post_bl(), 0, cornerrow), - key_place(sl.translate(wall_locate1(-1, 0))(web_post_bl()), 0, cornerrow), + # key_place(sl.translate(wall_locate1(-1, 0))(web_post_bl()), 0, cornerrow), + key_place(sl.translate(wall_locate1(0, 0))(web_post_bl()), 0, cornerrow), thumb_tl_place(thumb_post_tl()), ] ) @@ -999,6 +1596,152 @@ def thumb_connection(): return shape +def mini_thumb_walls(): + # thumb, walls + shape = wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_tr_place, 0, -1, mini_thumb_post_br()) + shape += wall_brace(mini_thumb_mr_place, 0, -1, web_post_br(), mini_thumb_mr_place, 0, -1, web_post_bl()) + shape += wall_brace(mini_thumb_br_place, 0, -1, web_post_br(), mini_thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(mini_thumb_bl_place, 0, 1, web_post_tr(), mini_thumb_bl_place, 0, 1, web_post_tl()) + shape += wall_brace(mini_thumb_br_place, -1, 0, web_post_tl(), mini_thumb_br_place, -1, 0, web_post_bl()) + shape += wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, -1, 0, web_post_bl()) + # thumb, corners + shape += wall_brace(mini_thumb_br_place, -1, 0, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(mini_thumb_bl_place, -1, 0, web_post_tl(), mini_thumb_bl_place, 0, 1, web_post_tl()) + # thumb, tweeners + shape += wall_brace(mini_thumb_mr_place, 0, -1, web_post_bl(), mini_thumb_br_place, 0, -1, web_post_br()) + shape += wall_brace(mini_thumb_bl_place, -1, 0, web_post_bl(), mini_thumb_br_place, -1, 0, web_post_tl()) + shape += wall_brace(mini_thumb_tr_place, 0, -1, mini_thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl()) + + return shape + +def mini_thumb_connection(): + # clunky bit on the top left thumb connection (normal connectors don't work well) + shape = bottom_hull( + [ + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + mini_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())), + mini_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())), + ] + ) + + shape += sl.hull()( + [ + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + mini_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())), + mini_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())), + mini_thumb_tl_place(web_post_tl()), + ] + ) + + shape += sl.hull()( + [ + left_key_place(web_post(), cornerrow, -1), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + mini_thumb_tl_place(web_post_tl()), + ] + ) + + shape += sl.hull()( + [ + left_key_place(web_post(), cornerrow, -1), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), + key_place(web_post_bl(), 0, cornerrow), + # key_place(sl.translate(wall_locate1(-1, 0))(web_post_bl()), 0, cornerrow), + mini_thumb_tl_place(web_post_tl()), + ] + ) + + shape += sl.hull()( + [ + mini_thumb_bl_place(web_post_tr()), + mini_thumb_bl_place(sl.translate(wall_locate1(-0.3, 1))(web_post_tr())), + mini_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())), + mini_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())), + mini_thumb_tl_place(web_post_tl()), + ] + ) + + return shape + + + +def carbonfet_thumb_walls(): + # thumb, walls + shape = wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_tr_place, 0, -1, web_post_br()) + shape += wall_brace(carbonfet_thumb_mr_place, 0, -1, web_post_br(), carbonfet_thumb_mr_place, 0, -1.15, web_post_bl()) + shape += wall_brace(carbonfet_thumb_br_place, 0, -1, web_post_br(), carbonfet_thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(carbonfet_thumb_bl_place, -.3, 1, thumb_post_tr(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl()) + shape += wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_tl(), carbonfet_thumb_br_place, -1, 0, web_post_bl()) + shape += wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, -1, 0, web_post_bl()) + # thumb, corners + shape += wall_brace(carbonfet_thumb_br_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_bl()) + shape += wall_brace(carbonfet_thumb_bl_place, -1, 0, thumb_post_tl(), carbonfet_thumb_bl_place, 0, 1, thumb_post_tl()) + # thumb, tweeners + shape += wall_brace(carbonfet_thumb_mr_place, 0, -1.15, web_post_bl(), carbonfet_thumb_br_place, 0, -1, web_post_br()) + # shape += wall_brace(thumb_ml_place, 0, 1, web_post_tl(), carbonfet_thumb_bl_place, 0, 1, web_post_tr()) + shape += wall_brace(carbonfet_thumb_bl_place, -1, 0, web_post_bl(), carbonfet_thumb_br_place, -1, 0, web_post_tl()) + shape += wall_brace(carbonfet_thumb_tr_place, 0, -1, web_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl()) + return shape + +def carbonfet_thumb_connection(): + # clunky bit on the top left thumb connection (normal connectors don't work well) + shape = bottom_hull( + [ + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + carbonfet_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(thumb_post_tr())), + ] + ) + + shape += sl.hull()( + [ + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + carbonfet_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_ml_place(thumb_post_tl()), + ] + ) + + shape += sl.hull()( + [ + left_key_place(web_post(), cornerrow, -1), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1), + left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1), + carbonfet_thumb_ml_place(thumb_post_tl()), + ] + ) + + shape += sl.hull()( + [ + left_key_place(web_post(), cornerrow, -1), + left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1), + key_place(web_post_bl(), 0, cornerrow), + # key_place(sl.translate(wall_locate1(-1, 0))(web_post_bl()), 0, cornerrow), + carbonfet_thumb_ml_place(thumb_post_tl()), + ] + ) + + shape += sl.hull()( + [ + carbonfet_thumb_bl_place(thumb_post_tr()), + carbonfet_thumb_bl_place(sl.translate(wall_locate1(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_bl_place(sl.translate(wall_locate2(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_bl_place(sl.translate(wall_locate3(-0.3, 1))(thumb_post_tr())), + carbonfet_thumb_ml_place(thumb_post_tl()), + ] + ) + + return shape + + + def case_walls(): return ( back_wall() @@ -1487,9 +2230,10 @@ def screw_insert_all_shapes(bottom_radius, top_radius, height): screw_insert(0, 0, bottom_radius, top_radius, height), # screw_insert(0, lastrow, bottom_radius, top_radius, height), screw_insert(0, lastrow - 1, bottom_radius, top_radius, height), - screw_insert(2, lastrow + 0.3, bottom_radius, top_radius, height), + screw_insert(3, lastrow, bottom_radius, top_radius, height), screw_insert(3, 0, bottom_radius, top_radius, height), - screw_insert(lastcol, 1, bottom_radius, top_radius, height), + screw_insert(lastcol, 0, bottom_radius, top_radius, height), + screw_insert(lastcol, lastrow - 1, bottom_radius, top_radius, height), ) return shape diff --git a/src/dactyl_manuform_cadquery.py b/src/dactyl_manuform_cadquery.py index 6514353..5e1a518 100644 --- a/src/dactyl_manuform_cadquery.py +++ b/src/dactyl_manuform_cadquery.py @@ -18,6 +18,12 @@ def rad2deg(rad: float) -> float: debug_exports = False +## IMPORT DEFAULT CONFIG IN CASE NEW PARAMETERS EXIST +import src.generate_configuration as cfg +for item in cfg.shape_config: + locals()[item] = cfg.shape_config[item] + +## LOAD RUN CONFIGURATION FILE with open('run_config.json', mode='r') as fid: data = json.load(fid) for item in data: diff --git a/src/generate_configuration.py b/src/generate_configuration.py index 7c34942..7a33a73 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -40,6 +40,17 @@ shape_config = { 9 # controls overall height# original=9 with centercol=3# use 16 for centercol=2 ), + + ############################## + # NEW TEST PARAMETERS + ############################## + 'pinky_1_5U': False, # LEAVE AS FALSE, CURRENTLY BROKEN + 'first_1_5U_row': 0, + 'last_1_5U_row': 5, + 'thumb_style': 'CARBONFET', #'DEFAULT', 'MINI', 'CARBONFET' + ############################## + + 'extra_width': 2.5, # extra space between the base of keys# original= 2 'extra_height': 1.0, # original= 0.5 @@ -223,8 +234,9 @@ shape_config = { ## END CONFIGURATION SECTION #################################### +def save_config(): + with open('run_config.json', mode='w') as fid: + json.dump(shape_config, fid, indent=4) - -with open('run_config.json', mode='w') as fid: - json.dump(shape_config, fid, indent=4) - +if __name__ == '__main__': + save_config() diff --git a/src/run.py b/src/run.py index edf3d44..f214bd5 100644 --- a/src/run.py +++ b/src/run.py @@ -3,10 +3,11 @@ # preference. You may want to back it up as another file name to prevent the generator from # overwriting your config history. +# import generate_configuration as cfg +# cfg.save_config() - -# ENGINE = 'solid' -ENGINE = 'cadquery' +ENGINE = 'solid' +# ENGINE = 'cadquery' if ENGINE == 'solid': exec(open('dactyl_manuform.py').read()) diff --git a/src/run_config.json b/src/run_config.json index 396dd70..46a1fd2 100644 --- a/src/run_config.json +++ b/src/run_config.json @@ -18,6 +18,10 @@ 7 ], "keyboard_z_offset": 9, + "pinky_1_5U": false, + "first_1_5U_row": 0, + "last_1_5U_row": 5, + "thumb_style": "CARBONFET", "extra_width": 2.5, "extra_height": 1.0, "wall_z_offset": 15, -- cgit v1.2.3