diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dactyl_manuform.py | 15 | ||||
-rw-r--r-- | src/generate_configuration.py | 30 | ||||
-rw-r--r-- | src/run_config.json | 260 |
3 files changed, 24 insertions, 281 deletions
diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index bb164b5..5677791 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -1,6 +1,7 @@ import numpy as np from numpy import pi import os.path as path +import getopt, sys import json import os @@ -23,11 +24,15 @@ import generate_configuration as cfg for item in cfg.shape_config: locals()[item] = cfg.shape_config[item] -## LOAD RUN CONFIGURATION FILE AND WRITE TO ANY VARIABLES IN FILE. -with open('run_config.json', mode='r') as fid: - data = json.load(fid) -for item in data: - locals()[item] = data[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] + # Really rough setup. Check for ENGINE, set it not present from configuration. try: diff --git a/src/generate_configuration.py b/src/generate_configuration.py index e2d71b0..08d02ff 100644 --- a/src/generate_configuration.py +++ b/src/generate_configuration.py @@ -1,3 +1,6 @@ +import sys +import getopt +import os import json @@ -301,23 +304,18 @@ 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: + # Check to see if the user has specified an alternate config + opts, args = getopt.getopt(sys.argv[1:], "", ["config="]); + 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 + + # Write the config to ./configs/<config_name>.json + with open(os.path.join(r"..", "configs", shape_config['config_name'] + '.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 diff --git a/src/run_config.json b/src/run_config.json deleted file mode 100644 index 627b536..0000000 --- a/src/run_config.json +++ /dev/null @@ -1,260 +0,0 @@ -{ - "ENGINE": "solid", - "save_dir": "DM_4x5_NOTCHPLT_DEFTMB_NOLED_EXTCTRL", - "config_name": "DM_4x5_NOTCHPLT_DEFTMB_NOLED_EXTCTRL", - "show_caps": false, - "nrows": 4, - "ncols": 5, - "alpha": 0.26179916666666664, - "beta": 0.08726638888888888, - "centercol": 3, - "centerrow_offset": 3, - "tenting_angle": 0.26179916666666664, - "symmetry": "symmetric", - "column_style_gt5": "orthographic", - "column_style": "standard", - "thumb_offsets": [ - 6, - -3, - 7 - ], - "keyboard_z_offset": 11, - "thumb_style": "DEFAULT", - "default_1U_cluster": true, - "minidox_Usize": 1.6, - "thumb_plate_tr_rotation": 0.0, - "thumb_plate_tl_rotation": 0.0, - "thumb_plate_mr_rotation": 0.0, - "thumb_plate_ml_rotation": 0.0, - "thumb_plate_br_rotation": 0.0, - "thumb_plate_bl_rotation": 0.0, - "pinky_1_5U": false, - "first_1_5U_row": 0, - "last_1_5U_row": 5, - "extra_width": 2.5, - "extra_height": 1.0, - "wall_z_offset": 15, - "wall_x_offset": 5, - "wall_y_offset": 6, - "left_wall_x_offset": 12, - "left_wall_z_offset": 3, - "left_wall_lower_y_offset": 0, - "left_wall_lower_z_offset": 0, - "wall_thickness": 4.5, - "wall_base_y_thickness": 4.5, - "wall_base_x_thickness": 4.5, - "wall_base_back_thickness": 4.5, - "fixed_angles": [ - 0.17453277777777776, - 0.17453277777777776, - 0, - 0, - 0, - -0.26179916666666664, - -0.26179916666666664 - ], - "fixed_x": [ - -41.5, - -22.5, - 0, - 20.3, - 41.4, - 65.5, - 89.6 - ], - "fixed_z": [ - 12.1, - 8.3, - 0, - 5, - 10.7, - 14.5, - 17.5 - ], - "fixed_tenting": 0.0, - "plate_style": "NOTCH", - "hole_keyswitch_height": 14.0, - "hole_keyswitch_width": 14.0, - "nub_keyswitch_height": 14.4, - "nub_keyswitch_width": 14.4, - "undercut_keyswitch_height": 14.0, - "undercut_keyswitch_width": 14.0, - "notch_width": 5.0, - "sa_profile_key_height": 12.7, - "sa_length": 18.5, - "sa_double_length": 37.5, - "plate_thickness": 5.1, - "plate_rim": 2.0, - "clip_thickness": 1.4, - "clip_undercut": 1.0, - "undercut_transition": 0.2, - "plate_file": null, - "plate_offset": 0.0, - "oled_mount_type": "NONE", - "oled_center_row": 1.25, - "oled_translation_offset": [ - 0, - 0, - 4 - ], - "oled_rotation_offset": [ - 0, - 0, - 0 - ], - "oled_configurations": { - "UNDERCUT": { - "oled_mount_width": 15.0, - "oled_mount_height": 35.0, - "oled_mount_rim": 3.0, - "oled_mount_depth": 6.0, - "oled_mount_cut_depth": 20.0, - "oled_mount_location_xyz": [ - -80.0, - 20.0, - 45.0 - ], - "oled_mount_rotation_xyz": [ - 13.0, - 0.0, - -6.0 - ], - "oled_left_wall_x_offset_override": 28.0, - "oled_left_wall_z_offset_override": 0.0, - "oled_left_wall_lower_y_offset": 12.0, - "oled_left_wall_lower_z_offset": 5.0, - "oled_mount_undercut": 1.0, - "oled_mount_undercut_thickness": 2.0 - }, - "SLIDING": { - "oled_mount_width": 12.5, - "oled_mount_height": 25.0, - "oled_mount_rim": 2.5, - "oled_mount_depth": 8.0, - "oled_mount_cut_depth": 20.0, - "oled_mount_location_xyz": [ - -78.0, - 10.0, - 41.0 - ], - "oled_mount_rotation_xyz": [ - 6.0, - 0.0, - -3.0 - ], - "oled_left_wall_x_offset_override": 24.0, - "oled_left_wall_z_offset_override": 0.0, - "oled_left_wall_lower_y_offset": 12.0, - "oled_left_wall_lower_z_offset": 5.0, - "oled_thickness": 4.2, - "oled_edge_overlap_end": 6.5, - "oled_edge_overlap_connector": 5.5, - "oled_edge_overlap_thickness": 2.5, - "oled_edge_overlap_clearance": 2.5, - "oled_edge_chamfer": 2.0 - }, - "CLIP": { - "oled_mount_width": 12.5, - "oled_mount_height": 39.0, - "oled_mount_rim": 2.0, - "oled_mount_depth": 7.0, - "oled_mount_cut_depth": 20.0, - "oled_mount_location_xyz": [ - -78.0, - 20.0, - 42.0 - ], - "oled_mount_rotation_xyz": [ - 12.0, - 0.0, - -6.0 - ], - "oled_left_wall_x_offset_override": 24.0, - "oled_left_wall_z_offset_override": 0.0, - "oled_left_wall_lower_y_offset": 12.0, - "oled_left_wall_lower_z_offset": 5.0, - "oled_thickness": 4.2, - "oled_mount_bezel_thickness": 3.5, - "oled_mount_bezel_chamfer": 2.0, - "oled_mount_connector_hole": 6.0, - "oled_screen_start_from_conn_end": 6.5, - "oled_screen_length": 24.5, - "oled_screen_width": 10.5, - "oled_clip_thickness": 1.5, - "oled_clip_width": 6.0, - "oled_clip_overhang": 1.0, - "oled_clip_extension": 5.0, - "oled_clip_width_clearance": 0.5, - "oled_clip_undercut": 0.5, - "oled_clip_undercut_thickness": 2.5, - "oled_clip_y_gap": 0.2, - "oled_clip_z_gap": 0.2 - } - }, - "web_thickness": 4.0, - "post_size": 0.1, - "post_adj": 0, - "screws_offset": "INSIDE", - "screw_insert_height": 3.8, - "screw_insert_bottom_radius": 2.655, - "screw_insert_top_radius": 2.55, - "wire_post_height": 7, - "wire_post_overhang": 3.5, - "wire_post_diameter": 2.6, - "controller_mount_type": "EXTERNAL", - "external_holder_height": 12.5, - "external_holder_width": 28.75, - "external_holder_xoffset": -5.0, - "screw_hole_diameter": 2, - "base_thickness": 3.0, - "base_offset": 3.0, - "base_rim_thickness": 5.0, - "screw_cbore_diameter": 4.0, - "screw_cbore_depth": 2.0, - "plate_holes": false, - "plate_holes_xy_offset": [ - 0.0, - 0.0 - ], - "plate_holes_width": 14.3, - "plate_holes_height": 14.3, - "plate_holes_diameter": 1.7, - "plate_holes_depth": 20.0, - "column_offsets": [ - [ - 0, - 0, - 0 - ], - [ - 0, - 0, - 0 - ], - [ - 0, - 2.82, - -4.5 - ], - [ - 0, - 0, - 0 - ], - [ - 0, - -6, - 5 - ], - [ - 0, - -6, - 5 - ], - [ - 0, - -6, - 5 - ] - ] -}
\ No newline at end of file |