The Kurgan 1.0.0: one process for the LCD, fans, lighting, local LLM servers and the web UI
This commit is contained in:
commit
f631386618
71 files changed
+14616
No files matched your search
@@ -0,0 +1,90 @@
|
||||
"""Selectable fan profiles: one set of temperature -> PWM duty curves for each fan group.
|
||||
|
||||
Every profile keeps the fail-safes in control.py (100% when a temperature is missing, a fan
|
||||
stalls or the controller fails), the slow ramp-down, and the top-fan boost while either
|
||||
case-fan group runs at 85% or more. Only the curves and the top fans' start/stop
|
||||
temperatures differ.
|
||||
|
||||
Curves are (temperature C, duty %) points: below the first point the duty is the first
|
||||
point's, between points it is interpolated, and at or above the last point it is 100%.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
Curve = tuple[tuple[int, int], ...]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FanProfile:
|
||||
key: str
|
||||
name: str
|
||||
description: str
|
||||
gpu_curve: Curve # GPU-side Commander PRO fans, from GPU temperature
|
||||
cpu_curve: Curve # CPU-side Commander PRO fans, from 5-second-averaged CPU package temperature
|
||||
top_curve: Curve # motherboard top fans while running, from the hotter of CPU/GPU
|
||||
top_start: int # top fans start at this temperature ...
|
||||
top_stop: int # ... and stop after 30 s below this one
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
return {"key": self.key, "name": self.name, "description": self.description,
|
||||
"gpu_curve": self.gpu_curve, "cpu_curve": self.cpu_curve, "top_curve": self.top_curve,
|
||||
"top_start": self.top_start, "top_stop": self.top_stop}
|
||||
|
||||
|
||||
def validate_curve(curve: Curve) -> None:
|
||||
if len(curve) < 2:
|
||||
raise ValueError("a curve needs at least two points")
|
||||
temps = [t for t, _ in curve]
|
||||
duties = [d for _, d in curve]
|
||||
if any(b <= a for a, b in zip(temps, temps[1:])):
|
||||
raise ValueError("curve temperatures must rise")
|
||||
if any(b < a for a, b in zip(duties, duties[1:])):
|
||||
raise ValueError("curve duties must not fall as temperature rises")
|
||||
if not all(0 <= t <= 110 for t in temps) or not all(0 <= d <= 100 for d in duties):
|
||||
raise ValueError("curve points must be 0-110 C and 0-100%")
|
||||
if duties[-1] != 100:
|
||||
raise ValueError("every curve must reach 100%")
|
||||
|
||||
|
||||
QUIET = FanProfile(
|
||||
"quiet", "Quiet",
|
||||
"Lower fan speeds; each group reaches 100% about 5 C later than Balanced.",
|
||||
gpu_curve=((45, 35), (55, 45), (65, 65), (75, 100)),
|
||||
cpu_curve=((55, 35), (65, 45), (75, 65), (85, 100)),
|
||||
top_curve=((55, 30), (65, 60), (75, 100)),
|
||||
top_start=55, top_stop=50,
|
||||
)
|
||||
BALANCED = FanProfile(
|
||||
"balanced", "Balanced",
|
||||
"The original curves: GPU-side fans reach 100% at 70 C, CPU-side fans at 80 C.",
|
||||
gpu_curve=((40, 40), (50, 50), (60, 65), (70, 100)),
|
||||
cpu_curve=((50, 40), (60, 50), (70, 65), (80, 100)),
|
||||
top_curve=((50, 30), (60, 60), (70, 100)),
|
||||
top_start=50, top_stop=45,
|
||||
)
|
||||
PERFORMANCE = FanProfile(
|
||||
"performance", "Performance",
|
||||
"Higher speeds for long AI or gaming loads; each group reaches 100% 5 C earlier than Balanced.",
|
||||
gpu_curve=((35, 50), (45, 60), (55, 80), (65, 100)),
|
||||
cpu_curve=((45, 50), (55, 60), (65, 80), (75, 100)),
|
||||
top_curve=((45, 40), (55, 70), (65, 100)),
|
||||
top_start=45, top_stop=40,
|
||||
)
|
||||
FULL = FanProfile(
|
||||
"full", "Full speed",
|
||||
"Every controlled fan at 100%, including the top fans.",
|
||||
gpu_curve=((0, 100), (110, 100)),
|
||||
cpu_curve=((0, 100), (110, 100)),
|
||||
top_curve=((0, 100), (110, 100)),
|
||||
top_start=0, top_stop=0,
|
||||
)
|
||||
|
||||
PROFILES: dict[str, FanProfile] = {p.key: p for p in (QUIET, BALANCED, PERFORMANCE, FULL)}
|
||||
DEFAULT_PROFILE = BALANCED.key
|
||||
|
||||
for _profile in PROFILES.values():
|
||||
for _curve in (_profile.gpu_curve, _profile.cpu_curve, _profile.top_curve):
|
||||
validate_curve(_curve)
|
||||
assert _profile.top_stop <= _profile.top_start
|
||||
Reference in new issue
Block a user