Oscilloscope using OF

I am trying to build a PC based Oscilloscope using openFrameworks.
I have the required hardware to send the external signals to PC on its serial port.
But being a newbie i don’t know how should i proceed.
To start with, i just want to plot a digital (1/0) signal with respect to time.
I tried using the ofBeginShape and ofVertex to plot the square/rectangular wave, but i am stuck in plotting it dynamically with respect to time.
Just need a slight push in right direction.
Anyone ?

you need something like a buffer to store the last x points from your signal then draw that in each draw() call. when your buffer has more than let’s say 500 points delete the first one so it doesn’t grow to much. the best structure to do this is a queue:

http://www.cplusplus.com/reference/stl/deque/

you will use it more or less like:

in testApp.h

  
  
#include <deque>  
...  
deque<ofPoint> buffer;  

in update

  
buffer.push_back(p)  
if(buffer.size()>500) buffer.pop_front();  

in draw

  
ofBeginShape();  
for(int i=0;i<buffer.size();i++){  
    ofVertex(buffer[i].x,buffer[i].y);  
}  
ofEndShape();