Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
Diff: main.cpp
- Revision:
- 16:2ff1cb2ae1b1
- Parent:
- 14:0fc33a3a7b4b
- Child:
- 17:356ca5690a59
diff -r 56a0bf424e8d -r 2ff1cb2ae1b1 main.cpp --- a/main.cpp Thu Apr 12 14:50:50 2012 +0000 +++ b/main.cpp Fri Apr 13 07:43:09 2012 +0000 @@ -110,8 +110,8 @@ // blobconf.addOneRigidLoopBouncing(); // blobconf.addOneRigidLoopBouncing(); -blobconf.addOneRigidLoopFollowing(); -blobconf.addOneRigidLoopFollowing(); +//blobconf.addOneRigidLoopFollowing(); + blobconf.addOneRigidLoopFollowing(); //blobconf.addOneRigidLoopTest(); @@ -157,9 +157,9 @@ // draw the config (note: each kind of blob renders differently) blobconf.draw(); - - lsr.startFullDisplay(); // this start the point-display counter (wherever the actual laser is). Before update and draw, the counter needs to be reset. - + + lsr.startFullDisplay(); // this start the point-display counter (wherever the actual laser is). Before update and draw, the counter needs to be reset. + // __enable_irq(); @@ -179,16 +179,16 @@ #endif - // (b)Sending Data: // PUT THIS IN AN INTERRUPT OR USE A TIMER!!! it may be TOO FAST... - // NOTE: better use a timer, so the only ISR "ticker" is the laser rendering (otherwise the laser rendering will be interrupted by the sending of data - the other way is ok): - if (measureSendPeriod.read_ms()>25) { - measureSendPeriod.stop(); - measureSendPeriod.reset(); + // (b)Sending Data: // PUT THIS IN AN INTERRUPT OR USE A TIMER!!! it may be TOO FAST... + // NOTE: better use a timer, so the only ISR "ticker" is the laser rendering (otherwise the laser rendering will be interrupted by the sending of data - the other way is ok): + if (measureSendPeriod.read_ms()>25) { + measureSendPeriod.stop(); + measureSendPeriod.reset(); - blobconf.sendConfData(); + blobconf.sendConfData(); - measureSendPeriod.start(); - } + measureSendPeriod.start(); + } // text: @@ -233,7 +233,7 @@ //interpretCommand(const char& address[2][], const int& data[2]) { void interpretCommand() { // (I) =========================================== SPECIAL FUNCTIONS (reset, rescan LUT, etc) ==================================================== - if ( !strcmp(address[0], "takeSnapshot" ) ) { + if ( !strcmp(address[0], "takeSnapshot" ) ) { // for test: for (int i=0; i<2 ; i++) { @@ -285,7 +285,7 @@ lsr.setConfigToRender(&blobconf); timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); - + } else if (!strcmp(address[0], "elastic_mouth")) { // timerForRendering.detach(); // blobconf.computeBoundingBox(); @@ -297,20 +297,40 @@ } else if (!strcmp(address[0], "spot_bouncing")) { + int value=data[0]; + if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data) + + timerForRendering.detach(); + // blobconf.computeBoundingBox(); + blobconf.clearConfig(); + + for (int i=0; i<value ; i++) blobconf.addOneRigidLoopBouncing(); + + lsr.setConfigToRender(&blobconf); + timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); + // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); + } + } + + else if (!strcmp(address[0], "spot_following")) { + int value=data[0]; + if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data) + + timerForRendering.detach(); + // blobconf.computeBoundingBox(); + blobconf.clearConfig(); + for (int i=0; i<value ; i++) blobconf.addOneRigidLoopFollowing(); + lsr.setConfigToRender(&blobconf); + timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); + // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); + } + } + + else if (!strcmp(address[0], "spot_test")) { timerForRendering.detach(); // blobconf.computeBoundingBox(); blobconf.clearConfig(); - blobconf.addOneRigidLoopBouncing(); - lsr.setConfigToRender(&blobconf); - timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); - // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); - } - - else if (!strcmp(address[0], "spot_following")) { - timerForRendering.detach(); - // blobconf.computeBoundingBox(); - blobconf.clearConfig(); - blobconf.addOneRigidLoopFollowing(); + blobconf.addOneRigidLoopTest(); lsr.setConfigToRender(&blobconf); timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); @@ -480,24 +500,23 @@ // Finally, start again threaded display: timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); - } - else if (!strcmp(stringCommand , "REDON")) IO.setRedPower(1); // pc.printf("%d\n",incomingByte); + } else if (!strcmp(stringCommand , "REDON")) IO.setRedPower(1); // pc.printf("%d\n",incomingByte); else if (!strcmp(stringCommand , "REDOFF")) IO.setRedPower(0); else if (!strcmp(stringCommand , "READVALUE")) pc.printf("Value read: %f", lockin.getSmoothValue());//lockin.getLastValue());/ else if (!strcmp(stringCommand , "mbedReset")) mbed_reset(); - + else if (!strcmp(stringCommand , "calibrate")) { - // First, we need to disable the threaded display for the loop: - timerForRendering.detach(); - // RESCAN (and save LUT table): - IO.scanLUT(); - // Finally, start again threaded display: - timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); - // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); - } + // First, we need to disable the threaded display for the loop: + timerForRendering.detach(); + // RESCAN (and save LUT table): + IO.scanLUT(); + // Finally, start again threaded display: + timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL); + // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL); + } // FINALLY, interpret commands (but only after parsing): // interpretCommand();//address, data);