Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Settimi committed Jul 2, 2024
1 parent 2435424 commit a603520
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions LaserGRBL/UserControls/GrblPanel3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public GrblPanel3D()
OpCounter = 0;
FrameTime = new Base.Mathematics.MobileDAverageCalculator(10);
SleepTime = new Base.Mathematics.MobileDAverageCalculator(10);
RefreshRate = new Base.Mathematics.MobileDAverageCalculator(10);
RefreshRate = new Base.Mathematics.MobileDAverageCalculator(3);
mLastWPos = GPoint.Zero;
mLastMPos = GPoint.Zero;
forcez = Settings.GetObject("Enale Z Jog Control", false);
Expand Down Expand Up @@ -777,7 +777,7 @@ private void DoGDIDraw(PaintEventArgs e)
else
VertexString = string.Format("{0,6:###0.0} B", VertexCounter / 1000000000.0);

text = $"VER {VertexString}\nAFT {string.Format("{0,6:##0} ms", FrameTime.Avg)}\nAST {string.Format("{0,6:##0} ms", SleepTime.Avg)}\nRPS {string.Format("{0,6:##0}", 1000.0 / RefreshRate.Avg)}";
text = $"VER {VertexString}\nAFT {string.Format("{0,6:##0} ms", FrameTime.Avg)}\nAST {string.Format("{0,6:##0} ms", SleepTime.Avg)}\nRPS {string.Format("{0,6:##0}", Math.Max(0, Math.Floor(1000.0 / RefreshRate.Avg - 1)))}";
size = MeasureText(text, font);
point = new Point(Width - size.Width - mPadding.Right, pos);
DrawOverlay(e, point, size, ColorScheme.PreviewRuler, 100);
Expand Down Expand Up @@ -1102,6 +1102,7 @@ public void AutoSizeDrawing()
);
}

PeriodicEventTimer InvalidateTimer = new Tools.PeriodicEventTimer(TimeSpan.FromSeconds(1), true);
public void TimerUpdate()
{
if (Core != null && (mLastWPos != Core.WorkPosition || mLastMPos != Core.MachinePosition || mCurF != Core.CurrentF || mCurS != Core.CurrentS))
Expand All @@ -1112,7 +1113,9 @@ public void TimerUpdate()
mCurS = Core.CurrentS;
RR.Set();
}
Invalidate();

if (InvalidateTimer.Expired)
Invalidate();
}

public void OnColorChange()
Expand Down

0 comments on commit a603520

Please sign in to comment.