Skip to content

Commit

Permalink
Added config update to add new parameters to config. Retained ability…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
joshreve committed Aug 22, 2021
1 parent 4c179f9 commit 9e2c0c3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
debug_*
*/__pycache__/*
*~$*
things/
configs/*.json
things/
Empty file added gallery/.gitkeep
Empty file.
33 changes: 15 additions & 18 deletions src/dactyl_manuform.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ def rad2deg(rad: float) -> float:
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.
Expand Down Expand Up @@ -152,15 +158,6 @@ def debugprint(info):
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)
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion src/generate_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,13 @@

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
Expand Down
2 changes: 1 addition & 1 deletion src/run_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9e2c0c3

Please sign in to comment.