Cubic Hand project for EECS 249A course.

Dependencies:   MMA8451Q TSI cc3000_hostdriver_mbedsocket NVIC_set_all_priorities mbed Multi_WS2811

Committer:
kalbers
Date:
Thu Dec 11 05:25:03 2014 +0000
Revision:
26:42ae7eed0b68
Parent:
23:a8de4f87cada
Child:
32:bf5f545621aa
Child:
36:4a58639da6cf
Added Dataglove Receive Blocking that returns a glove structure.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kalbers 3:5f5d75cba8e1 1 #include "GloveWifi.h"
kalbers 3:5f5d75cba8e1 2
kalbers 13:c701f1122797 3 #pragma once
kalbers 13:c701f1122797 4
naren 14:0c4a26dc6873 5 struct Glove {
naren 14:0c4a26dc6873 6 double roll;
naren 14:0c4a26dc6873 7 double pitch;
naren 14:0c4a26dc6873 8 double yaw;
naren 14:0c4a26dc6873 9 double fingers[5];
naren 14:0c4a26dc6873 10 double gyro[3];
naren 14:0c4a26dc6873 11 double magn[3];
naren 14:0c4a26dc6873 12 double accel[3];
naren 14:0c4a26dc6873 13 int lastPkgTime;
naren 14:0c4a26dc6873 14 };
naren 14:0c4a26dc6873 15
kalbers 3:5f5d75cba8e1 16 class DataGlove
kalbers 3:5f5d75cba8e1 17 {
kalbers 3:5f5d75cba8e1 18 public:
kalbers 3:5f5d75cba8e1 19 DataGlove();
kalbers 3:5f5d75cba8e1 20 ~DataGlove();
kalbers 3:5f5d75cba8e1 21 void Init();
kalbers 26:42ae7eed0b68 22 bool Receive();
kalbers 26:42ae7eed0b68 23 Glove ReceiveBlocking();
kalbers 23:a8de4f87cada 24
kalbers 23:a8de4f87cada 25 //Returns the latest glove values in a structure.
kalbers 23:a8de4f87cada 26 Glove GetCurrentValues();
kalbers 23:a8de4f87cada 27 //Returns true if new data since last function call, false otherwise.
kalbers 23:a8de4f87cada 28 bool CheckForNewValues();
kalbers 23:a8de4f87cada 29
kalbers 3:5f5d75cba8e1 30 int16_t finger1, finger2, finger3, finger4, finger5;
kalbers 3:5f5d75cba8e1 31 int16_t accelx, accely, accelz;
kalbers 3:5f5d75cba8e1 32 int16_t gyrox, gyroy, gyroz;
kalbers 3:5f5d75cba8e1 33
kalbers 3:5f5d75cba8e1 34 private:
kalbers 3:5f5d75cba8e1 35 uint8_t SendBuf[20];
kalbers 3:5f5d75cba8e1 36 int16_t notConnectedCount;
kalbers 19:e751d075e2e6 37 long numReceived;
kalbers 19:e751d075e2e6 38 char Buf[256], buffer[256];
kalbers 15:b48ac00af0b8 39 bool raw;
kalbers 15:b48ac00af0b8 40 unsigned char bcc;
kalbers 15:b48ac00af0b8 41 int pkglen, u;
kalbers 15:b48ac00af0b8 42 int timeOfArrival, id, pkgtype;
kalbers 15:b48ac00af0b8 43 int j, k, y;
kalbers 15:b48ac00af0b8 44 double roll, yaw, pitch;
kalbers 15:b48ac00af0b8 45 double norm, test;
kalbers 15:b48ac00af0b8 46 int q0, q1, q2, q3;
kalbers 15:b48ac00af0b8 47 double q00, q11, q22, q33;
kalbers 18:6737bf53ccd1 48 long ReceiveCount;
kalbers 23:a8de4f87cada 49 bool NewData;
naren 22:0cc5b7e55419 50 // Stores glove data
naren 14:0c4a26dc6873 51 Glove *gl;
naren 22:0cc5b7e55419 52 // Stores the correction matrix
naren 22:0cc5b7e55419 53 Glove *correction;
naren 22:0cc5b7e55419 54 // Stores the corrected glove values
naren 22:0cc5b7e55419 55 Glove *corrected;
kalbers 3:5f5d75cba8e1 56 GloveWifi GloveSocket;
kalbers 18:6737bf53ccd1 57
kalbers 18:6737bf53ccd1 58 private:
kalbers 18:6737bf53ccd1 59 void Parse();
kalbers 18:6737bf53ccd1 60 void StreamData(uint8_t DataType);
kalbers 19:e751d075e2e6 61 void StopSampling();
kalbers 18:6737bf53ccd1 62 void ExtractFingersQuat();
kalbers 18:6737bf53ccd1 63 void ExtractQuat();
kalbers 18:6737bf53ccd1 64 void ExtractFingersRaw();
kalbers 18:6737bf53ccd1 65 void ExtractRaw();
kalbers 18:6737bf53ccd1 66 void ExtractFingers();
kalbers 3:5f5d75cba8e1 67 };