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
Diff: soundSpot.cpp
- Revision:
- 0:345b3bc7a0ea
- Child:
- 4:f9d364f10335
diff -r 000000000000 -r 345b3bc7a0ea soundSpot.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/soundSpot.cpp Wed Mar 28 14:40:01 2012 +0000
@@ -0,0 +1,86 @@
+#include "soundSpot.h"
+
+// Constructor:
+soundSpot::soundSpot() { // by default, the child constructor call the parameterless default constructor (we could force another by doing: soundSpot::soundSpot : LivingSpot (params...) { ..}
+
+// DEFAULT sending mode will be all off:
+stopAllSending();
+resetAllSendingModes();
+
+initCommonVariables();
+}
+
+// IMPORTANT: the destructor of the base class is virtual, but it won't be implemented with the same name in the child class; therefore, it
+// must be implemented in the base class (and it will be called when using delete of the child, first the delete child, then delete base)
+soundSpot::~soundSpot() {
+}
+
+void soundSpot::setColor(char c) {
+ blobColor=0x07&c; // we will use the first three bits to set the RGB colors.
+}
+
+void soundSpot::initCommonVariables() {
+ firstTimeNoTouch=true;
+ // randomForce.set(1,0);// first time there won't be any force, or random force
+ // randomForce=randomForce.getRotatedDeg(1.0*(rand()%360));
+ // randomForce.normalize();
+
+ noTouchedCounter=0;
+ wallCounter=0;
+ blobWallCollision=false;
+ //slidingDirection=true; // (will change when touching wall)
+
+ render=true;
+ standByMode=false;
+}
+
+ void soundSpot::resetAllSendingModes() {
+ // RESET SENDING DATA:
+ // (a) anchor mass data:
+ sendingAnchorPosition=false;
+ sendingAnchorForce=false; // this is the total force on the anchor mass, not just the recentering force
+ sendingAnchorTouchWall=false;
+ // (b) data from blob points:
+ sendingLoopPositions=true;
+ sendingLoopForces=false;// this is not just the forces from light, but all the forces in each particle
+ sendingLoopForcesLight=false;// forces only from light
+ sendingLoopRegions=false; // from this we can detect "hits"
+ sendingLoopTouchWall=false;
+ // (c) Blob geometry:
+ sendingBlobArea=false;
+ sendingBlobNormals=false;
+ sendingBlobAngles=false; // redundant with sendingBlobNormals, but simplified (only angle of normal)
+ // (d) Light sensing statistics:
+ sendingBlobMaxMin=false;
+ sendingLightForce=false; // the total light force
+ sendingTouched=false;
+ // (e) Recentering vector: (note: redundant with sendingLightForce, IF the correction angle is known).
+ sendingRecenteringVector=false;
+ sendingRecenteringAngle=false;
+ sendingRecenteringNorm=false;
+ }
+
+ void soundSpot::stopAllSending() {
+ // STOP HARDWARE SENDING MODE (per spot):
+ sendSerial=false;
+ sendOSC=true;
+ }
+
+ void soundSpot::sendData(void) { // send data common to all kind of blobs
+ // send common things:
+ // .. TO DO
+
+ // Send data specific to the derived class:
+ sendDataSpecific(); // this will depend on the kind of blob
+}
+
+
+
+// this should be called AFTER the number of points on the lsdTrajectory has been fixed.
+void soundSpot::setDelayMirrors(int delay) {
+ delayMirrorSamples=bluePrint.scafold.size()-delay;
+}
+
+
+
+
