GraphicsWindow.Title = "ECG display" GraphicsWindow.top=0 GraphicsWindow.Left=0 windowheight=desktop.Height windowWidth=desktop.width GraphicsWindow.Height = windowheight GraphicsWindow.Width = windowWidth GraphicsWindow.MouseDown = MyEventHandler CalcOneSecond=0 CalcOffset=0 CalcLoops=0 wait=1 loop=0 Oldrow=2 oldZeroRow=0 z=0 ' just used when putting the seconds number 'read the file, until the date/time string is found (usually the second line) row=0 y=File.ReadLine("DataToPlot.csv",row) row=row+1 While text.GetLength(y)<3 y=File.ReadLine("DataToPlot.csv",row) row=row+1 Endwhile filetext=y 'date/time string is found and is now held in 'filetext' Oldrow=row While 1=1 GraphicsWindow.Clear() Drawgrid() GraphicsWindow.PenColor = "Black" GraphicsWindow.PenWidth = 1 For vertpos=100 To 700 Step 5*38.6 x=0 ' left hand side of the screen y=vertpos ' middle of the screen vertically For row=Oldrow To Oldrow+1700 oldx=x oldy=y x=x+1 y=File.ReadLine("DataToPlot.csv",row) y=y/4 'scale trace height to look better 'Handle what happens when a zero (second marker) is loaded if y>0 then y=y+vertpos 'move to middle of screen vertically GraphicsWindow.DrawLine(oldx,oldy, x,y) Else ' we are now on a Zero row - one second tick mark 'work out the number of pixels for one second If CalcLoops<3 then ' ignore the first few zeros CalcOffset=row CalcLoops=CalcLoops+1 else CalcOneSecond=row-oldZeroRow GraphicsWindow.Title="Row ="+row+" CalcOneSecond =" + CalcOneSecond oldZeroRow=row CalcLoops=CalcLoops+1 'now put in a tick mark to show the one second ticks GraphicsWindow.DrawLine(oldx,1000, oldx,980) While wait=1 'do nothing endwhile wait=1 endif 'and correct the next line segment origin y=oldy endif endfor oldrow=row EndFor oldrow=row loop=loop+1 endwhile Program.End() '================================ Sub Drawgrid 'Draw a grid GraphicsWindow.PenColor = "red" GraphicsWindow.PenWidth = 0.1 oldx=0 oldy=0 'horizontal lines For y=0 To 1000 Step 38.6 For x=0 To 1800 Step 193 '193 pixels across = 1 second GraphicsWindow.drawline(oldx,y, x,y) oldx=x oldy=y EndFor EndFor 'vertical lines - major lines every 0.2 seconds For x=0 To 1800 Step 38.6 For y=0 To 1000 Step 100 GraphicsWindow.drawline(x,oldy, x,y) oldx=x oldy=y EndFor EndFor 'vertical lines GraphicsWindow.PenColor = "orange" For x=0 To 1800 Step 7.72 For y=0 To 1000 Step 100 GraphicsWindow.drawline(x,oldy, x,y) oldx=x oldy=y EndFor EndFor ' put a one-second marker GraphicsWindow.PenColor = "Black" GraphicsWindow.PenWidth = 1 leftX=193 rightX=386 Yposition=38.6*25 endHeight=20 GraphicsWindow.DrawLine(leftX,Yposition,rightX,Yposition) 'then the two end marks GraphicsWindow.DrawLine(leftX,Yposition+endHeight/2,leftX,Yposition-endHeight/2) GraphicsWindow.DrawLine(rightX,Yposition+endHeight/2,rightX,Yposition-endHeight/2) GraphicsWindow.DrawText((leftX+rightX)/2,Yposition,"1 second") GraphicsWindow.DrawText(20,20,"Q R Thurtle "+filetext) 'put seconds on the four axes For y = 230 To 830 Step 5*38.6 For x = 0 To 1800 Step 193 GraphicsWindow.DrawText(x,y,z) z=z+1 EndFor EndFor EndSub '============================ Sub MyEventHandler If wait=0 Then wait=1 Else wait=0 EndIf EndSub