Files
chromebox-fan-control-win/FanControl.ChromeboxEC/ChromeboxECControlSensor.cs
jack 111eb22824 Add FanControl.ChromeboxEC plugin, project background, ectool docs
- Add FanControl.ChromeboxEC plugin for Fan Control
- Add project background/缘由 in README (EN/zh)
- Add docs/ectool-commands-zh.md
- Update sln, appsettings, gitignore

Made-with: Cursor
2026-03-22 15:15:02 +08:00

42 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using FanControl.Plugins;
namespace FanControl.ChromeboxEC;
/// <summary>风扇控制ectool fanduty &lt;percent&gt;</summary>
public sealed class ChromeboxECControlSensor : IPluginControlSensor2
{
private readonly string _ectoolPath;
private readonly string[] _autoFanArgs;
private float? _value;
public ChromeboxECControlSensor(string ectoolPath, string[] autoFanArgs)
{
_ectoolPath = ectoolPath;
_autoFanArgs = autoFanArgs;
}
public string Id => "ChromeboxEC_Control";
public string Name => "Chromebox EC Fan";
public string Origin => "ectool fanduty";
public float? Value => _value;
public string? PairedFanSensorId => "ChromeboxEC_Fan";
/// <summary>设置风扇占空比 0100调用 ectool fanduty</summary>
public void Set(float val)
{
_value = val;
var duty = (int)Math.Clamp(Math.Round(val), 0, 100);
EctoolRunner.Run(_ectoolPath, ["fanduty", duty.ToString()]);
}
/// <summary>禁用控制时恢复 EC 自动风扇,调用 ectool autofanctrl</summary>
public void Reset()
{
_value = null;
if (_autoFanArgs is { Length: > 0 })
EctoolRunner.Run(_ectoolPath, _autoFanArgs);
}
public void Update() { }
}