diff options
author | Robert Reed <robert.mc.reed@gmail.com> | 2021-08-25 22:55:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 22:55:17 -0700 |
commit | 9741a5f4731dac2f4792a4b451d9a96dd1c2a381 (patch) | |
tree | cf9fba2dd539e6890899c9d1b33ebb81093cd4f2 /src/generate_configuration.py | |
parent | d937d7beb2d7d898dd937cd9e024952b56607403 (diff) | |
parent | 27f491bda62c18e314380ddc6456962a2417b84b (diff) |
Merge branch 'master' into feat/bash
Diffstat (limited to 'src/generate_configuration.py')
-rw-r--r-- | src/generate_configuration.py | 146 |
1 files changed, 120 insertions, 26 deletions
diff --git a/src/generate_configuration.py b/src/generate_configuration.py index e2d71b0..f5fa716 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -1,3 +1,6 @@ +import sys +import getopt +import os import json @@ -7,8 +10,8 @@ r2d = 180 / pi shape_config = { - 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade - # 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + 'ENGINE': 'solid', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade + # 'ENGINE': 'cadquery', # 'solid' = solid python / OpenSCAD, 'cadquery' = cadquery / OpenCascade ###################### @@ -18,7 +21,8 @@ shape_config = { 'save_dir': '.', 'config_name': "DM", - 'show_caps': False, + 'show_caps': True, + 'show_pcbs': False, #only runs if caps are shown, easist place to initially inject geometry 'nrows': 5, #5, # key rows 'ncols': 6, #6, # key columns @@ -43,11 +47,11 @@ shape_config = { ############################## # THUMB PARAMETERS ############################## - 'thumb_style': 'MINIDOX', # 'DEFAULT' 6-key, 'MINI' 5-key, 'CARBONFET' 6-key, 'MINIDOX' 3-key + # 'DEFAULT' 6-key, 'MINI' 5-key, 'CARBONFET' 6-key, 'MINIDOX' 3-key, 'TRACKBALL_ORBYL', 'TRACKBALL_CJ' + 'thumb_style': 'TRACKBALL_ORBYL', 'default_1U_cluster': True, # only used with default, makes top right thumb cluster key 1U - 'minidox_Usize': 1.6 - , # Thumb key size. May need slight oversizing, check w/ caps. Additional spacing will be automatically added for larger keys. - + # Thumb key size. May need slight oversizing, check w/ caps. Additional spacing will be automatically added for larger keys. + 'minidox_Usize': 1.6, # Thumb plate rotations, anything other than 90 degree increments WILL NOT WORK. 'thumb_plate_tr_rotation': 0.0, # Top right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. 'thumb_plate_tl_rotation': 0.0, # Top left plate rotation tweaks as thumb cluster is crowded for hot swap, etc. @@ -56,6 +60,74 @@ shape_config = { 'thumb_plate_br_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. 'thumb_plate_bl_rotation': 0.0, # Bottom right plate rotation tweaks as thumb cluster is crowded for hot swap, etc. + ################################### + ## Trackball in Wall ## + ################################### + 'trackball_in_wall': False, # Separate trackball option, placing it in the OLED area + 'tbiw_ball_center_row': 0.2, # up from cornerrow instead of down from top + 'tbiw_translational_offset': (0.0, 0.0, 0.0), + 'tbiw_rotation_offset': (0.0, 0.0, 0.0), + 'tbiw_left_wall_x_offset_override': 50.0, + 'tbiw_left_wall_z_offset_override': 0.0, + 'tbiw_left_wall_lower_y_offset': 0.0, + 'tbiw_left_wall_lower_z_offset': 0.0, + + 'tbiw_oled_center_row': .75, # not none, offsets are from this position + 'tbiw_oled_translation_offset': (-3.5, 0, 1.5), # Z offset tweaks are expected depending on curvature and OLED mount choice. + 'tbiw_oled_rotation_offset': (0, 0, 0), + + ########################################### + ## Trackball JS / ORBYL Thumb Cluster ## + ########################################## + 'other_thumb': 'DEFAULT', # cluster used for second thumb except if ball_side == 'both' + 'tbjs_key_diameter': 70, + # Offsets are per key and are applied before rotating into place around the ball + # X and Y act like Tangential and Radial around the ball + 'tbjs_translation_offset': (0, 0, 10), # applied to the whole assy + 'tbjs_rotation_offset': (0, 0, 0), # applied to the whole assy + 'tbjs_key_translation_offsets': [ + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + (0.0, 0.0, -3.0-5), + ], + 'tbjs_key_rotation_offsets': [ + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + (0.0, 0.0, 0.0), + ], + + ################################### + ## Trackball CJ Thumb Cluster ## + ################################### + 'tbcj_inner_diameter': 42, + 'tbcj_thickness': 2, + 'tbcj_outer_diameter': 53, + + + ################################### + ## Trackball General ## + ################################### + # EXPERIMENTAL + 'trackball_modular': False, # May add removable trackball in subsequent releases, no current use. + # END EXPERIMENTAL + + 'trackball_Usize': 1.5, # size for inner key near trackball + 'ball_side': 'right', #'left', 'right', or 'both' + 'ball_diameter': 34.0, + 'ball_wall_thickness': 3, # should not be changed unless the import models are changed. + 'ball_gap': 1.0, + 'trackball_hole_diameter': 36.5, + 'trackball_hole_height': 40, + 'trackball_plate_thickness': 2, + 'trackball_plate_width': 2, + # Removed trackball_rotation, ball_z_offset. and trackball_sensor_rotation and added more flexibility. + 'tb_socket_translation_offset': (0, 0, 2.0), # applied to the socket and sensor, large values will cause web/wall issues. + 'tb_socket_rotation_offset': (0, 0, 0), # applied to the socket and sensor, large values will cause web/wall issues. + 'tb_sensor_translation_offset': (0, 0, 0), #deviation from socket offsets, for fixing generated geometry issues + 'tb_sensor_rotation_offset': (0, 0, 0), #deviation from socket offsets, for changing the sensor roll orientation + ############################## # EXPERIMENTAL PARAMETERS ############################## @@ -237,6 +309,9 @@ shape_config = { 'wire_post_overhang': 3.5, 'wire_post_diameter': 2.6, + + + ################################### ## Controller Mount / Connectors ## ################################### @@ -252,7 +327,7 @@ shape_config = { 'external_holder_height': 12.5, 'external_holder_width': 28.75, 'external_holder_xoffset': -5.0, - + 'external_holder_yoffset': -4.5, #Tweak this value to get the right undercut for the tray engagement. # Offset is from the top inner corner of the top inner key. @@ -271,7 +346,7 @@ shape_config = { # Offset is from the top inner corner of the top inner key. ################################### - ## EXPERIMENTAL + ## HOLES ON PLATE FOR PCB MOUNT ################################### 'plate_holes': False, 'plate_holes_xy_offset': (0.0, 0.0), @@ -281,6 +356,16 @@ shape_config = { 'plate_holes_depth': 20.0, ################################### + ## SHOW PCB FOR FIT CHECK + ################################### + 'pcb_width': 18.0, + 'pcb_height': 18.0, + 'pcb_thickness': 1.5, + 'pcb_hole_diameter': 2, + 'pcb_hole_pattern_width': 14.3, + 'pcb_hole_pattern_height': 14.3, + + ################################### ## COLUMN OFFSETS #################################### @@ -301,23 +386,32 @@ shape_config = { #################################### def save_config(): - print("Saving Configuration") - with open('run_config.json', mode='w') as fid: - json.dump(shape_config, fid, indent=4) - -def update_config(fname, fname_out=None): - if fname_out is None: - fname_out == "updated_config.json" - # Open existing config, update with any new parameters, and save to updated_config.json - with open(fname, mode='r') as fid: - last_shape_config = json.load(fid) - shape_config.update(last_shape_config) - - with open(fname_out, mode='w') as fid: - json.dump(shape_config, fid, indent=4) + # Check to see if the user has specified an alternate config + opts, args = getopt.getopt(sys.argv[1:], "", ["config=", "update="]) + got_opts = False + for opt, arg in opts: + if opt in ('--update'): + with open(os.path.join(r"..", "configs", arg + '.json'), mode='r') as fid: + data = json.load(fid) + shape_config.update(data) + got_opts = True + + for opt, arg in opts: + if opt in ('--config'): + # If a config file was specified, set the config_name and save_dir + shape_config['save_dir'] = arg + shape_config['config_name'] = arg + got_opts = True + + # Write the config to ./configs/<config_name>.json + if got_opts: + with open(os.path.join(r"..", "configs", shape_config['config_name'] + '.json'), mode='w') as fid: + json.dump(shape_config, fid, indent=4) + + else: + with open(os.path.join(r".", 'run_config.json'), mode='w') as fid: + json.dump(shape_config, fid, indent=4) if __name__ == '__main__': - save_config() - from dactyl_manuform import * - run()
\ No newline at end of file + save_config()
\ No newline at end of file |