Remove Test button, move Stop All to right edge
- Removed Test button, OnTest, RunTestAsync, IsTestRunning - Remaining buttons (Live, Pattern, Random, Stop All) at 80px each - Stop All moved to right edge (x=324)
This commit is contained in:
+10
-78
@@ -16,7 +16,6 @@ public class MainForm : Form
|
|||||||
readonly Label _lblDeviceName;
|
readonly Label _lblDeviceName;
|
||||||
readonly TextBox _txtDeviceName;
|
readonly TextBox _txtDeviceName;
|
||||||
readonly Button _btnConnect;
|
readonly Button _btnConnect;
|
||||||
readonly Button _btnTest;
|
|
||||||
readonly Button _btnStop;
|
readonly Button _btnStop;
|
||||||
readonly System.Windows.Forms.Timer _statusTimer;
|
readonly System.Windows.Forms.Timer _statusTimer;
|
||||||
readonly CancellationTokenSource _loopCts;
|
readonly CancellationTokenSource _loopCts;
|
||||||
@@ -121,43 +120,35 @@ public class MainForm : Form
|
|||||||
};
|
};
|
||||||
_chkSwap.CheckedChanged += OnSwapChanged;
|
_chkSwap.CheckedChanged += OnSwapChanged;
|
||||||
|
|
||||||
_btnTest = new Button
|
|
||||||
{
|
|
||||||
Text = "Test",
|
|
||||||
Location = new Point(16, 96),
|
|
||||||
Size = new Size(68, 32)
|
|
||||||
};
|
|
||||||
_btnTest.Click += OnTest;
|
|
||||||
|
|
||||||
_btnLive = new Button
|
_btnLive = new Button
|
||||||
{
|
{
|
||||||
Text = "Live",
|
Text = "Live",
|
||||||
Location = new Point(92, 96),
|
Location = new Point(16, 96),
|
||||||
Size = new Size(68, 32)
|
Size = new Size(80, 32)
|
||||||
};
|
};
|
||||||
_btnLive.Click += OnLive;
|
_btnLive.Click += OnLive;
|
||||||
|
|
||||||
_btnPattern = new Button
|
_btnPattern = new Button
|
||||||
{
|
{
|
||||||
Text = "Pattern",
|
Text = "Pattern",
|
||||||
Location = new Point(168, 96),
|
Location = new Point(104, 96),
|
||||||
Size = new Size(68, 32)
|
Size = new Size(80, 32)
|
||||||
};
|
};
|
||||||
_btnPattern.Click += OnPattern;
|
_btnPattern.Click += OnPattern;
|
||||||
|
|
||||||
_btnRandom = new Button
|
_btnRandom = new Button
|
||||||
{
|
{
|
||||||
Text = "Random",
|
Text = "Random",
|
||||||
Location = new Point(244, 96),
|
Location = new Point(192, 96),
|
||||||
Size = new Size(68, 32)
|
Size = new Size(80, 32)
|
||||||
};
|
};
|
||||||
_btnRandom.Click += OnRandom;
|
_btnRandom.Click += OnRandom;
|
||||||
|
|
||||||
_btnStop = new Button
|
_btnStop = new Button
|
||||||
{
|
{
|
||||||
Text = "Stop All",
|
Text = "Stop All",
|
||||||
Location = new Point(320, 96),
|
Location = new Point(324, 96),
|
||||||
Size = new Size(76, 32)
|
Size = new Size(80, 32)
|
||||||
};
|
};
|
||||||
_btnStop.Click += OnStop;
|
_btnStop.Click += OnStop;
|
||||||
|
|
||||||
@@ -360,7 +351,7 @@ public class MainForm : Form
|
|||||||
};
|
};
|
||||||
OnAmpChanged(null, EventArgs.Empty);
|
OnAmpChanged(null, EventArgs.Empty);
|
||||||
|
|
||||||
Controls.AddRange(new Control[] { _lblBle, _lblWs, _lblDeviceName, _txtDeviceName, _btnConnect, _chkSwap, _btnTest, _btnLive, _btnPattern, _btnRandom, _btnStop, _lblAudioDev, _cboAudioDev, _lblTrack, _lblSendA, _heatA, _lblSendB, _heatB, _lblRecvA, _gaugeRecvA, _lblRecvB, _gaugeRecvB, _lblLimitA, _limitBarA, _lblLimitValA, _chkScaleA, _lblLimitB, _limitBarB, _lblLimitValB, _chkScaleB, _lblAmpA, _ampBarA, _lblAmpValA, _lblAmpB, _ampBarB, _lblAmpValB });
|
Controls.AddRange(new Control[] { _lblBle, _lblWs, _lblDeviceName, _txtDeviceName, _btnConnect, _chkSwap, _btnLive, _btnPattern, _btnRandom, _btnStop, _lblAudioDev, _cboAudioDev, _lblTrack, _lblSendA, _heatA, _lblSendB, _heatB, _lblRecvA, _gaugeRecvA, _lblRecvB, _gaugeRecvB, _lblLimitA, _limitBarA, _lblLimitValA, _chkScaleA, _lblLimitB, _limitBarB, _lblLimitValB, _chkScaleB, _lblAmpA, _ampBarA, _lblAmpValA, _lblAmpB, _ampBarB, _lblAmpValB });
|
||||||
|
|
||||||
// Tray icon — three cached variants: neutral=gray, active=gold, hot=red-orange
|
// Tray icon — three cached variants: neutral=gray, active=gold, hot=red-orange
|
||||||
_iconNeutral = CreateVoltageIcon(Color.Gray);
|
_iconNeutral = CreateVoltageIcon(Color.Gray);
|
||||||
@@ -530,8 +521,7 @@ public class MainForm : Form
|
|||||||
|
|
||||||
void RefreshButtonStates()
|
void RefreshButtonStates()
|
||||||
{
|
{
|
||||||
bool busy = IsTestRunning || _isLiveRunning || _isPatternRunning || _isRandomRunning;
|
bool busy = _isLiveRunning || _isPatternRunning || _isRandomRunning;
|
||||||
_btnTest.Enabled = !_server.HasClient && !busy;
|
|
||||||
_btnLive.Enabled = !_server.HasClient && !busy;
|
_btnLive.Enabled = !_server.HasClient && !busy;
|
||||||
_btnPattern.Enabled = !_server.HasClient && !busy;
|
_btnPattern.Enabled = !_server.HasClient && !busy;
|
||||||
_btnRandom.Enabled = !_server.HasClient && !busy;
|
_btnRandom.Enabled = !_server.HasClient && !busy;
|
||||||
@@ -558,64 +548,6 @@ public class MainForm : Form
|
|||||||
UpdateTrayIcon();
|
UpdateTrayIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsTestRunning;
|
|
||||||
|
|
||||||
void OnTest(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (IsTestRunning || _server.HasClient) return;
|
|
||||||
IsTestRunning = true;
|
|
||||||
_btnTest.Enabled = false;
|
|
||||||
|
|
||||||
Task.Run(() => RunTestAsync());
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task RunTestAsync()
|
|
||||||
{
|
|
||||||
// Short feel-good pattern over both channels (~3s), gentle swell, A leads B.
|
|
||||||
const int testStrength = 25;
|
|
||||||
|
|
||||||
_state.SetStrength('A', testStrength);
|
|
||||||
_state.SetStrength('B', testStrength);
|
|
||||||
|
|
||||||
// 30 frames x 100ms = 3 seconds. Deep-ish 7Hz pulse with breathing envelope.
|
|
||||||
var framesA = new List<WaveFrame>();
|
|
||||||
var framesB = new List<WaveFrame>();
|
|
||||||
for (int i = 0; i < 30; i++)
|
|
||||||
{
|
|
||||||
double t = (double)i / 30;
|
|
||||||
// Swell 0 -> 70 -> 0 over the run
|
|
||||||
double env = Math.Sin(Math.PI * t) * 70;
|
|
||||||
int intA = (int)Math.Round(env);
|
|
||||||
int intB = (int)Math.Round(env * 0.7); // B slightly softer
|
|
||||||
|
|
||||||
int freqMs = 150; // ~7Hz deep
|
|
||||||
framesA.Add(new WaveFrame(
|
|
||||||
Freq.Compress4(new[] { freqMs, freqMs, freqMs, freqMs }),
|
|
||||||
Intensity.Clamp4(new[] { intA, intA, intA, intA })));
|
|
||||||
framesB.Add(new WaveFrame(
|
|
||||||
Freq.Compress4(new[] { freqMs, freqMs, freqMs, freqMs }),
|
|
||||||
Intensity.Clamp4(new[] { intB, intB, intB, intB })));
|
|
||||||
}
|
|
||||||
|
|
||||||
_state.Stop('A'); _state.Stop('B');
|
|
||||||
_state.EnqueueStream('A', framesA);
|
|
||||||
_state.EnqueueStream('B', framesB);
|
|
||||||
|
|
||||||
// Wait for the stream to be consumed (~3s) plus margin, then silence.
|
|
||||||
await Task.Delay(3300);
|
|
||||||
|
|
||||||
_state.SetStrength('A', 0);
|
|
||||||
_state.SetStrength('B', 0);
|
|
||||||
_state.Stop('A');
|
|
||||||
_state.Stop('B');
|
|
||||||
|
|
||||||
BeginInvoke(() =>
|
|
||||||
{
|
|
||||||
IsTestRunning = false;
|
|
||||||
RefreshButtonStates();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnStop(object? sender, EventArgs e)
|
void OnStop(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
StopLive();
|
StopLive();
|
||||||
|
|||||||
Reference in New Issue
Block a user