diff options
Diffstat (limited to 'src/testApp.cpp')
| -rw-r--r-- | src/testApp.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index 81b77e2..081c3e6 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -41,7 +41,7 @@ void testApp::setup(){ light=true; - camWidth = 320; // try to grab at this size. + camWidth = 320; // try to grab at this size. camHeight = 240; vidGrabber.setVerbose(true); @@ -49,12 +49,17 @@ void testApp::setup(){ vidGrabber.setDeviceID(0); - vidGrabber.initGrabber(camWidth,camHeight); + grabberAvailable=vidGrabber.initGrabber(camWidth,camHeight); //printf("asked for 320 by 240 - actual size is %i by %i\n", vidGrabber.width, vidGrabber.height); videoInverted = new unsigned char[camWidth*camHeight*3]; videoTexture.allocate(camWidth,camHeight, GL_RGB); + ard.connect("/dev/ttyUSB0", 57600); + ofAddListener(ard.EInitialized, this, &testApp::setupArduino); + bSetupArduino = false; + bSwitchArduino = false; + } //-------------------------------------------------------------- @@ -76,10 +81,44 @@ void testApp::update(){ videoTexture.loadData(videoInverted, camWidth,camHeight, GL_RGB); } } + + updateArduino(); +} + +//-------------------------------------------------------------- +void testApp::setupArduino(const int & version) { + + // remove listener because we don't need it anymore + ofRemoveListener(ard.EInitialized, this, &testApp::setupArduino); + + // this is where you setup all the pins and pin modes, etc + for (int i = 0; i < 13; i++){ + ard.sendDigitalPinMode(i, ARD_OUTPUT); + } + ard.sendDigitalPinMode(7, ARD_INPUT); + + bSetupArduino = true; + printf("arduino ready\n"); +} + +//-------------------------------------------------------------- +void testApp::updateArduino(){ + + // update the arduino, get any data or messages. + ard.update(); + + // do not send anything until the arduino has been set up + if (bSetupArduino) { + if (bSwitchArduino!=ard.getDigital(7)) { + bSwitchArduino=ard.getDigital(7); + printf("pin 7 %i\n",bSwitchArduino); + } + } } //-------------------------------------------------------------- void testApp::draw(){ + if (mode!=CALIBRATE&&bSetupArduino&!bSwitchArduino) return; for (int i=0;i<numViews;i++) { views[i].setLight(); } |
