diff --git a/README.md b/README.md index 5bc302c..d303b02 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Carefully monitor the output of the configurator when setting up your equipment. - [ ] Works with multiple devices - [ ] Has a visual interface - [ ] Can display temperature in Fahrenheit -- [ ] Allows you to configure usage/temperature switching +- [x] Allows you to configure usage/temperature switching ## What devices are supported? Unfortunately, it is impossible to try the configuration of a particular device without having it in hand. diff --git a/configurator.py b/configurator.py index c0a93f6..6cc087c 100755 --- a/configurator.py +++ b/configurator.py @@ -90,6 +90,19 @@ def selectNum(maximum: int, text, default: int = None): return selected +def selectFloat(maximum: float, text, default: float = 1): + while True: + selected = click.prompt(text, type=float, default=default) + if selected == 0: + print("Bye!") + exit(0) + if 0.100 <= selected <= maximum: + break + else: + print("Error:", selected, "is too low.") + return selected + + print("All modules are installed! Great! Well, let's now try to identify your device!") json_devices_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'user-devices.json5')) reedCustom = os.path.isfile(json_devices_file) @@ -249,11 +262,22 @@ def showSensors(): TARGET_ARGS.append("-z") TARGET_ARGS.append(f"{sensor_index}") +TARGET_ARGS.append("-o") +option = selectNum(3, 'Now enter type of data to display ' + '(temp - 1, usage - 2, both - 3, 0 - to exit the configurator)', 3) +TARGET_ARGS.append(f"{option}") + TARGET_ARGS.append("-i") -interval = selectNum(60, 'Now enter the data output interval in seconds ' - '(maximum - 60, 0 - to exit the configurator)', 2) +interval = selectFloat(60, 'Now enter the data output interval in seconds ' + '(min - 0.1, max - 60, 0 - to exit the configurator)', 1) TARGET_ARGS.append(f"{interval}") +if option == 3: + TARGET_ARGS.append("-hld") + hold = selectFloat(60, 'Now enter output switching interval in seconds' + '(min - 1, max - 60, 0 - to exit the configurator)', 10) + TARGET_ARGS.append(f"{hold}") + if reedCustom: TARGET_ARGS.append("-u") diff --git a/deepcool-digital-info.py b/deepcool-digital-info.py index 164e435..65424fd 100755 --- a/deepcool-digital-info.py +++ b/deepcool-digital-info.py @@ -9,7 +9,9 @@ CUR_DEVICE = "CUSTOM" SENSOR = 'k10temp' SENSOR_INDEX = 0 +OPTION = 3 INTERVAL = 1 +HOLD = 10 class DeviceInfo: @@ -35,7 +37,9 @@ def __init__(self, vendor_id, product_id, simple_mode): 'device') parser.add_argument('-d', '--device', nargs='?', help='select your device name in json (--json-devices req)', default=CUR_DEVICE) -parser.add_argument('-i', '--interval', type=int, nargs='?', help='display refresh timing in seconds', default=INTERVAL) +parser.add_argument('-o', '--option', type=int, nargs='?', help='display temp or util', default=OPTION) +parser.add_argument('-i', '--interval', type=float, nargs='?', help='display refresh timing in seconds', default=INTERVAL) +parser.add_argument('-hld', '--hold', type=float, nargs='?', help='display switch timing in seconds', default=HOLD) parser.add_argument('-j', '--json-devices', nargs='?', help='path to the device configuration file in the form of a ' 'json-file', default=None) parser.add_argument('-s', '--sensor', default=SENSOR, nargs='?', type=str) @@ -54,7 +58,9 @@ def __init__(self, vendor_id, product_id, simple_mode): "don't worry about it)", default=None) args = parser.parse_args() +OPTION = args.option INTERVAL = args.interval +HOLD = args.hold SENSOR = args.sensor SENSOR_INDEX = args.sensor_index CUR_DEVICE = args.device @@ -188,12 +194,20 @@ def get_usage(is_test: bool = False): continue hidDevice.set_nonblocking(1) - temp = get_data_complex(value=get_temperature(TST_MODE), mode='temp') - hidDevice.write(temp) - time.sleep(INTERVAL) - utils = get_data_complex(value=get_usage(TST_MODE), mode='util') - hidDevice.write(utils) - time.sleep(INTERVAL) + if OPTION in (1, 3): + holdtemp = HOLD + while holdtemp >= INTERVAL: + temp = get_data_complex(value=get_temperature(TST_MODE), mode='temp') + hidDevice.write(temp) + holdtemp -= INTERVAL + time.sleep(INTERVAL) + if OPTION in (2, 3): + holdutils = HOLD + while holdutils >= INTERVAL: + utils = get_data_complex(value=get_usage(TST_MODE), mode='util') + hidDevice.write(utils) + holdutils -= INTERVAL + time.sleep(INTERVAL) except IOError as ex: print(ex) print("Failed to open device for writing. Either you are using the wrong device (incorrect VENDOR_ID/PRODUCT_ID), "