Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Thu Apr 17 08:04:14 2014 +0000
Revision:
47:199042980678
Parent:
43:1dd4cfc30788
publishing for sharing with Ken Iwasaki

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 40:3ba2b0ea9f33 1 #include "laserSensingDisplay.h"
mbedalvaro 40:3ba2b0ea9f33 2
mbedalvaro 40:3ba2b0ea9f33 3 laserSensingDisplay lsd; // pre-instantiated cross-file global object
mbedalvaro 40:3ba2b0ea9f33 4
mbedalvaro 40:3ba2b0ea9f33 5 // The constructor:
mbedalvaro 40:3ba2b0ea9f33 6 laserSensingDisplay::laserSensingDisplay()
mbedalvaro 40:3ba2b0ea9f33 7 {
mbedalvaro 40:3ba2b0ea9f33 8 // pointDisplayCounter=65535;
mbedalvaro 40:3ba2b0ea9f33 9 runningState=false;// this is important for the FIRST time (could be better in an "init" function?).
mbedalvaro 43:1dd4cfc30788 10 displayingFinished=false;
mbedalvaro 40:3ba2b0ea9f33 11 }
mbedalvaro 40:3ba2b0ea9f33 12
mbedalvaro 40:3ba2b0ea9f33 13 void laserSensingDisplay::run() // start the ticker on laserDisplayThread
mbedalvaro 40:3ba2b0ea9f33 14 {
mbedalvaro 40:3ba2b0ea9f33 15 timerForRendering.attach(this, &laserSensingDisplay::laserDisplayThread, RENDER_INTERVAL); // the address of the object, member function, and interval (in seconds)
mbedalvaro 40:3ba2b0ea9f33 16 runningState=true;
mbedalvaro 40:3ba2b0ea9f33 17 }
mbedalvaro 40:3ba2b0ea9f33 18
mbedalvaro 40:3ba2b0ea9f33 19 void laserSensingDisplay::stop() // stop the ticker on laserDisplayThread
mbedalvaro 40:3ba2b0ea9f33 20 {
mbedalvaro 40:3ba2b0ea9f33 21 timerForRendering.detach();
mbedalvaro 40:3ba2b0ea9f33 22 runningState=false;
mbedalvaro 40:3ba2b0ea9f33 23 }
mbedalvaro 40:3ba2b0ea9f33 24
mbedalvaro 40:3ba2b0ea9f33 25 bool laserSensingDisplay::isRunning()
mbedalvaro 40:3ba2b0ea9f33 26 {
mbedalvaro 40:3ba2b0ea9f33 27 return(runningState);
mbedalvaro 40:3ba2b0ea9f33 28 }
mbedalvaro 40:3ba2b0ea9f33 29
mbedalvaro 40:3ba2b0ea9f33 30 void laserSensingDisplay::setSceneToDisplay(Scene* ptScene)
mbedalvaro 40:3ba2b0ea9f33 31 {
mbedalvaro 40:3ba2b0ea9f33 32 //Note: if the scene is recreated, it is important to first stop the displaying, and call to this function again, and only then re-attach the interrupt
mbedalvaro 40:3ba2b0ea9f33 33
mbedalvaro 40:3ba2b0ea9f33 34 ptSceneToDisplay=ptScene;
mbedalvaro 40:3ba2b0ea9f33 35 totalObjects=ptSceneToDisplay->totalObjects();
mbedalvaro 40:3ba2b0ea9f33 36
mbedalvaro 40:3ba2b0ea9f33 37 // overlap display to avoid deformed saccade and give time to the mirrors to be well in the saccade trajectory
mbedalvaro 40:3ba2b0ea9f33 38 // NOTE: ideally, numOverlapPoints depends on the number of points of EACH blob, as well as the distance between the spots.
mbedalvaro 40:3ba2b0ea9f33 39 // But for the time being, this will be a fixed quantity (DEFAULT_OVERLAP_POINTS).
mbedalvaro 40:3ba2b0ea9f33 40 if (totalObjects>1) numOverlapPoints=DEFAULT_OVERLAP_POINTS;
mbedalvaro 40:3ba2b0ea9f33 41 else numOverlapPoints=0;
mbedalvaro 40:3ba2b0ea9f33 42
mbedalvaro 40:3ba2b0ea9f33 43 configTotalPoints=ptSceneToDisplay->totalPoints();
mbedalvaro 40:3ba2b0ea9f33 44 // configTotalPoints contains the number of points of the config, and will be used to ensure that a FULL DISPLAY has been done BEFORE updating and "re-drawing" the trajectory in the buffer,
mbedalvaro 40:3ba2b0ea9f33 45 // wherever the current point being displayed when we start the update/draw.
mbedalvaro 40:3ba2b0ea9f33 46 // pointDisplayCounter=0;
mbedalvaro 40:3ba2b0ea9f33 47
mbedalvaro 40:3ba2b0ea9f33 48 // Set time counters to 0:
mbedalvaro 40:3ba2b0ea9f33 49 // NOTE: the waiting times (normal, start and end point) can be OBJECT dependent. This may be a nice future (TO DO?).
mbedalvaro 40:3ba2b0ea9f33 50 waitFirst=0;
mbedalvaro 40:3ba2b0ea9f33 51 waitFirstLaser=0;
mbedalvaro 40:3ba2b0ea9f33 52 waitNormal=0;
mbedalvaro 40:3ba2b0ea9f33 53 waitLaser=0;
mbedalvaro 40:3ba2b0ea9f33 54 waitLast=0;
mbedalvaro 40:3ba2b0ea9f33 55
mbedalvaro 40:3ba2b0ea9f33 56 // IMPORTANT: we have to start like this:
mbedalvaro 40:3ba2b0ea9f33 57 stateLsd=START_FIRST_OBJECT;
mbedalvaro 43:1dd4cfc30788 58
mbedalvaro 43:1dd4cfc30788 59 displayingFinished=false;
mbedalvaro 40:3ba2b0ea9f33 60 }
mbedalvaro 40:3ba2b0ea9f33 61
mbedalvaro 40:3ba2b0ea9f33 62 bool laserSensingDisplay::isDisplayingOver()
mbedalvaro 40:3ba2b0ea9f33 63 {
mbedalvaro 40:3ba2b0ea9f33 64 return(displayingFinished); // the value of displayingFinished will become true when the renderer finished displaying all points of all objects.
mbedalvaro 40:3ba2b0ea9f33 65 }
mbedalvaro 40:3ba2b0ea9f33 66
mbedalvaro 40:3ba2b0ea9f33 67 void laserSensingDisplay::startDisplayCheck()
mbedalvaro 40:3ba2b0ea9f33 68 {
mbedalvaro 40:3ba2b0ea9f33 69 displayingFinished=false; // we set it to false, wherever we where in the displaying process; when it becomes true, it means we had
mbedalvaro 40:3ba2b0ea9f33 70 // completed at least one full display of the unchanged scene.
mbedalvaro 40:3ba2b0ea9f33 71 }
mbedalvaro 40:3ba2b0ea9f33 72
mbedalvaro 40:3ba2b0ea9f33 73 // THE CORE OF THE DISPLAYING ENGINE:
mbedalvaro 40:3ba2b0ea9f33 74 // Note: this routine should run in a thread - but in fact it is running in an interrupt routine for the time being.
mbedalvaro 40:3ba2b0ea9f33 75 void laserSensingDisplay::laserDisplayThread()
mbedalvaro 40:3ba2b0ea9f33 76 {
mbedalvaro 40:3ba2b0ea9f33 77 // For tests:
mbedalvaro 40:3ba2b0ea9f33 78 myLed1=!myLed1;
mbedalvaro 40:3ba2b0ea9f33 79 // pc.printf("Point nb: %d\n", currentPoint);// does serial works in the interrupt?
mbedalvaro 40:3ba2b0ea9f33 80
mbedalvaro 40:3ba2b0ea9f33 81 switch (stateLsd) {
mbedalvaro 40:3ba2b0ea9f33 82 case NORMAL_POINT:
mbedalvaro 40:3ba2b0ea9f33 83 if (currentPoint<currentTotalPoints+numOverlapPoints) { // Attention: use modulo currentTotalPoints when accessing trajectory index.
mbedalvaro 40:3ba2b0ea9f33 84 if (waitNormal==0) { // Send mirrors position the first time (note: I don't put this inside the waitNormal<WAIT_NORMAL, because WAIT_NORMAL can be 0!
mbedalvaro 40:3ba2b0ea9f33 85 uint8_t currentPointWrap=currentPoint%currentTotalPoints;
mbedalvaro 40:3ba2b0ea9f33 86 x= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPointWrap].v2.x;
mbedalvaro 40:3ba2b0ea9f33 87 y= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPointWrap].v2.y;
mbedalvaro 40:3ba2b0ea9f33 88
mbedalvaro 40:3ba2b0ea9f33 89 IO.writeOutX(x);
mbedalvaro 40:3ba2b0ea9f33 90 IO.writeOutY(y);
mbedalvaro 40:3ba2b0ea9f33 91 // for tests:
mbedalvaro 40:3ba2b0ea9f33 92 // pc.printf("%d - %d\n", x, y);// does serial works in the interrupt?
mbedalvaro 40:3ba2b0ea9f33 93 }
mbedalvaro 40:3ba2b0ea9f33 94 if (waitNormal<WAIT_NORMAL) {
mbedalvaro 40:3ba2b0ea9f33 95 waitNormal++;// wait a little to correct for mirror delay (note: the mirror effective waiting time is WAIT_NORMAL + WAIT_LASER)
mbedalvaro 40:3ba2b0ea9f33 96 } else { // if we got here, it means the mirrors are well positionned: activate laser:
mbedalvaro 40:3ba2b0ea9f33 97 if ((waitLaser==0)&&(currentPoint>numOverlapPoints)) { // change laser output the first time:
mbedalvaro 40:3ba2b0ea9f33 98 #ifdef SENSING_LASER_BLANKING
mbedalvaro 40:3ba2b0ea9f33 99 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 100 #endif
mbedalvaro 40:3ba2b0ea9f33 101 #ifndef debugDelayMirrors
mbedalvaro 40:3ba2b0ea9f33 102 IO.setRGBPower(currentColor);
mbedalvaro 40:3ba2b0ea9f33 103 #else // TEST MODE for delay using blue laser:
mbedalvaro 40:3ba2b0ea9f33 104 uint8_t delayedPoint=(currentPoint+currentTotalPoints-ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.delayMirrorSamples)%currentTotalPoints;
mbedalvaro 40:3ba2b0ea9f33 105 if ( ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[delayedPoint].lightZone<0) { // note: we use PREVIOUS sensing - so as not to wait again for
mbedalvaro 40:3ba2b0ea9f33 106 //IO.setRGBPower((currentColor&0x02)|0x04); // RED always on, BLUE OFF (and green whatever it was)
mbedalvaro 40:3ba2b0ea9f33 107 // Note: better not use complicated calls?
mbedalvaro 40:3ba2b0ea9f33 108 IO.setRGBPower(currentColor|0x02); // add blue (if blue was on, nothing happens...)
mbedalvaro 40:3ba2b0ea9f33 109 } else {
mbedalvaro 40:3ba2b0ea9f33 110 IO.setGreenPower(currentColor);
mbedalvaro 40:3ba2b0ea9f33 111 }
mbedalvaro 40:3ba2b0ea9f33 112 #endif
mbedalvaro 40:3ba2b0ea9f33 113 }
mbedalvaro 40:3ba2b0ea9f33 114 if (waitLaser<WAIT_LASER) {
mbedalvaro 40:3ba2b0ea9f33 115 waitLaser++; // increment wait laser counter
mbedalvaro 40:3ba2b0ea9f33 116 } else { // If we got here, it means that mirrors and laser power are both properly set:
mbedalvaro 40:3ba2b0ea9f33 117
mbedalvaro 40:3ba2b0ea9f33 118 // READ the intensity and move to the next point:
mbedalvaro 40:3ba2b0ea9f33 119 uint8_t currentPointWrap=currentPoint%currentTotalPoints;
mbedalvaro 40:3ba2b0ea9f33 120 ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPointWrap].intensity=(unsigned char)(255.0*IO.lockInCorrectedValue(x,y));
mbedalvaro 40:3ba2b0ea9f33 121 ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPointWrap].intensity=(unsigned char)(255.0*IO.lockInCorrectedValue(x,y));
mbedalvaro 40:3ba2b0ea9f33 122
mbedalvaro 40:3ba2b0ea9f33 123 // Move to next point:
mbedalvaro 40:3ba2b0ea9f33 124 currentPoint++;
mbedalvaro 40:3ba2b0ea9f33 125
mbedalvaro 40:3ba2b0ea9f33 126 waitNormal=0;
mbedalvaro 40:3ba2b0ea9f33 127 waitLaser=0;
mbedalvaro 40:3ba2b0ea9f33 128
mbedalvaro 40:3ba2b0ea9f33 129 // Update the point display counter (meaning: this point has been properly acquired - we need (at least) configTotalPoints
mbedalvaro 40:3ba2b0ea9f33 130 // of those good acquisitions before updating and re-draw). But attention! this counter may OVERFLOW!
mbedalvaro 40:3ba2b0ea9f33 131 //pointDisplayCounter++;
mbedalvaro 40:3ba2b0ea9f33 132 }
mbedalvaro 40:3ba2b0ea9f33 133 }
mbedalvaro 40:3ba2b0ea9f33 134 } else { // this means we ended rendering this blob, with or without partial duplication
mbedalvaro 40:3ba2b0ea9f33 135
mbedalvaro 40:3ba2b0ea9f33 136 #ifdef debugDelayMirrors // this means that we will process the saccade data all the time, not only when querying the data! can be useful for tests only
mbedalvaro 40:3ba2b0ea9f33 137 ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.processSensedData();
mbedalvaro 40:3ba2b0ea9f33 138 #endif
mbedalvaro 40:3ba2b0ea9f33 139
mbedalvaro 40:3ba2b0ea9f33 140 if (totalObjects>1) stateLsd=LAST_POINT;
mbedalvaro 40:3ba2b0ea9f33 141 else { // this means we are rendering a unique blob:
mbedalvaro 40:3ba2b0ea9f33 142 // currentObject does not change (equal to 0 always), stateLsd is always NORMAL_POINT
mbedalvaro 40:3ba2b0ea9f33 143 // The only thing we need to do is to reset "currentPoint" to 0, and eventually change the color of the blob:
mbedalvaro 40:3ba2b0ea9f33 144 currentPoint=0;
mbedalvaro 40:3ba2b0ea9f33 145 currentColor=ptSceneToDisplay->objectArray[currentObject]->myColor;
mbedalvaro 40:3ba2b0ea9f33 146
mbedalvaro 40:3ba2b0ea9f33 147 // Also, note that this means we ended displaying a whole "configuration", hence:
mbedalvaro 40:3ba2b0ea9f33 148 displayingFinished=true; // (whatever the previous state was).
mbedalvaro 40:3ba2b0ea9f33 149 }
mbedalvaro 40:3ba2b0ea9f33 150 }
mbedalvaro 40:3ba2b0ea9f33 151 break;
mbedalvaro 40:3ba2b0ea9f33 152 case LAST_POINT:
mbedalvaro 40:3ba2b0ea9f33 153 // pc.printf("LAST\n");// does serial works in the interrupt?
mbedalvaro 40:3ba2b0ea9f33 154
mbedalvaro 40:3ba2b0ea9f33 155 // We need to pause for a while (this is for avoiding a deformed end of a blob when there are more than one blob AND we did not properly correct the mirror delay - this may be because
mbedalvaro 40:3ba2b0ea9f33 156 // we want a faster display, in which case we will need to adjust the mirrorDelay variable to something different from 0)
mbedalvaro 40:3ba2b0ea9f33 157 if (waitLast<WAIT_LAST) waitLast++;
mbedalvaro 40:3ba2b0ea9f33 158 else {
mbedalvaro 40:3ba2b0ea9f33 159 // switch off displaying lasers AND if required, the sensing laser (NOTE: there is no need to wait for switch off time)
mbedalvaro 40:3ba2b0ea9f33 160 IO.setRGBPower(0x00);
mbedalvaro 40:3ba2b0ea9f33 161 #ifdef SENSING_LASER_BLANKING
mbedalvaro 40:3ba2b0ea9f33 162 IO.setLaserLockinPower(0);
mbedalvaro 40:3ba2b0ea9f33 163 #endif
mbedalvaro 40:3ba2b0ea9f33 164 waitLast=0;
mbedalvaro 40:3ba2b0ea9f33 165 stateLsd=MOVE_NEXT_OBJECT;
mbedalvaro 40:3ba2b0ea9f33 166 }
mbedalvaro 40:3ba2b0ea9f33 167 break;
mbedalvaro 40:3ba2b0ea9f33 168
mbedalvaro 40:3ba2b0ea9f33 169 case START_FIRST_OBJECT:
mbedalvaro 40:3ba2b0ea9f33 170 // pc.printf("START NEW OBJECT\n");// does serial works in the interrupt?
mbedalvaro 40:3ba2b0ea9f33 171
mbedalvaro 40:3ba2b0ea9f33 172 currentObject=0;
mbedalvaro 40:3ba2b0ea9f33 173
mbedalvaro 40:3ba2b0ea9f33 174 // currentMirrorDelay=ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.delayMirrorSamples; // per blob delay!
mbedalvaro 40:3ba2b0ea9f33 175 currentTotalPoints=ptSceneToDisplay->objectArray[currentObject]->size(); // or using: displaySensingBuffer.lsdTrajectory.size() (but now I made it private to mantain size consistancy between 3d and 2d array size)
mbedalvaro 40:3ba2b0ea9f33 176 currentColor=ptSceneToDisplay->objectArray[currentObject]->myColor;
mbedalvaro 40:3ba2b0ea9f33 177 currentPoint=0;
mbedalvaro 40:3ba2b0ea9f33 178
mbedalvaro 40:3ba2b0ea9f33 179 if (totalObjects>1) stateLsd=START_POINT;
mbedalvaro 40:3ba2b0ea9f33 180 else stateLsd=NORMAL_POINT; // in this case, we can skip the waiting for the last point (and first point too)
mbedalvaro 40:3ba2b0ea9f33 181 break;
mbedalvaro 40:3ba2b0ea9f33 182
mbedalvaro 40:3ba2b0ea9f33 183 case MOVE_NEXT_OBJECT:
mbedalvaro 40:3ba2b0ea9f33 184 // TO DO: line and counter to avoid overshoot?
mbedalvaro 40:3ba2b0ea9f33 185
mbedalvaro 40:3ba2b0ea9f33 186 // Start processing next blob:
mbedalvaro 40:3ba2b0ea9f33 187 currentObject=(currentObject+1)%totalObjects;
mbedalvaro 40:3ba2b0ea9f33 188
mbedalvaro 40:3ba2b0ea9f33 189 // NOTE: check if this was the last object:
mbedalvaro 40:3ba2b0ea9f33 190 if (currentObject==0) {
mbedalvaro 40:3ba2b0ea9f33 191 displayingFinished=true; // that meant we cycle over the whole configuration
mbedalvaro 40:3ba2b0ea9f33 192 }
mbedalvaro 40:3ba2b0ea9f33 193
mbedalvaro 40:3ba2b0ea9f33 194 // currentMirrorDelay=ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.delayMirrorSamples; // per blob delay!
mbedalvaro 40:3ba2b0ea9f33 195 currentTotalPoints=ptSceneToDisplay->objectArray[currentObject]->size();// displaySensingBuffer.lsdTrajectory.size();
mbedalvaro 40:3ba2b0ea9f33 196 currentColor=ptSceneToDisplay->objectArray[currentObject]->myColor;
mbedalvaro 40:3ba2b0ea9f33 197 currentPoint=0;
mbedalvaro 40:3ba2b0ea9f33 198
mbedalvaro 40:3ba2b0ea9f33 199 if (totalObjects>1) stateLsd=START_POINT;
mbedalvaro 40:3ba2b0ea9f33 200 else stateLsd=NORMAL_POINT; // in this case, we can skip the waiting for the last point (and first point too)
mbedalvaro 40:3ba2b0ea9f33 201
mbedalvaro 40:3ba2b0ea9f33 202 break;
mbedalvaro 40:3ba2b0ea9f33 203
mbedalvaro 40:3ba2b0ea9f33 204 case START_POINT:
mbedalvaro 40:3ba2b0ea9f33 205 if (waitFirst==0) {
mbedalvaro 40:3ba2b0ea9f33 206 // Send command to position the mirrors on the first point of NEXT blob (laser is flying in between during this time... )
mbedalvaro 40:3ba2b0ea9f33 207 x= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[0].v2.x;
mbedalvaro 40:3ba2b0ea9f33 208 y= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[0].v2.y;
mbedalvaro 40:3ba2b0ea9f33 209 IO.writeOutX(x);
mbedalvaro 40:3ba2b0ea9f33 210 IO.writeOutY(y);
mbedalvaro 40:3ba2b0ea9f33 211 }
mbedalvaro 40:3ba2b0ea9f33 212 if (waitFirst<WAIT_FIRST) waitFirst++; // time for positioning of mirrors on next blob.
mbedalvaro 40:3ba2b0ea9f33 213 else { //mirrors are positioned: activate laser and lock in (needs time):
mbedalvaro 40:3ba2b0ea9f33 214 if (waitFirstLaser==0) {
mbedalvaro 40:3ba2b0ea9f33 215 // activate laser - important in particular for giving time to the Lock-in to catch signal, then laser rouge:
mbedalvaro 40:3ba2b0ea9f33 216 IO.setRGBPower(currentColor);
mbedalvaro 40:3ba2b0ea9f33 217 #ifdef SENSING_LASER_BLANKING
mbedalvaro 40:3ba2b0ea9f33 218 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 219 #endif
mbedalvaro 40:3ba2b0ea9f33 220 }
mbedalvaro 40:3ba2b0ea9f33 221 if (waitFirstLaser<WAIT_FIRST_LASER) waitFirstLaser++;
mbedalvaro 40:3ba2b0ea9f33 222 else {
mbedalvaro 40:3ba2b0ea9f33 223 waitFirst=0;
mbedalvaro 40:3ba2b0ea9f33 224 waitFirstLaser=0;
mbedalvaro 40:3ba2b0ea9f33 225 stateLsd=NORMAL_POINT; // start normal point
mbedalvaro 40:3ba2b0ea9f33 226 }
mbedalvaro 40:3ba2b0ea9f33 227 }
mbedalvaro 40:3ba2b0ea9f33 228 break;
mbedalvaro 40:3ba2b0ea9f33 229 }
mbedalvaro 40:3ba2b0ea9f33 230 }
mbedalvaro 40:3ba2b0ea9f33 231
mbedalvaro 40:3ba2b0ea9f33 232 /*
mbedalvaro 40:3ba2b0ea9f33 233 void laserSensingDisplay::laserRenderThreadONEBLOBONLY() {
mbedalvaro 40:3ba2b0ea9f33 234 // When we arrive here, we ASSUME the mirrors are well positioned at the currentPoint-1, so we need to process the currentPoint:
mbedalvaro 40:3ba2b0ea9f33 235
mbedalvaro 40:3ba2b0ea9f33 236 // Current mirror position:
mbedalvaro 40:3ba2b0ea9f33 237 x= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPoint].v2.x;
mbedalvaro 40:3ba2b0ea9f33 238 y= ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPoint].v2.y;
mbedalvaro 40:3ba2b0ea9f33 239
mbedalvaro 40:3ba2b0ea9f33 240 // (2) Send command to position the mirrors to the next position:
mbedalvaro 40:3ba2b0ea9f33 241 IO.writeOutX(x);
mbedalvaro 40:3ba2b0ea9f33 242 IO.writeOutY(y);
mbedalvaro 40:3ba2b0ea9f33 243
mbedalvaro 40:3ba2b0ea9f33 244 // int delayedPoint=(currentPoint+currentMirrorDelay)%currentTotalPoints;
mbedalvaro 40:3ba2b0ea9f33 245
mbedalvaro 40:3ba2b0ea9f33 246 #ifdef debugDelayMirrors
mbedalvaro 40:3ba2b0ea9f33 247 if ( ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPoint].lightZone<0) {
mbedalvaro 40:3ba2b0ea9f33 248 IO.setBluePower(0);
mbedalvaro 40:3ba2b0ea9f33 249 // myled3=0;
mbedalvaro 40:3ba2b0ea9f33 250 } else {
mbedalvaro 40:3ba2b0ea9f33 251 IO.setBluePower(1);
mbedalvaro 40:3ba2b0ea9f33 252 // myled3=1;
mbedalvaro 40:3ba2b0ea9f33 253 }
mbedalvaro 40:3ba2b0ea9f33 254 //IO.setRGBPower(0x04); else IO.setRGBPower(0x07);
mbedalvaro 40:3ba2b0ea9f33 255 #endif
mbedalvaro 40:3ba2b0ea9f33 256
mbedalvaro 40:3ba2b0ea9f33 257 // (1) SENSING (on the current blob and particle index with mirror delay: )
mbedalvaro 40:3ba2b0ea9f33 258 ptSceneToDisplay->objectArray[currentObject]->displaySensingBuffer.lsdTrajectory[currentPoint].intensity=(unsigned char)(255.0*IO.lockInCorrectedValue(x,y));
mbedalvaro 40:3ba2b0ea9f33 259 //=lockin.getMedianValue(); //lockin.getLastValue();//
mbedalvaro 40:3ba2b0ea9f33 260
mbedalvaro 40:3ba2b0ea9f33 261 // increment the current point index:
mbedalvaro 40:3ba2b0ea9f33 262 currentPoint=(currentPoint+1)%currentTotalPoints;
mbedalvaro 40:3ba2b0ea9f33 263
mbedalvaro 40:3ba2b0ea9f33 264 }
mbedalvaro 40:3ba2b0ea9f33 265 */
mbedalvaro 40:3ba2b0ea9f33 266