Skip to content

Commit

Permalink
pause button
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed May 9, 2012
1 parent d765373 commit 435b751
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fusion1.pde
Expand Up @@ -5,6 +5,7 @@ float MPERSSQUARED_PER_BIT = (1/256.0)*9.807; //(g/LSB)*(m*s^-2/g)=m*s^-2/LSB

IMU imu;
PFont font;
boolean running;

class State{
float s;
Expand Down Expand Up @@ -39,6 +40,13 @@ void keyPressed(){
if(key==' '){
state.s=0;
state.v=0;
} else if(key=='p'){
if(running){
running=false;
} else {
imu.clear();
running=true;
}
}
}

Expand All @@ -51,11 +59,12 @@ void setup(){
imu = new IMU(this, serialPort);

state=null;
running=true;
}

void draw(){
// until the serial stream runs dry
while(true){
while(running){

try{
// grab a reading from the IMU
Expand Down
4 changes: 4 additions & 0 deletions imu.pde
Expand Up @@ -47,6 +47,10 @@ class IMU{
return chunk;
}

void clear(){
serial.clear();
}

IMUReading read() throws IMUParseException{
String raw = readRaw();
if(raw==null){
Expand Down

0 comments on commit 435b751

Please sign in to comment.