Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of scoreLight_Advanced by
simpleLaserRenderer.h@30:d8af03f01cd4, 2012-09-21 (annotated)
- Committer:
- mbedalvaro
- Date:
- Fri Sep 21 10:02:35 2012 +0000
- Revision:
- 30:d8af03f01cd4
- Parent:
- 25:74cb85b85fd2
- Child:
- 31:5f039cbddee8
first commit. Not yet functional. Added ghost and pacman game modes, but the behaviour of these "rigid spots" is not implemented yet
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedalvaro | 30:d8af03f01cd4 | 1 | #ifndef simpleLaserSensingRenderer_h |
| mbedalvaro | 30:d8af03f01cd4 | 2 | #define simpleLaserSensingRenderer_h |
| mbedalvaro | 30:d8af03f01cd4 | 3 | |
| mbedalvaro | 30:d8af03f01cd4 | 4 | #include "blobConfig.h" |
| mbedalvaro | 30:d8af03f01cd4 | 5 | // Include hardware interface for display and sensing: |
| mbedalvaro | 30:d8af03f01cd4 | 6 | #include "hardwareIO.h" |
| mbedalvaro | 30:d8af03f01cd4 | 7 | |
| mbedalvaro | 30:d8af03f01cd4 | 8 | //extern DigitalOut myled3; // for tests... |
| mbedalvaro | 30:d8af03f01cd4 | 9 | |
| mbedalvaro | 30:d8af03f01cd4 | 10 | #define debugDelayMirrors // this is to check visually the mirror delay (but it is also beautiful) |
| mbedalvaro | 30:d8af03f01cd4 | 11 | |
| mbedalvaro | 30:d8af03f01cd4 | 12 | #define RED_BLANKING // note: RED blanking introduces problems because the Lock-in looses signal, but we can add more points to compensate when there |
| mbedalvaro | 30:d8af03f01cd4 | 13 | // are many blobs, see "DEFAULT_OVERLAP_POINTS" (but will slow down...) |
| mbedalvaro | 30:d8af03f01cd4 | 14 | |
| mbedalvaro | 30:d8af03f01cd4 | 15 | #define RENDER_INTERVAL 0.00011 // good value in previous version (monaco) was 0.00011 // in seconds (Ticker) |
| mbedalvaro | 30:d8af03f01cd4 | 16 | |
| mbedalvaro | 30:d8af03f01cd4 | 17 | #define WAIT_NORMAL 0 // good :0 // (minimum is 0) waiting time for setting mirror position MINUS waiting laser time (note that this total waiting time may be equal to 0 if we set a good sampling freq for the renderer, but |
| mbedalvaro | 30:d8af03f01cd4 | 18 | // and if the shape is regular so that this time does not change significatively - this is not the case for multiple blobs or highly deformed blobs). |
| mbedalvaro | 30:d8af03f01cd4 | 19 | #define WAIT_LASER 0 // (minimum is 0) waiting time for activating the laser (if there are color changes IN BETWEEN points). Maybe needed for the green laser |
| mbedalvaro | 30:d8af03f01cd4 | 20 | // WHEN THERE IS MORE THAN ONE SPOT: |
| mbedalvaro | 30:d8af03f01cd4 | 21 | #define WAIT_FIRST 12 // special waiting time for mirror positioning to first point on next blob BEFORE re-activating laser |
| mbedalvaro | 30:d8af03f01cd4 | 22 | #define WAIT_FIRST_LASER 0 // IMPORTANT waiting time for the activation of the RED laser and LOCK-IN (also waiting time for the mirrors) |
| mbedalvaro | 30:d8af03f01cd4 | 23 | #define WAIT_LAST 0 // special waiting time for last point |
| mbedalvaro | 30:d8af03f01cd4 | 24 | |
| mbedalvaro | 30:d8af03f01cd4 | 25 | // Redundant drawing for avoiding deformed saccade (note: this could be active when there is more than one blob, instead of using a #define...) |
| mbedalvaro | 30:d8af03f01cd4 | 26 | #define DEFAULT_OVERLAP_POINTS 10 |
| mbedalvaro | 30:d8af03f01cd4 | 27 | |
| mbedalvaro | 30:d8af03f01cd4 | 28 | enum lsdStateType {NORMAL_POINT, LAST_POINT, MOVE_NEXT_BLOB, START_POINT}; |
| mbedalvaro | 30:d8af03f01cd4 | 29 | |
| mbedalvaro | 30:d8af03f01cd4 | 30 | class simpleLaserSensingRenderer { |
| mbedalvaro | 30:d8af03f01cd4 | 31 | public: |
| mbedalvaro | 30:d8af03f01cd4 | 32 | |
| mbedalvaro | 30:d8af03f01cd4 | 33 | void setConfigToRender(blobConfig*); |
| mbedalvaro | 30:d8af03f01cd4 | 34 | //void startRenderer(); // pb: I cannot use the ticker function inside the class! |
| mbedalvaro | 30:d8af03f01cd4 | 35 | void laserRenderThread(); |
| mbedalvaro | 30:d8af03f01cd4 | 36 | void laserRenderThreadONEBLOBONLY(); |
| mbedalvaro | 30:d8af03f01cd4 | 37 | // void laserRender(blobConfig*); |
| mbedalvaro | 30:d8af03f01cd4 | 38 | |
| mbedalvaro | 30:d8af03f01cd4 | 39 | blobConfig* ptBlobCfToRender; |
| mbedalvaro | 30:d8af03f01cd4 | 40 | |
| mbedalvaro | 30:d8af03f01cd4 | 41 | lsdStateType stateLsd; |
| mbedalvaro | 30:d8af03f01cd4 | 42 | int totalBlobs; |
| mbedalvaro | 30:d8af03f01cd4 | 43 | int currentBlob; |
| mbedalvaro | 30:d8af03f01cd4 | 44 | int currentPoint; |
| mbedalvaro | 30:d8af03f01cd4 | 45 | int currentMirrorDelay; |
| mbedalvaro | 30:d8af03f01cd4 | 46 | int currentTotalPoints; |
| mbedalvaro | 30:d8af03f01cd4 | 47 | int currentColor; |
| mbedalvaro | 30:d8af03f01cd4 | 48 | unsigned short x,y; // auxiliary variables storing mirror position(0-4096) |
| mbedalvaro | 30:d8af03f01cd4 | 49 | |
| mbedalvaro | 30:d8af03f01cd4 | 50 | // New method to check complete display of one loop: |
| mbedalvaro | 30:d8af03f01cd4 | 51 | unsigned char configTotalPoints; |
| mbedalvaro | 30:d8af03f01cd4 | 52 | unsigned char pointDisplayCounter; |
| mbedalvaro | 30:d8af03f01cd4 | 53 | unsigned char numOverlapPoints; |
| mbedalvaro | 30:d8af03f01cd4 | 54 | bool endedFullDisplay(); |
| mbedalvaro | 30:d8af03f01cd4 | 55 | void startFullDisplay(); |
| mbedalvaro | 30:d8af03f01cd4 | 56 | |
| mbedalvaro | 30:d8af03f01cd4 | 57 | int waitNormal, waitLaser, waitFirst, waitFirstLaser, waitLast; |
| mbedalvaro | 30:d8af03f01cd4 | 58 | }; |
| mbedalvaro | 30:d8af03f01cd4 | 59 | |
| mbedalvaro | 30:d8af03f01cd4 | 60 | #endif |
| mbedalvaro | 30:d8af03f01cd4 | 61 | |
| mbedalvaro | 30:d8af03f01cd4 | 62 | |
| mbedalvaro | 30:d8af03f01cd4 | 63 |
