Strip Chart Recorder

KitCarlson

Active Member
Licensed User
Longtime User
Scrolling Chart

A strip chart is where the pen(s) are fixed in X, and move in the Y direction while the chart paper with grid moves forward. An examples are EKG, seismic recorder, and lie detector.

I have used the Chart Framework, the Oscilloscope examples, information there helps with line plots. I am considering using a Canvas and DrawBitmap with ScrRect and DestRect to move the chart 1 or 2 dip to left, and plot the new point(s) at right edge, and add to grid, and repeat.

Is there a better way? I wonder if the grid maintenance could be done in a separate circular never ending way? Or is there a better way to move the chart?

Ideas, comments, and examples are welcome and appreciated.
 
Last edited:

KitCarlson

Active Member
Licensed User
Longtime User
I experimented some with the ideas for a strip chart recorder. I started with the Oscilloscope example provided by Klaus.

Here is the code for the drawing the chart:

B4X:
Sub DrawCurves
   Dim i As Int
   Dim SrcRec, DestRec As Rect
      
   SrcRec.Initialize(GridX0 + dx*2dip, GridY0, GridX1, GridY1) ' here for visibility, move out, 
   DestRec.Initialize(GridX0, GridY0, GridX1 - dx*2dip, GridY1)' for efficiency, do once
   cvsGraph.DrawBitmap(cvsGraph.Bitmap,SrcRec,DestRec)
   For i = 0 To CurvesNb
      If Curve(i).Draw = True Then
         y2(i) = GridYm + (-Curve(i).Offset - CurveVal(i, ii)) * Curve(i).Scale
         cvsGraph.DrawLine(GridX1 - dx*2dip, y1(i),GridX1, y2(i), Curve(i).Color, 2dip)
         cvsGraph.DrawLine(GridX1 - dx*2dip, y0(i),GridX1, y1(i), Colors.Black, 2dip) ' erase old w/ black
           y0(i) = y1(i) ' save for erase later
         y1(i) = y2(i) ' save for start point next curve
      End If
   Next
   pnlGraph.Invalidate
   DoEvents
End Sub

I am having problems. I found that drawing curves at same location, and moving, copies prior draws. I tried to over write in black to erase, this overwrites the grid too. Later if things progress I will attempt at moving grid. I also found that there is a misalignment in the SrcRect, DestRec and the DrawLine based on dx. I tried to patch, but no luck yet. I m a beginner, so it is likely a problem in my methods.

I welcome all comments.
 

Attachments

  • Screenshot_2013-02-09-15-04-43.png
    Screenshot_2013-02-09-15-04-43.png
    26.3 KB · Views: 319
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
I experimented some with the ideas for a strip chart recorder. I started with the Oscilloscope example provided by Klaus.

Here is the code for the drawing the chart:

B4X:
Sub DrawCurves
   Dim i As Int
   Dim SrcRec, DestRec As Rect
      
   SrcRec.Initialize(GridX0 + dx*2dip, GridY0, GridX1, GridY1) ' here for visibility, move out, 
   DestRec.Initialize(GridX0, GridY0, GridX1 - dx*2dip, GridY1)' for efficiency, do once
   cvsGraph.DrawBitmap(cvsGraph.Bitmap,SrcRec,DestRec)
   For i = 0 To CurvesNb
      If Curve(i).Draw = True Then
         y2(i) = GridYm + (-Curve(i).Offset - CurveVal(i, ii)) * Curve(i).Scale
         cvsGraph.DrawLine(GridX1 - dx*2dip, y1(i),GridX1, y2(i), Curve(i).Color, 2dip)
         cvsGraph.DrawLine(GridX1 - dx*2dip, y0(i),GridX1, y1(i), Colors.Black, 2dip) ' erase old w/ black
           y0(i) = y1(i) ' save for erase later
         y1(i) = y2(i) ' save for start point next curve
      End If
   Next
   pnlGraph.Invalidate
   DoEvents
End Sub

I am having problems. I found that drawing curves at same location, and moving, copies prior draws. I tried to over write in black to erase, this overwrites the grid too. Later if things progress I will attempt at moving grid. I also found that there is a misalignment in the SrcRect, DestRec and the DrawLine based on dx. I tried to patch, but no luck yet. I m a beginner, so it is likely a problem in my methods.

I welcome all comments.

Hello or need an example of this chart for my project and can have the full code, I would be grateful.

Ciao o bisogno di un esempio di questo chart per un mio progetto e possibile avere il codice completo, te ne sarei grato.
 
Upvote 0

KitCarlson

Active Member
Licensed User
Longtime User
Long ago, I placed a working example with code in the, "b4a share your creations" forum section. It is several pages deep by now. The example uses a built in data generator, just replace it with your data arrays. Many thanks to Klaus, for his code that gave me the start.
 
Upvote 0
Top