! XY plotter program by Alberto !--------------------------------------------------- Dim Pixels[2] Dim New_X[4] Dim Old_X[4] Dim New_Y[4] Dim Old_Y[4] Dim Amp[4] Dim Off_Y[4] Dim KL[4,4] Goto Skip_Sub !---------------------------------------------------- ! Ini Sub-Routines !---------------------------------------------------- Graph: gr.color KL[Index,1], KL[Index,2], KL[Index,3], KL[Index,4],0 if abs(Old_Y[Index] - New_Y[Index]) > 3 then gr.line ggg, Old_X[Index] + Off_X,600-((Old_Y[Index] * Amp[Index]) + Off_Y[Index]),New_X[Index] + Off_X,600-((New_Y[Index] * Amp[Index]) + Off_Y[Index]) else gr.set.pixels OPix,pixels[],New_X[Index] + Off_X,600-((New_Y[Index]*Amp[Index])+Off_Y[Index]) end if Old_Y[Index] = New_Y[Index] Old_X[Index] = New_X[Index] gr.render Return Coordinate: gr.line Ord, 50,50,50,550 gr.line asc, 50,550,950,550 for divy = 50 to 550 step 50 gr.line szy, Off_X - 10,divy, Off_X, divy gr.render next divy for divx = 50 to 950 step 90 gr.line szx, divx,560, divx, 550 gr.render next divx gr.color 255,255,240,0,0 gr.text.size 22 gr.get.textbounds A_Name$,Lf,Tp,Rt,Bt gr.text.draw nas,500-((Rt-Lf)/2),590,A_Name$ gr.render S_Point = (600-(len(O_Name$)*25))/2 for yp = 1 to len(O_Name$) SF$ = Mid$(O_Name$,yp,1) gr.get.textbounds SF$,Lf,Tp,Rt,Bt cc= (Rt/2) gr.text.draw nas,20-cc,(yp*25)+S_Point,SF$ gr.render next yp gr.color 255,255,255,255,0 Return Pnt_Time: Time Year$, Month$, Day$, Hour$, Minute$, Second$ gr.color 255,255,255,255,0 gr.text.size 17 Ini_Tempo$ = Hour$ + ":" + Minute$ gr.text.draw tme, 28,583,Ini_Tempo$ gr.render Return Wipe_Off: gr.color 255, 0, 0, 0, 1 gr.rect wgr, 51,0,1000,549 gr.render gr.color 255, 255, 255, 255, 0 Return SetUp: swv = 0 KL[1,1]=255 KL[1,2]=255 KL[1,3]=255 KL[1,4]=255 KL[2,1]=255 KL[2,2]=255 KL[2,3]=255 KL[2,4]=0 KL[3,1]=255 KL[3,2]=255 KL[3,3]=0 KL[3,4]=255 KL[4,1]=255 KL[4,2]=0 KL[4,3]=255 KL[4,4]=255 gr.set.antialias 0 Off_X = 51 !------------------------------------------------------------------------- ! Minimum Y offset = 51 (lower value will not be removed by the wipe off) Off_Y[1] = 181 % (**) Off_Y[2] = 311 % (**) Off_Y[3] = 401 % (**) Off_Y[4] = 51 % (**) Amp[1] = 50 % (***) Amp[2] = 50 % (***) Amp[3] = 5 % (***) Amp[4] = 1 % (***) !------------------------------------------------------------------------ New_X = 0 Old_X = New_X Old_Y[1] = New_Y[1] Old_Y[2] = New_Y[2] Old_Y[3] = New_Y[3] Old_Y[4] = New_Y[4] !---------------------------------------------------- A_Name$ = "Time" % (*) O_Name$ = "Amplitude" % (*) Return !---------------------------------------------------- ! End Sub-Routines !---------------------------------------------------- Skip_Sub: !------------------------------------------------------------------- ! The above part of this program can be used as an "INCLUDE" !-------------------------------------------------------------------- gr.open 255,0,0,0,0,0 gr.screen ww, hh gr.scale (ww/1000), (hh/600) gr.color 255,255,255,255,0 gosub SetUp gosub Coordinate gosub Pnt_Time !----------------------------------------------------------------------------------------- Ini: MaxClock = Clock() + 1000 % time base interval (Can be changed to suite your neeed) X_Base = X_Base + 1 % time base increment (X axis) Ds = Ds + 1 % to draw saw tooth and square waves if Ds > 59 then Ds = 0 % 1 minute interval For saw tooth wave and square wave !----------------------------------------------------------------------------------------------- ! Here you will load XY arrays with your proper values !------------------------------------------------------------------- !------------------ First Function ----------------------------------- Index = 1 New_X[Index] = X_Base % (*****) New_Y[Index] = sin(X_Base/20) % (****) gosub Graph !------------------ Second Function ---------------- Index = 2 New_X[Index] = X_Base % (*****) New_Y[Index] = cos(X_Base/20) % (****) gosub Graph !------------------ Third Function ----------------- Index = 3 New_X[Index] = X_Base % (*****) If Ds = 0 then New_X[Index] = X_Base - 1 if Ds = 0 then swv = !swv New_Y[Index] = swv*10 % (****) gosub Graph !----------------- Fourth Function ----------------- Index = 4 New_X[Index] = X_Base % (*****) If Ds = 0 then New_X[Index] = X_Base - 1 New_Y[Index] = Ds % (****) gosub Graph !-------------------------- End of functions -------------------------------------- !------------------------------------------------------------------------------ ! Here the system checks if the screen page if full !------------------------------------------------------------------------------ if X_Base > 900 then % when graph space is full area will be wiped off gosub Wipe_Off gr.hide tme gosub Pnt_Time X_Base = 0 New_X = 0 Old_X = 0 Old_Y = 0 end if !---------------------------------------------------- Do Until Clock() > MaxClock % wait for the setted time goto Ini % Loop for ever End