Alvaro Cassinelli / Mbed 2 deprecated skinGames_forktest

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Revision:
18:d72935b13858
Parent:
12:0de9cd2bced5
Child:
19:228430f1350e
--- a/soundSpot.cpp	Sat Apr 28 09:33:49 2012 +0000
+++ b/soundSpot.cpp	Sat Apr 28 12:35:21 2012 +0000
@@ -8,6 +8,11 @@
 resetAllSendingModes();
 
 initCommonVariables();
+
+// initialize timer for sending OSC data:
+periodSendingData=25;// by default, we send the data every 25 ms. Note: the "data" to send will of course depend on the kind of blob. That will be therefore re-set when 
+// instantiating the kind of blob. 
+measureSendPeriod.start();
 }
 
 // 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 
@@ -36,12 +41,13 @@
 
  void soundSpot::resetAllSendingModes() {
   // RESET SENDING DATA:
+  sendingOnlyWhenTouch=false;
  // (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;
+  sendingLoopPositions=false;
   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"
@@ -67,10 +73,18 @@
  }
   
  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
+    // send common things, such as testing if it is the right time to send data:
+   
+    if (measureSendPeriod.read_ms()>periodSendingData) {
+            measureSendPeriod.stop();
+            measureSendPeriod.reset();
+
+          // Send data specific to the derived class:
+           if ((sendingOnlyWhenTouch==false)||(blobWallCollision==true)||(displaySensingBuffer.lightTouched==true))
+            sendDataSpecific(); // this will depend on the kind of blob
+        
+            measureSendPeriod.start();
+        }
+   
 }