From d3f03185529517ac1f542eb0f11245d4fd7b97c8 Mon Sep 17 00:00:00 2001 From: MachuMachu Date: Sun, 30 Jun 2024 05:25:10 +0800 Subject: [PATCH 1/4] Added display type and lowered minimum update interval - Added option to display temp, usage or both. - Changed update interval data type to float. --- configurator.py | 22 ++++++++++++++++++++-- deepcool-digital-info.py | 19 ++++++++++++------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/configurator.py b/configurator.py index c0a93f6..cf29ed4 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,9 +262,14 @@ def showSensors(): TARGET_ARGS.append("-z") TARGET_ARGS.append(f"{sensor_index}") +TARGET_ARGS.append("-o") +option = selectNum(3, 'Now enter what 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 reedCustom: diff --git a/deepcool-digital-info.py b/deepcool-digital-info.py index 164e435..e85ea94 100755 --- a/deepcool-digital-info.py +++ b/deepcool-digital-info.py @@ -9,6 +9,7 @@ CUR_DEVICE = "CUSTOM" SENSOR = 'k10temp' SENSOR_INDEX = 0 +OPTION = 3 INTERVAL = 1 @@ -35,7 +36,8 @@ 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('-i', '--interval', type=float, nargs='?', help='display refresh timing in seconds', default=INTERVAL) +parser.add_argument('-o', '--option', type=int, nargs='?', help='display temp or usage', default=OPTION) 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,6 +56,7 @@ 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 SENSOR = args.sensor SENSOR_INDEX = args.sensor_index @@ -188,12 +191,14 @@ 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): + temp = get_data_complex(value=get_temperature(TST_MODE), mode='temp') + hidDevice.write(temp) + time.sleep(INTERVAL) + if OPTION in (2, 3): + utils = get_data_complex(value=get_usage(TST_MODE), mode='util') + hidDevice.write(utils) + 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), " From 2458e9bee15eb0956f540698958012da19d33e01 Mon Sep 17 00:00:00 2001 From: MachuMachu Date: Sun, 30 Jun 2024 06:19:27 +0800 Subject: [PATCH 2/4] Added data type switching interval --- configurator.py | 8 +++++++- deepcool-digital-info.py | 23 ++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/configurator.py b/configurator.py index cf29ed4..cca7977 100755 --- a/configurator.py +++ b/configurator.py @@ -263,7 +263,7 @@ def showSensors(): TARGET_ARGS.append(f"{sensor_index}") TARGET_ARGS.append("-o") -option = selectNum(3, 'Now enter what data to display ' +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}") @@ -272,6 +272,12 @@ def showSensors(): '(min - 0.1, max - 60, 0 - to exit the configurator)', 1) TARGET_ARGS.append(f"{interval}") +if option == 3: + TARGET_ARGS.append("-hld") + hold = selectNum(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 e85ea94..65424fd 100755 --- a/deepcool-digital-info.py +++ b/deepcool-digital-info.py @@ -11,6 +11,7 @@ SENSOR_INDEX = 0 OPTION = 3 INTERVAL = 1 +HOLD = 10 class DeviceInfo: @@ -36,8 +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('-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('-o', '--option', type=int, nargs='?', help='display temp or usage', default=OPTION) +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) @@ -58,6 +60,7 @@ def __init__(self, vendor_id, product_id, simple_mode): 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 @@ -192,13 +195,19 @@ def get_usage(is_test: bool = False): hidDevice.set_nonblocking(1) if OPTION in (1, 3): - temp = get_data_complex(value=get_temperature(TST_MODE), mode='temp') - hidDevice.write(temp) - time.sleep(INTERVAL) + 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): - utils = get_data_complex(value=get_usage(TST_MODE), mode='util') - hidDevice.write(utils) - time.sleep(INTERVAL) + 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), " From 8181eea89fc7af10e0cf9d2e18ab429fe2337950 Mon Sep 17 00:00:00 2001 From: MachuMachu Date: Sun, 30 Jun 2024 06:23:03 +0800 Subject: [PATCH 3/4] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From d8571e1b530095cd9c28fd552e4545568196e525 Mon Sep 17 00:00:00 2001 From: MachuMachu Date: Sun, 30 Jun 2024 06:27:32 +0800 Subject: [PATCH 4/4] Changed display switching interval to accept float --- configurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configurator.py b/configurator.py index cca7977..6cc087c 100755 --- a/configurator.py +++ b/configurator.py @@ -274,7 +274,7 @@ def showSensors(): if option == 3: TARGET_ARGS.append("-hld") - hold = selectNum(60, 'Now enter output switching interval in seconds' + 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}")