Hardware Reference
In-Depth Information
Figure 8-2. Graph visualization of data being sent
Listing 8-1. testApp.cpp, Part 7 of 7
void testApp::draw(){
ofBackground (50,50,50);
ofSetLineWidth (1);
ofSetColor(0,0,0);
for (int i = 266; i > 9; i -=32){ // draw the grid
ofLine(10,i,266,i);
ofLine(i,10,i,266);
}
for (int i = 0; i < 255; i++){ // draw the data
ofSetLineWidth (2);
ofSetColor(0,255,0);
ofLine (i+10,(266 - graph[i]) , i+11 , (266 -graph [i+1]));
ofSetColor(255,255,0);
ofLine (i+10,(266 - graph1[i]) , i+11 , (266 -graph1 [i+1]));
ofSetColor(0,0,255);
ofLine (i+10,(266 - graph2[i]) , i+11 , (266 -graph2 [i+1]));
}
ofSetColor(255,0,0);
ofLine (10 + point, 10, 10 + point, 266); // draw the position line
ofSetLineWidth (1);
} // end testApp::draw()
The last thing before compiling the code is to declare variables and function prototypes in testApp.h . Listing 8-2
describes the class used for the program. For simplicity, a majority of the variables are declared within the class
definition. Listing 8-2 needs to replace the one created with the empty application. The code will need a preliminary
test before the rest of the project is complete. To test, temporarily comment out the three WaitForReply function calls
 
Search WWH ::




Custom Search