From 325022d27c6b7e4efeba651b9c3333d019d8d146 Mon Sep 17 00:00:00 2001 From: Mute Date: Sat, 8 Aug 2026 11:18:01 +0000 Subject: [PATCH] Fix Send gauges showing intensity, zero when idle - Send gauges now show waveform intensity (0-100) not strength ceiling - State.LastIntensityA/B tracks average intensity per tick - Zero when no pattern/stream active (was 25 due to IntensityOff 101 sentinel) - Recv gauges unchanged (device-reported strength 0-200) --- MainForm.cs | 8 ++++---- State.cs | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 02cf7eb..91eb13d 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -142,7 +142,7 @@ public class MainForm : Form Location = new Point(72, 160), Size = new Size(332, 20), Minimum = 0, - Maximum = 200, + Maximum = 100, Style = ProgressBarStyle.Continuous }; _lblSendB = new Label @@ -157,7 +157,7 @@ public class MainForm : Form Location = new Point(72, 184), Size = new Size(332, 20), Minimum = 0, - Maximum = 200, + Maximum = 100, Style = ProgressBarStyle.Continuous }; _lblRecvA = new Label @@ -357,8 +357,8 @@ public class MainForm : Form _lblBle.Text = _device.IsConnected ? $"BLE: connected ({_device.DeviceName})" : "BLE: disconnected"; - _gaugeSendA.Value = Math.Clamp(_state.LastSentA, 0, 200); - _gaugeSendB.Value = Math.Clamp(_state.LastSentB, 0, 200); + _gaugeSendA.Value = Math.Clamp(_state.LastIntensityA, 0, 100); + _gaugeSendB.Value = Math.Clamp(_state.LastIntensityB, 0, 100); _gaugeRecvA.Value = Math.Clamp(_device.StrengthA, 0, 200); _gaugeRecvB.Value = Math.Clamp(_device.StrengthB, 0, 200); _btnTest.Enabled = !_server.HasClient && !IsTestRunning; diff --git a/State.cs b/State.cs index 3486b61..511a799 100644 --- a/State.cs +++ b/State.cs @@ -17,6 +17,7 @@ public class State public int ActualA, ActualB; public int LastSentA, LastSentB; + public int LastIntensityA, LastIntensityB; public int MaxStrength = 200; public LimitMode LimitMode = LimitMode.Clamp; @@ -105,9 +106,14 @@ public class State DirtyA = false; DirtyB = false; + bool hasA = !StreamA.IsEmpty || (LoopFreqA != null && LoopIntA != null); + bool hasB = !StreamB.IsEmpty || (LoopFreqB != null && LoopIntB != null); var (freqA, intA) = PopWave(StreamA, LoopFreqA, LoopIntA); var (freqB, intB) = PopWave(StreamB, LoopFreqB, LoopIntB); + LastIntensityA = hasA ? (intA[0] + intA[1] + intA[2] + intA[3]) / 4 : 0; + LastIntensityB = hasB ? (intB[0] + intB[1] + intB[2] + intB[3]) / 4 : 0; + return (modeA, valA, modeB, valB, freqA, intA, freqB, intB); } }