mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-30 20:24:22 +01:00
Restore fan mode on resume
This commit is contained in:
parent
75f40c4167
commit
def9012056
|
|
@ -50,6 +50,23 @@ namespace FanControl
|
|||
}
|
||||
|
||||
notifyIcon.ShowBalloonTip(3000, Text, "Fan Control Started", ToolTipIcon.Info);
|
||||
|
||||
Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
}
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
||||
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||
}
|
||||
|
||||
private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
|
||||
{
|
||||
// Restore fan mode on resume
|
||||
if (e.Mode == Microsoft.Win32.PowerModes.Resume)
|
||||
{
|
||||
fanControl.SetMode(fanControl.Mode);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFanMode(FanController.FanMode mode)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace FanControl
|
|||
SensorType = SensorType.Power,
|
||||
ValueDeadZone = 0.1f,
|
||||
AvgSamples = 20,
|
||||
MaxValue = 25, // TODO: On resume a bogus value is returned
|
||||
Profiles = new Dictionary<FanMode, FanSensor.Profile>()
|
||||
{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace FanControl
|
|||
|
||||
public float ValueDeadZone { get; set; }
|
||||
public int AvgSamples { get; set; } = 5;
|
||||
public float? MaxValue { get; set; }
|
||||
|
||||
internal string HardwareName { get; set; } = "";
|
||||
internal HardwareType HardwareType { get; set; }
|
||||
|
|
@ -153,6 +154,9 @@ namespace FanControl
|
|||
if (!newValue.HasValue || newValue <= 0.0)
|
||||
return false;
|
||||
|
||||
if (MaxValue.HasValue)
|
||||
newValue = Math.Min(newValue.Value, MaxValue.Value);
|
||||
|
||||
if (AllSamples.Count == 0 || Math.Abs(AllSamples.Last() - newValue.Value) >= ValueDeadZone)
|
||||
{
|
||||
AllSamples.Add(newValue.Value);
|
||||
|
|
|
|||
Loading…
Reference in a new issue