feat: ramp-up/down delay fan control

- Add RampUpSteps and RampUpMinDeltaPercent config
- Gradual ramp in both directions (up and down) to reduce fan oscillation
- Fix Advanced tab layout with RowStyles and label alignment

Made-with: Cursor
This commit is contained in:
2026-03-22 12:53:15 +08:00
parent 1de688b792
commit e8c8a759e0
7 changed files with 91 additions and 7 deletions

View File

@@ -25,6 +25,8 @@ public sealed class MainForm : Form
private readonly CheckBox _chkFailAuto = new();
private readonly NumericUpDown _nudChartMin = new();
private readonly NumericUpDown _nudChartPoints = new();
private readonly NumericUpDown _nudRampUpSteps = new();
private readonly NumericUpDown _nudRampUpMinDelta = new();
private readonly NotifyIcon _tray = new();
private readonly ContextMenuStrip _trayMenu = new();
private readonly ToolStripMenuItem _miPause;
@@ -141,11 +143,13 @@ public sealed class MainForm : Form
{
Dock = DockStyle.Fill,
ColumnCount = 2,
RowCount = 13,
RowCount = 15,
Padding = new Padding(12)
};
flp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 35));
flp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 65));
for (var i = 0; i < 15; i++)
flp.RowStyles.Add(new RowStyle(SizeType.AutoSize));
var row = 0;
AddRow(flp, row++, Resources.LblLanguage, _cmbLanguage);
@@ -201,6 +205,14 @@ public sealed class MainForm : Form
_nudChartPoints.Maximum = 10_000;
_nudChartPoints.Increment = 100;
AddRow(flp, row++, Resources.LblRampUpSteps, _nudRampUpSteps);
_nudRampUpSteps.Minimum = 1;
_nudRampUpSteps.Maximum = 10;
AddRow(flp, row++, Resources.LblRampUpMinDeltaPercent, _nudRampUpMinDelta);
_nudRampUpMinDelta.Minimum = 0;
_nudRampUpMinDelta.Maximum = 50;
var btnSaveAdv = new Button { Text = Resources.BtnSaveAdvanced, AutoSize = true, Dock = DockStyle.Bottom };
btnSaveAdv.Click += (_, _) => SaveFromUi();
tabAdv.Controls.Add(btnSaveAdv);
@@ -211,7 +223,7 @@ public sealed class MainForm : Form
private static void AddRow(TableLayoutPanel t, int row, string label, Control editor)
{
t.Controls.Add(new System.Windows.Forms.Label { Text = label, AutoSize = true, Anchor = AnchorStyles.Left }, 0, row);
t.Controls.Add(new System.Windows.Forms.Label { Text = label, AutoSize = true, Anchor = AnchorStyles.Left | AnchorStyles.Top }, 0, row);
editor.Dock = DockStyle.Fill;
t.Controls.Add(editor, 1, row);
}
@@ -271,6 +283,8 @@ public sealed class MainForm : Form
_chkFailAuto.Checked = _config.FailSafeRestoreAutoFan;
_nudChartMin.Value = _config.ChartHistoryMinutes;
_nudChartPoints.Value = _config.ChartMaxPoints;
_nudRampUpSteps.Value = _config.RampUpSteps;
_nudRampUpMinDelta.Value = _config.RampUpMinDeltaPercent;
for (var i = 0; i < 14; i++)
_gridCurve.Rows[i].Cells[1].Value = _config.CurvePoints[i].ToString();
RebuildCurveChart();
@@ -296,6 +310,8 @@ public sealed class MainForm : Form
FailSafeRestoreAutoFan = _chkFailAuto.Checked,
ChartHistoryMinutes = (int)_nudChartMin.Value,
ChartMaxPoints = (int)_nudChartPoints.Value,
RampUpSteps = (int)_nudRampUpSteps.Value,
RampUpMinDeltaPercent = (int)_nudRampUpMinDelta.Value,
CurvePoints = ReadCurveFromGrid()
};
return c;