From c9c7a3dc960e4c16389f8269649e78bb0312b1f5 Mon Sep 17 00:00:00 2001 From: SofieLewis <55637872+SofieLewis@users.noreply.github.com> Date: Wed, 25 Sep 2019 15:23:45 +0100 Subject: [PATCH 1/3] Update automatic.py Correct typos when parsing arguments --- examples/automatic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/automatic.py b/examples/automatic.py index 846688f..57026dd 100755 --- a/examples/automatic.py +++ b/examples/automatic.py @@ -13,8 +13,8 @@ parser.add_argument('--threshold', type=float, default=-1, help='Temperature threshold in degrees C to enable fan') parser.add_argument('--hysteresis', type=float, default=-1, help='Distance from threshold before fan is disabled') -parser.add_argument('--off-threshold', type=float, default=55.0, help='Temperature threshold in degrees C to enable fan') -parser.add_argument('--on-threshold', type=float, default=65.0, help='Temperature threshold in degrees C to disable fan') +parser.add_argument('--off-threshold', type=float, default=55.0, help='Temperature threshold in degrees C to disable fan') +parser.add_argument('--on-threshold', type=float, default=65.0, help='Temperature threshold in degrees C to enable fan') parser.add_argument('--delay', type=float, default=2.0, help='Delay, in seconds, between temperature readings') parser.add_argument('--preempt', action='store_true', default=False, help='Monitor CPU frequency and activate cooling premptively') parser.add_argument('--verbose', action='store_true', default=False, help='Output temp and fan status messages') From 220a0b9cf68f1bc7281b49a1fc5da1a4bfebaf4a Mon Sep 17 00:00:00 2001 From: SofieLewis <55637872+SofieLewis@users.noreply.github.com> Date: Thu, 26 Sep 2019 00:36:38 +0100 Subject: [PATCH 2/3] Manual Mode fix removed last_change and fixed the manual mode. Before it would only turn on or off (depending if you switched while fan was on or off) for the delay time (2s default) --- examples/automatic.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/examples/automatic.py b/examples/automatic.py index 57026dd..46f98ed 100755 --- a/examples/automatic.py +++ b/examples/automatic.py @@ -71,9 +71,9 @@ def set_fan(status): def set_automatic(status): - global armed, last_change + global armed, armed = status - last_change = 0 + if args.threshold > -1 or args.hysteresis > -1: @@ -92,7 +92,6 @@ def set_automatic(status): led_busy = Lock() enable = False is_fast = False -last_change = 0 signal.signal(signal.SIGTERM, clean_exit) if args.noled: @@ -100,12 +99,6 @@ def set_automatic(status): fanshim.set_light(0, 0, 0) led_busy.release() -t = get_cpu_temp() -if t >= args.threshold: - last_change = get_cpu_temp() - set_fan(True) - - if not args.nobutton: @fanshim.on_release() def release_handler(was_held): @@ -142,12 +135,12 @@ def held_handler(): enable = True elif armed: if t >= args.on_threshold: - enable = True + set_fan(True) elif t <= args.off_threshold: - enable = False + set_fan(False) - if set_fan(enable): - last_change = t + + if not args.noled: update_led_temperature(t) From 9a8229342555cb0ce5c86a96bac842490496554e Mon Sep 17 00:00:00 2001 From: SofieLewis <55637872+SofieLewis@users.noreply.github.com> Date: Thu, 26 Sep 2019 10:47:58 +0100 Subject: [PATCH 3/3] Update automatic.py Found bug an cleaned empty lines after testing on pi --- examples/automatic.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/automatic.py b/examples/automatic.py index 46f98ed..7906980 100755 --- a/examples/automatic.py +++ b/examples/automatic.py @@ -71,7 +71,7 @@ def set_fan(status): def set_automatic(status): - global armed, + global armed armed = status @@ -139,9 +139,6 @@ def held_handler(): elif t <= args.off_threshold: set_fan(False) - - - if not args.noled: update_led_temperature(t)