Simple step tracking

Dependencies:   MPU9250 mbed-os

Fork of ST by alonso palomino

Revision:
5:2fbd60a970d6
Parent:
4:b741278722c1
Child:
7:eff79b4c37ab
--- a/ButtonService.h	Thu Oct 19 21:11:05 2017 +0000
+++ b/ButtonService.h	Thu Oct 19 21:43:19 2017 +0000
@@ -38,7 +38,7 @@
         //4 * 6 = 24
         //convert to 4 bytes
         //union all        
-        uint8_t sensorValues[24] = {0};
+        //uint8_t sensorValues[24] = {0};
         //float rollTest = 94.2425f;
         //uint16_t rollValue = (uint16_t)roll;
         //uint16_t pitchValue = (uint16_t)pitch;
@@ -70,28 +70,43 @@
         uint8_t *rollValue;
         rollValue = reinterpret_cast<uint8_t*>(&roll);
         
-        uint8_t *rollValue;
-        rollValue = reinterpret_cast<uint8_t*>(&roll);
+        uint8_t *pitchValue;
+        pitchValue = reinterpret_cast<uint8_t*>(&pitch);
+        
+        uint8_t *yawValue;
+        yawValue = reinterpret_cast<uint8_t*>(&yaw);
         
-        uint8_t *rollValue;
-        rollValue = reinterpret_cast<uint8_t*>(&roll);
+        uint8_t *gxValue;
+        gxValue = reinterpret_cast<uint8_t*>(&gx);
+        
+        uint8_t *gyValue;
+        gyValue = reinterpret_cast<uint8_t*>(&gy);
+        
+        uint8_t *gzValue;
+        gzValue = reinterpret_cast<uint8_t*>(&gz);
         
-        uint8_t *rollValue;
-        rollValue = reinterpret_cast<uint8_t*>(&roll);
+        //sensorValues = 
+        int * result = new int[24];
+        copy(rollValue, rollValue + 4, result);
+        copy(pitchValue, pitchValue + 4, result + 4);
+        copy(yawValue, yawValue + 4, result + 8);
         
-        uint8_t *rollValue;
-        rollValue = reinterpret_cast<uint8_t*>(&roll);
+        copy(gxValue, gxValue + 4, result + 12);
+        copy(gyValue, gyValue + 4, result + 16);
+        copy(gzValue, gzValue + 4, result + 20);
         
-        uint8_t *rollValue;
-        rollValue = reinterpret_cast<uint8_t*>(&roll);
-
-        ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)array, sizeof(array));
+        for(int i = 0; i < result.length; i++){
+            
+        }
+        //union all arrays
+        
+        ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)rollValue, sizeof(rollValue));
         //ble.updateCharacteristicValue(buttonState.getValueHandle(), (uint8_t *)v ,sizeof(v));
     }
 
 private:
     BLE                              &ble;
-    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[4])>  buttonState;
+    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[8])>  buttonState;
 };
 
 #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */