Temp Fork
Dependencies: MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed
Fork of CubicHand by
Revision 28:42ae7eed0b68, committed 2014-12-11
- Comitter:
- kalbers
- Date:
- Thu Dec 11 05:25:03 2014 +0000
- Parent:
- 23:a8de4f87cada
- Child:
- 29:50be685a3f54
- Commit message:
- Added Dataglove Receive Blocking that returns a glove structure.
Changed in this revision
--- a/DataGlove.cpp Thu Dec 11 04:17:46 2014 +0000
+++ b/DataGlove.cpp Thu Dec 11 05:25:03 2014 +0000
@@ -58,7 +58,14 @@
GloveSocket.SendDataToGlove(SendBuf, 6);
}
-void DataGlove::Receive()
+
+Glove DataGlove::ReceiveBlocking()
+{
+ while(Receive() == false);
+ return *gl;
+}
+
+bool DataGlove::Receive()
{
raw = false;
numReceived += GloveSocket.GetDataFromBuffer(Buf, 1);
@@ -76,7 +83,7 @@
if ((numReceived - 3 )< pkglen)
{
if(numReceived == 0) notConnectedCount++;
- return;
+ return false;
}
for (u = 3; u <= pkglen; u++)
{
@@ -91,7 +98,8 @@
timeOfArrival = (Buf[6] << 24) + (Buf[7] << 16) + (Buf[8] << 8) + Buf[9];
id = (Buf[4] << 8) + Buf[5];
pkgtype = Buf[3];
- if(ReceiveCount > 501 && ReceiveCount++%25 == 0) {//printf("%d %c\r\n", ReceiveCount, Buf[0]);
+ ReceiveCount++;
+ if(ReceiveCount > 501 && ReceiveCount%25 == 0) {//printf("%d %c\r\n", ReceiveCount, Buf[0]);
printf("%f %f %f %f %f %f %f %f\r\n", corrected->roll, corrected->pitch, corrected->yaw,
corrected->fingers[0], corrected->fingers[1], corrected->fingers[2],
corrected->fingers[3], corrected->fingers[4]);
@@ -128,6 +136,7 @@
Buf[0] = 0; //Clear Token so no repeats.
notConnectedCount = 0;
numReceived = 0;
+ return true;
}
else
{
@@ -136,7 +145,7 @@
}
}
// Normalize the data for the first 1000 samples
- if (ReceiveCount < 500) {
+ /*if (ReceiveCount < 500) {
correction->roll = (correction->roll*ReceiveCount + gl->roll)/(ReceiveCount+1);
correction->pitch = (correction->pitch*ReceiveCount + gl->pitch)/(ReceiveCount+1);
correction->yaw = (correction->yaw*ReceiveCount + gl->yaw)/(ReceiveCount+1);
@@ -149,7 +158,7 @@
corrected->yaw = gl->yaw - correction->yaw;
for (int iter = 0; iter < 5; iter++)
corrected->fingers[iter] = gl->fingers[iter] - correction->fingers[iter];
- }
+ }*/
}
else {
//printf("couldn't get data %d\r\n", notConnectedCount);
@@ -163,7 +172,7 @@
numReceived = 0;
notConnectedCount++;
}
-
+ return false;
}
void DataGlove::ExtractFingersQuat()
@@ -319,6 +328,7 @@
{
return *gl;
}
+
bool DataGlove::CheckForNewValues()
{
if(NewData == true)
--- a/DataGlove.h Thu Dec 11 04:17:46 2014 +0000 +++ b/DataGlove.h Thu Dec 11 05:25:03 2014 +0000 @@ -19,7 +19,8 @@ DataGlove(); ~DataGlove(); void Init(); - void Receive(); + bool Receive(); + Glove ReceiveBlocking(); //Returns the latest glove values in a structure. Glove GetCurrentValues();
--- a/GloveWifi.cpp Thu Dec 11 04:17:46 2014 +0000
+++ b/GloveWifi.cpp Thu Dec 11 05:25:03 2014 +0000
@@ -99,9 +99,8 @@
{
DropCount = 0;
}
- if(DropCount > 200)
+ if(DropCount > 20)
{
- printf("!\r\n");
Reconnect();
DropCount = 0;
}
