widget graphic for Velocity ?

Here’s an old piece of mine

  1. create new widget

  2. set up a bunch of variables :

  • GraphPoints : array of Vector2D to store X,Y points
  • Duration : the amount of time shown on graph (eg. show velocity graph of past 5 seconds)
  • MaxFps : the maximum sampling rate (eg. 10 points per second, multiplied by 5 seconds = 50 lines to draw, keep performance in mind)
  • Width, Height : size of graph (eg. 400 x 200)
  • MaxSpeed : size of the Y axis (eg. 1500)
  • LastIndex, FVel : just some local cache variables
    image

Initialize all the points at the bottom-right-most end of graph, and start timer

On timer get current velocity and update the graph points

Then override the OnPaint function for your widget to draw lines