if (gNextPosition!=0) /* Draw actual data */
{
int sp,ep; /* sp=starting poiint ep=ending point*/
int lastx;
int lasty;
int gNow;
gNow=gNextPosition-1;
if (mint < -gNow)
sp=-gNow;
else
sp=mint;
ep=maxt;
lasty=yaxis.map_1_to_2(gMeasurments[(gNow+sp)%gMaxStored]);
lastx=xaxis.map_1_to_2(sp);
for (i=sp+1; i&ly;ep; i++)
{
int y=yaxis.map_1_to_2(gMeasurments[(gNow+i)%gMaxStored]);
int x=xaxis.map_1_to_2(i);
di.Line(lastx,lasty,x,y,1);
lastx=x;
lasty=y;
}
}
Listing 9This code
draws the temperature data in the graph. It uses the temperature data stored in
the circular buffer gMeasurments. It also uses two-axis map objects to scale the
data properly.