팬 판단 온도 계산 보강
This commit is contained in:
+35
-6
@@ -398,6 +398,22 @@ function cpu_temp(): float
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
function fan_control_temp(float $cpuTemp, ?float $rp1Temp): float
|
||||
{
|
||||
if ($cpuTemp <= 0) {
|
||||
return $rp1Temp !== null ? round($rp1Temp, 2) : 0.0;
|
||||
}
|
||||
if ($rp1Temp === null || $rp1Temp <= 0) {
|
||||
return round($cpuTemp, 2);
|
||||
}
|
||||
|
||||
$rp1Weight = clamp_float((float)setting_value('fan.rp1_temp_weight'), 0.0, 1.0);
|
||||
$mixed = ($cpuTemp * (1.0 - $rp1Weight)) + ($rp1Temp * $rp1Weight);
|
||||
$headroom = (float)setting_value('fan.control_temp_headroom');
|
||||
|
||||
return round(max($cpuTemp, $mixed + $headroom), 2);
|
||||
}
|
||||
|
||||
function fan_target_pwm(float $temp): int
|
||||
{
|
||||
$minTemp = (float)setting_value('fan.auto_min_temp');
|
||||
@@ -455,7 +471,9 @@ function apply_fan_policy(): array
|
||||
$state = get_control_state();
|
||||
$paths = fan_paths();
|
||||
|
||||
$temp = cpu_temp();
|
||||
$cpuTemp = cpu_temp();
|
||||
$rp1Temp = rp1_temp_c();
|
||||
$controlTemp = fan_control_temp($cpuTemp, $rp1Temp);
|
||||
|
||||
$mode = (string)($state['mode'] ?? 'auto');
|
||||
if (!in_array($mode, ['auto', 'manual', 'off'], true)) {
|
||||
@@ -468,10 +486,10 @@ function apply_fan_policy(): array
|
||||
$desired = match ($mode) {
|
||||
'manual' => $manualPwm,
|
||||
'off' => 0,
|
||||
default => fan_target_pwm($temp),
|
||||
default => fan_target_pwm($controlTemp),
|
||||
};
|
||||
$target = $mode === 'auto'
|
||||
? fan_ramped_pwm($currentPwm, $desired, $temp)
|
||||
? fan_ramped_pwm($currentPwm, $desired, $controlTemp)
|
||||
: $desired;
|
||||
|
||||
$enableOk = write_sys_value($paths['enable'], $mode === 'off' ? 0 : 1);
|
||||
@@ -487,7 +505,9 @@ function apply_fan_policy(): array
|
||||
'mode' => $mode,
|
||||
'target_pwm' => $target,
|
||||
'actual_pwm' => $actualPwm,
|
||||
'temp_c' => $temp,
|
||||
'temp_c' => $cpuTemp,
|
||||
'rp1_temp_c' => $rp1Temp,
|
||||
'control_temp_c' => $controlTemp,
|
||||
'rpm' => $rpm,
|
||||
'ok' => $enableOk && $pwmOk,
|
||||
'paths' => $paths,
|
||||
@@ -3182,6 +3202,12 @@ function collect_snapshot(bool $applyFan = true): array
|
||||
if ($temp <= 0) {
|
||||
$temp = (float)$policy['temp_c'];
|
||||
}
|
||||
$rp1Temp = isset($policy['rp1_temp_c']) && is_numeric($policy['rp1_temp_c'])
|
||||
? (float)$policy['rp1_temp_c']
|
||||
: rp1_temp_c();
|
||||
$controlTemp = isset($policy['control_temp_c']) && is_numeric($policy['control_temp_c'])
|
||||
? (float)$policy['control_temp_c']
|
||||
: fan_control_temp($temp, $rp1Temp);
|
||||
|
||||
$load = sys_getloadavg() ?: [0, 0, 0];
|
||||
$mem = mem_info();
|
||||
@@ -3202,7 +3228,7 @@ function collect_snapshot(bool $applyFan = true): array
|
||||
'cpu_temp_c' => $temp,
|
||||
'fan_rpm' => $rpm,
|
||||
'fan_efficiency' => fan_efficiency($rpm, $temp, $cpuPower['watts'] ?? null),
|
||||
'rp1_temp_c' => rp1_temp_c(),
|
||||
'rp1_temp_c' => $rp1Temp,
|
||||
'cpu_voltage' => $cpuPower['voltage'],
|
||||
'cpu_watts' => $cpuPower['watts'],
|
||||
'battery_voltage' => $battery['voltage'],
|
||||
@@ -3231,12 +3257,15 @@ function collect_snapshot(bool $applyFan = true): array
|
||||
'rpm' => $rpm,
|
||||
'enable' => $policy['enable_value'],
|
||||
'target_pwm' => $policy['target_pwm'],
|
||||
'control_temp_c' => $controlTemp,
|
||||
'policy_ok' => $policy['ok'],
|
||||
'paths' => $policy['paths'],
|
||||
];
|
||||
|
||||
$system = array_merge($os, [
|
||||
'temp_c' => $temp,
|
||||
'rp1_temp_c' => $rp1Temp,
|
||||
'fan_control_temp_c' => $controlTemp,
|
||||
'load' => [
|
||||
round((float)$load[0], 2),
|
||||
round((float)$load[1], 2),
|
||||
@@ -3258,7 +3287,7 @@ function collect_snapshot(bool $applyFan = true): array
|
||||
'temp_c' => $temp,
|
||||
'fan_rpm' => $rpm,
|
||||
'fan_efficiency' => fan_efficiency($rpm, $temp, $cpuPower['watts'] ?? null),
|
||||
'rp1_temp_c' => rp1_temp_c(),
|
||||
'rp1_temp_c' => $rp1Temp,
|
||||
'cpu_voltage' => $cpuPower['voltage'],
|
||||
'cpu_watts' => $cpuPower['watts'],
|
||||
'battery_voltage' => $battery['voltage'],
|
||||
|
||||
Reference in New Issue
Block a user