From a875efd9b66f1838d79a342dabcb118d85a41965 Mon Sep 17 00:00:00 2001 From: d3dx13 Date: Wed, 2 Mar 2022 11:01:15 +0300 Subject: [PATCH 1/5] Jetson Nano A02 fix --- config.json | 3 ++- fanctl.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 88a6bcf..f8953a4 100644 --- a/config.json +++ b/config.json @@ -2,5 +2,6 @@ "FAN_OFF_TEMP":20, "FAN_MAX_TEMP":50, "UPDATE_INTERVAL":2, -"MAX_PERF":1 +"MAX_PERF":1, +"INVERSED_PIN":true } diff --git a/fanctl.py b/fanctl.py index 8a16378..4c8dd95 100644 --- a/fanctl.py +++ b/fanctl.py @@ -11,12 +11,14 @@ FAN_MAX_TEMP=config["FAN_MAX_TEMP"] UPDATE_INTERVAL=config["UPDATE_INTERVAL"] MAX_PERF=config["MAX_PERF"] + INVERSED_PIN=config["INVERSED_PIN"] except: print("error loading /etc/automagic-fan/config.json.\nPlease check your config file.\nProceeding with default settings.") FAN_OFF_TEMP=20 FAN_MAX_TEMP=50 UPDATE_INTERVAL=2 MAX_PERF=0 + INVERSED_PIN=true if MAX_PERF>0: print("Maximizing clock speeds with jetson_clocks") @@ -34,7 +36,8 @@ def read_temp(): def fan_curve(temp): spd=255*(temp-FAN_OFF_TEMP)/(FAN_MAX_TEMP-FAN_OFF_TEMP) - return int(min(max(0,spd),255)) + spd=max(min(0,spd),255) + return 255-spd if INVERSED_PIN else spd def set_speed(spd): with open("/sys/devices/pwm-fan/target_pwm","w") as file: From e7b14bb9a50c49e4594fa5193d0d582846456203 Mon Sep 17 00:00:00 2001 From: d3dx13 Date: Wed, 2 Mar 2022 11:03:48 +0300 Subject: [PATCH 2/5] save int(float) and correct bounds --- fanctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fanctl.py b/fanctl.py index 4c8dd95..d2fa1b6 100644 --- a/fanctl.py +++ b/fanctl.py @@ -36,7 +36,7 @@ def read_temp(): def fan_curve(temp): spd=255*(temp-FAN_OFF_TEMP)/(FAN_MAX_TEMP-FAN_OFF_TEMP) - spd=max(min(0,spd),255) + spd=int(min(max(0,spd),255)) return 255-spd if INVERSED_PIN else spd def set_speed(spd): From 6a9dad98443452a61bd3326f8e2cdd3850322991 Mon Sep 17 00:00:00 2001 From: d3dx13 Date: Wed, 2 Mar 2022 11:07:30 +0300 Subject: [PATCH 3/5] added some debug (disabled) --- fanctl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fanctl.py b/fanctl.py index d2fa1b6..7cb95d0 100644 --- a/fanctl.py +++ b/fanctl.py @@ -37,6 +37,8 @@ def read_temp(): def fan_curve(temp): spd=255*(temp-FAN_OFF_TEMP)/(FAN_MAX_TEMP-FAN_OFF_TEMP) spd=int(min(max(0,spd),255)) + # DEBUG + # print(255-spd if INVERSED_PIN else spd) return 255-spd if INVERSED_PIN else spd def set_speed(spd): From aab9ad2c42322f7e41d0095373042c38e7d4c26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=D0=B8=D0=B9=20=D0=96=D0=B8?= =?UTF-8?q?=D0=B4=D0=BA=D0=BE=D0=B2?= Date: Mon, 22 May 2023 16:50:05 +0300 Subject: [PATCH 4/5] Restart=always --- automagic-fan.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automagic-fan.service b/automagic-fan.service index 95c1a91..73bf1bb 100644 --- a/automagic-fan.service +++ b/automagic-fan.service @@ -3,12 +3,13 @@ Description=Automagic fan control [Service] Type=simple +Restart=always +RestartSec=5 ExecStartPre=/bin/sleep 5 ExecStart=/usr/bin/python3 -u /usr/local/bin/automagic-fan/fanctl.py ExecStopPost=/bin/sh -c '/bin/echo 0 > /sys/devices/pwm-fan/target_pwm' User=root StandardOutput=journal+console -Restart=always [Install] WantedBy=multi-user.target From ca24d2352d90998e89de5e9da1e49bb4b600907d Mon Sep 17 00:00:00 2001 From: jetson Date: Mon, 22 May 2023 15:55:57 +0200 Subject: [PATCH 5/5] config for our jetson --- automagic-fan.service | 2 -- config.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/automagic-fan.service b/automagic-fan.service index 73bf1bb..d260d74 100644 --- a/automagic-fan.service +++ b/automagic-fan.service @@ -5,9 +5,7 @@ Description=Automagic fan control Type=simple Restart=always RestartSec=5 -ExecStartPre=/bin/sleep 5 ExecStart=/usr/bin/python3 -u /usr/local/bin/automagic-fan/fanctl.py -ExecStopPost=/bin/sh -c '/bin/echo 0 > /sys/devices/pwm-fan/target_pwm' User=root StandardOutput=journal+console diff --git a/config.json b/config.json index f8953a4..a102a60 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,5 @@ "FAN_MAX_TEMP":50, "UPDATE_INTERVAL":2, "MAX_PERF":1, -"INVERSED_PIN":true +"INVERSED_PIN":false }