From 9e2c0c3b72eb0bb27210bf19d76e7e4b6f5ce295 Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Sat, 21 Aug 2021 20:31:07 -0400 Subject: Added config update to add new parameters to config. Retained ability to run the run_config.json file if there are no CLI arguments. Retained ability to run the run_config.json file if there are no CLI arguments. Will eventually deprecate run_config in favor of the configs directory, but don't want to mess up existing configs until they have time to migrate. Un-ignored configs. Would like to build a set of user configs through PRs to see variety. Add gallery directory for those with submit configs for people to see examples. All PRs for configs are expected to have identically named files (with some suffix for multiple) to show example images. --- src/dactyl_manuform.py | 33 +++++++++++++++------------------ src/generate_configuration.py | 8 +++++++- src/run_config.json | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 1dc1507..8156ca6 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -24,14 +24,20 @@ import generate_configuration as cfg for item in cfg.shape_config: locals()[item] = cfg.shape_config[item] -## CHECK FOR CONFIG FILE AND WRITE TO ANY VARIABLES IN FILE. -opts, args = getopt.getopt(sys.argv[1:], "", ["config="]); -for opt, arg in opts: - if opt in ('--config'): - with open(os.path.join(r"..", "configs", arg + '.json'), mode='r') as fid: - data = json.load(fid) - for item in data: - locals()[item] = data[item] +if len(sys.argv) <= 1: + with open(os.path.join(r".", 'run_config.json'), mode='r') as fid: + data = json.load(fid) + +else: + ## CHECK FOR CONFIG FILE AND WRITE TO ANY VARIABLES IN FILE. + opts, args = getopt.getopt(sys.argv[1:], "", ["config="]) + for opt, arg in opts: + if opt in ('--config'): + with open(os.path.join(r"..", "configs", arg + '.json'), mode='r') as fid: + data = json.load(fid) + +for item in data: + locals()[item] = data[item] # Really rough setup. Check for ENGINE, set it not present from configuration. @@ -152,15 +158,6 @@ teensy_holder_width = 7 + teensy_pcb_thickness teensy_holder_height = 6 + teensy_width - -# wire_post_height = 7 -# wire_post_overhang = 3.5 -# wire_post_diameter = 2.6 -# -# screw_insert_height = 3.8 -# screw_insert_bottom_radius = 5.31 / 2 -# screw_insert_top_radius = 5.1 / 2 - # save_path = path.join("..", "things", save_dir) if not path.isdir(save_path): os.mkdir(save_path) @@ -2605,7 +2602,7 @@ def thumb_walls(side='right', style_override=None): elif "TRACKBALL" in _thumb_style: if (side == ball_side or ball_side == 'both'): - if _thumb_style == "TRACKBALL_ORBYL" : + if _thumb_style == "TRACKBALL_ORBYL": return tbjs_thumb_walls() elif thumb_style == "TRACKBALL_CJ": return tbcj_thumb_walls() diff --git a/src/generate_configuration.py b/src/generate_configuration.py index 79ef5b3..7b0ef84 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -387,7 +387,13 @@ shape_config = { def save_config(): # Check to see if the user has specified an alternate config - opts, args = getopt.getopt(sys.argv[1:], "", ["config="]); + opts, args = getopt.getopt(sys.argv[1:], "", ["config=", "update="]) + 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) + for opt, arg in opts: if opt in ('--config'): # If a config file was specified, set the config_name and save_dir diff --git a/src/run_config.json b/src/run_config.json index cd7db76..3679941 100644 --- a/src/run_config.json +++ b/src/run_config.json @@ -20,7 +20,7 @@ 7 ], "keyboard_z_offset": 11, - "thumb_style": "TRACKBALL_CJ", + "thumb_style": "DEFAULT", "default_1U_cluster": true, "minidox_Usize": 1.6, "thumb_plate_tr_rotation": 0.0, -- cgit v1.2.3