Skip to content

Commit

Permalink
fix lenovo limits
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Apr 4, 2024
1 parent 772f824 commit ca3a438
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "adjustor"
version = "2.1.2"
version = "2.1.3"
authors = [
{ name="Kapenekakis Antheas", email="[email protected]" },
]
Expand Down
24 changes: 17 additions & 7 deletions src/adjustor/drivers/lenovo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
from adjustor.core.lenovo import (
MIN_CURVE,
TdpMode,
get_fan_curve,
get_fast_tdp,
get_full_fan_speed,
get_power_light,
get_steady_tdp,
get_tdp_mode,
set_fan_curve,
set_fast_tdp,
Expand Down Expand Up @@ -141,6 +138,14 @@ def update(self, conf: Config):
# Check user changed values
steady = conf["tdp.lenovo.tdp.custom.tdp"].to(int)

old_steady = steady
if self.enforce_limits:
steady = min(max(steady, 4), 30)
else:
steady = min(max(steady, 0), 50)
if old_steady != steady:
conf["tdp.lenovo.tdp.custom.tdp"] = steady

steady_updated = steady and steady != self.old_conf["tdp.custom.tdp"].to(
int
)
Expand Down Expand Up @@ -189,10 +194,15 @@ def update(self, conf: Config):
conf[f"tdp.lenovo.fan.manual.st{(i + 1)*10}"] = v

# Handle fan curve limits
if conf["tdp.lenovo.fan.manual.enforce_limits"].to(bool):
for i, v in enumerate(MIN_CURVE):
if conf[f"tdp.lenovo.fan.manual.st{(i + 1)*10}"].to(int) < v:
conf[f"tdp.lenovo.fan.manual.st{(i + 1)*10}"] = v
for i, v in enumerate(MIN_CURVE):
val = conf[f"tdp.lenovo.fan.manual.st{(i + 1)*10}"].to(int)
old_val = val
if conf["tdp.lenovo.fan.manual.enforce_limits"].to(bool) and val < v:
val = v

val = max(min(val, 115), 0)
if old_val != val:
conf[f"tdp.lenovo.fan.manual.st{(i + 1)*10}"] = val

# Check if fan curve has changed
# Use debounce logic on these changes
Expand Down

0 comments on commit ca3a438

Please sign in to comment.