Alvaro Cassinelli
/
skinGames_II
save loops
simpleLaserRenderer.h@0:df6fdd9b99f0, 2014-12-02 (annotated)
- Committer:
- mbedalvaro
- Date:
- Tue Dec 02 04:39:15 2014 +0000
- Revision:
- 0:df6fdd9b99f0
this new version of skinGames will have a function that stops scanning as the laser reaches the same position (i.e., loops) with a certain precision. It is for extracting contours for Takashita project. It can then save on a file or send on osc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedalvaro | 0:df6fdd9b99f0 | 1 | #ifndef simpleLaserSensingRenderer_h |
mbedalvaro | 0:df6fdd9b99f0 | 2 | #define simpleLaserSensingRenderer_h |
mbedalvaro | 0:df6fdd9b99f0 | 3 | |
mbedalvaro | 0:df6fdd9b99f0 | 4 | #include "blobConfig.h" |
mbedalvaro | 0:df6fdd9b99f0 | 5 | // Include hardware interface for display and sensing: |
mbedalvaro | 0:df6fdd9b99f0 | 6 | #include "hardwareIO.h" |
mbedalvaro | 0:df6fdd9b99f0 | 7 | |
mbedalvaro | 0:df6fdd9b99f0 | 8 | //extern DigitalOut myled3; // for tests... |
mbedalvaro | 0:df6fdd9b99f0 | 9 | |
mbedalvaro | 0:df6fdd9b99f0 | 10 | //#define debugDelayMirrors // this is to check visually the mirror delay (but it is also beautiful) |
mbedalvaro | 0:df6fdd9b99f0 | 11 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 13 | // are many blobs, see "DEFAULT_OVERLAP_POINTS" (but will slow down...) |
mbedalvaro | 0:df6fdd9b99f0 | 14 | |
mbedalvaro | 0:df6fdd9b99f0 | 15 | #define RENDER_INTERVAL 0.00011 // good value in previous version (monaco) was 0.00011 // in seconds (Ticker) |
mbedalvaro | 0:df6fdd9b99f0 | 16 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 20 | // WHEN THERE IS MORE THAN ONE SPOT: |
mbedalvaro | 0:df6fdd9b99f0 | 21 | #define WAIT_FIRST 12 // special waiting time for mirror positioning to first point on next blob BEFORE re-activating laser |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 23 | #define WAIT_LAST 0 // special waiting time for last point |
mbedalvaro | 0:df6fdd9b99f0 | 24 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 26 | #define DEFAULT_OVERLAP_POINTS 5 // 10 |
mbedalvaro | 0:df6fdd9b99f0 | 27 | |
mbedalvaro | 0:df6fdd9b99f0 | 28 | enum lsdStateType {NORMAL_POINT, LAST_POINT, MOVE_NEXT_BLOB, START_POINT}; |
mbedalvaro | 0:df6fdd9b99f0 | 29 | |
mbedalvaro | 0:df6fdd9b99f0 | 30 | class simpleLaserSensingRenderer { |
mbedalvaro | 0:df6fdd9b99f0 | 31 | public: |
mbedalvaro | 0:df6fdd9b99f0 | 32 | |
mbedalvaro | 0:df6fdd9b99f0 | 33 | void setConfigToRender(blobConfig*); |
mbedalvaro | 0:df6fdd9b99f0 | 34 | //void startRenderer(); // pb: I cannot use the ticker function inside the class! |
mbedalvaro | 0:df6fdd9b99f0 | 35 | void laserRenderThread(); |
mbedalvaro | 0:df6fdd9b99f0 | 36 | void laserRenderThreadONEBLOBONLY(); |
mbedalvaro | 0:df6fdd9b99f0 | 37 | // void laserRender(blobConfig*); |
mbedalvaro | 0:df6fdd9b99f0 | 38 | |
mbedalvaro | 0:df6fdd9b99f0 | 39 | blobConfig* ptBlobCfToRender; |
mbedalvaro | 0:df6fdd9b99f0 | 40 | |
mbedalvaro | 0:df6fdd9b99f0 | 41 | lsdStateType stateLsd; |
mbedalvaro | 0:df6fdd9b99f0 | 42 | int totalBlobs; |
mbedalvaro | 0:df6fdd9b99f0 | 43 | int currentBlob; |
mbedalvaro | 0:df6fdd9b99f0 | 44 | int currentPoint; |
mbedalvaro | 0:df6fdd9b99f0 | 45 | int currentMirrorDelay; |
mbedalvaro | 0:df6fdd9b99f0 | 46 | int currentTotalPoints; |
mbedalvaro | 0:df6fdd9b99f0 | 47 | int currentColor; |
mbedalvaro | 0:df6fdd9b99f0 | 48 | unsigned short x,y; // auxiliary variables storing mirror position(0-4096) |
mbedalvaro | 0:df6fdd9b99f0 | 49 | |
mbedalvaro | 0:df6fdd9b99f0 | 50 | // New method to check complete display of one loop: |
mbedalvaro | 0:df6fdd9b99f0 | 51 | unsigned char configTotalPoints; |
mbedalvaro | 0:df6fdd9b99f0 | 52 | unsigned char pointDisplayCounter; |
mbedalvaro | 0:df6fdd9b99f0 | 53 | unsigned char numOverlapPoints; |
mbedalvaro | 0:df6fdd9b99f0 | 54 | |
mbedalvaro | 0:df6fdd9b99f0 | 55 | void startFullDisplay(); |
mbedalvaro | 0:df6fdd9b99f0 | 56 | bool endedFullDisplay(); |
mbedalvaro | 0:df6fdd9b99f0 | 57 | bool endedFractionDisplay(int fract); |
mbedalvaro | 0:df6fdd9b99f0 | 58 | |
mbedalvaro | 0:df6fdd9b99f0 | 59 | int waitNormal, waitLaser, waitFirst, waitFirstLaser, waitLast; |
mbedalvaro | 0:df6fdd9b99f0 | 60 | }; |
mbedalvaro | 0:df6fdd9b99f0 | 61 | |
mbedalvaro | 0:df6fdd9b99f0 | 62 | #endif |
mbedalvaro | 0:df6fdd9b99f0 | 63 | |
mbedalvaro | 0:df6fdd9b99f0 | 64 | |
mbedalvaro | 0:df6fdd9b99f0 | 65 |