Temp Fork

Dependencies:   MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed

Fork of CubicHand by Model-Based Team

Files at this revision

API Documentation at this revision

Comitter:
kalbers
Date:
Thu Dec 11 04:17:46 2014 +0000
Parent:
22:0cc5b7e55419
Child:
25:7a866b3d79bb
Child:
28:42ae7eed0b68
Commit message:
Added interface to get Glove Values and check for new values.

Changed in this revision

DataGlove.cpp Show annotated file Show diff for this revision Revisions of this file
DataGlove.h Show annotated file Show diff for this revision Revisions of this file
--- a/DataGlove.cpp	Thu Dec 11 04:07:54 2014 +0000
+++ b/DataGlove.cpp	Thu Dec 11 04:17:46 2014 +0000
@@ -14,6 +14,7 @@
 	corrected = new Glove;
 	ReceiveCount = 0;
     numReceived = 0;
+    NewData = false;
     //Initialize correction values to 0
     correction->roll = 0.0;
     correction->pitch = 0.0;
@@ -123,6 +124,7 @@
                     }
                     break;
                 }
+                NewData = true;
                 Buf[0] = 0; //Clear Token so no repeats.
                 notConnectedCount = 0;
                 numReceived = 0;
@@ -311,4 +313,20 @@
     gl->pitch = 0.0;
     gl->yaw = 0.0;
     gl->lastPkgTime = timeOfArrival;
+}
+
+Glove DataGlove::GetCurrentValues()
+{
+	return *gl;
+}
+bool DataGlove::CheckForNewValues()
+{
+	if(NewData == true)
+	{
+		NewData = false;
+		return true;
+	}else
+	{
+		return false;
+	}
 }
\ No newline at end of file
--- a/DataGlove.h	Thu Dec 11 04:07:54 2014 +0000
+++ b/DataGlove.h	Thu Dec 11 04:17:46 2014 +0000
@@ -20,6 +20,12 @@
 		~DataGlove();
 		void Init();
 		void Receive();
+		
+		//Returns the latest glove values in a structure.
+		Glove GetCurrentValues();
+		//Returns true if new data since last function call, false otherwise. 
+		bool CheckForNewValues();
+		
         int16_t finger1, finger2, finger3, finger4, finger5;
         int16_t accelx, accely, accelz;
         int16_t gyrox, gyroy, gyroz;
@@ -39,6 +45,7 @@
 	    int q0, q1, q2, q3;
 	    double q00, q11, q22, q33;
 	    long ReceiveCount;
+	    bool NewData;
 	    // Stores glove data
 		Glove *gl;
 		// Stores the correction matrix