void loop() { char cmd; while(!Serial.available()); digitalWrite(PIN_LED,0); getCmd(&cmd); switch(cmd) { case 'Z': //stonycam.chipToMatlab(); frameCaptureAndTx(); //subsampleCaptureAndTx(); //config_state = invert_state(); break; case '?': default: Serial.println("Z: MATLAB chip"); delay(50); break; } digitalWrite(PIN_LED,1); }
void loop() { char opcode,cc; // TODO: for now, the code has no requests for tuning parameters if(0 == gFlagCaptureRunning) { do { while(!DataConn.available()); cc = DataConn.read(); } while(SYMBOL_SOF != cc); // grab data while(!DataConn.available()); opcode = DataConn.read(); if(OPCODE_START == opcode) { gFlagCaptureRunning = 1; DataConn.print(SYMBOL_SOF); DataConn.print(OPCODE_START_ACK); } else if(OPCODE_SINGLE_FRAME == opcode) { digitalWriteFast(PIN_LED,0); frameCaptureAndTx(); digitalWriteFast(PIN_LED,1); } else if(OPCODE_REQ_NUM_CAMS) { DataConn.write(SYMBOL_SOF); DataConn.write(OPCODE_RESP_NUM_CAMS); DataConn.write((char)NUMCAMS); } // otherwise, ignore } else { // check for stop command while(DataConn.available()) { do { cc=DataConn.read(); } while((DataConn.available()) && (SYMBOL_SOF != cc)); if(SYMBOL_SOF != cc) { continue; } // FIXME: if we ONLY get an SOF, we're stuck here! while(!DataConn.available()); opcode = DataConn.read(); if(OPCODE_STOP == opcode) { gFlagCaptureRunning = 0; DataConn.print(OPCODE_STOP_ACK); return; } // otherwise ignore // russ: even when other commands are added to change things (like the sample resolution // or the framerate) these will only be accepted when a capture is not running } digitalWriteFast(PIN_LED,0); frameCaptureAndTx(); digitalWriteFast(PIN_LED,1); } }