Simple step tracking

Dependencies:   MPU9250 mbed-os

Fork of ST by alonso palomino

Revision:
8:1bac78ab3acc
Parent:
7:eff79b4c37ab
Child:
9:e265a634306d
diff -r eff79b4c37ab -r 1bac78ab3acc ButtonService.h
--- a/ButtonService.h	Thu Oct 19 22:02:24 2017 +0000
+++ b/ButtonService.h	Fri Oct 20 16:53:30 2017 +0000
@@ -34,39 +34,7 @@
         ble.gattServer().addService(buttonService);
     }
 
-    void updateButtonState(float roll, float pitch, float yaw, float gx, float gy, float gz) {
-        //4 * 6 = 24
-        //convert to 4 bytes
-        //union all        
-        //uint8_t sensorValues[24] = {0};
-        //float rollTest = 94.2425f;
-        //uint16_t rollValue = (uint16_t)roll;
-        //uint16_t pitchValue = (uint16_t)pitch;
-        //uint16_t yawValue = (uint16_t)yaw;
-
-        //uint16_t gxValue = (uint16_t)gx;
-        //uint16_t gyValue = (uint16_t)gy;
-        //uint16_t gzValue = (uint16_t)gz;
-        
-        //sensorValues[0]= rollValue & 0xff;
-        //sensorValues[1]= (rollValue >> 8);
-
-        //sensorValues[2]= pitchValue & 0xff;
-        //sensorValues[3]= (pitchValue >> 8);
-
-        //sensorValues[4]= yawValue & 0xff;
-        //sensorValues[5]= (yawValue >> 8);
-
-        //sensorValues[6]= gxValue & 0xff;
-        //sensorValues[7]= (gxValue >> 8);
-
-        //sensorValues[8]= gyValue & 0xff;
-        //sensorValues[9]= (gyValue >> 8);
-
-        //sensorValues[10]= gzValue & 0xff;
-        //sensorValues[11]= (gzValue >> 8);
-        
-        //converted:00 00 00 00 00 00 02 00 00 00 00 00
+    void updateButtonState(float roll, float pitch, float yaw, float gx, float gy, float gz) {      
         uint8_t *rollValue;
         rollValue = reinterpret_cast<uint8_t*>(&roll);
         
@@ -86,14 +54,14 @@
         gzValue = reinterpret_cast<uint8_t*>(&gz);
         
         //sensorValues = 
-        int * result = new int[16];
+        uint8_t * result = new uint8_t[24];
         copy(rollValue, rollValue + 4, result);
         copy(pitchValue, pitchValue + 4, result + 4);
-        //copy(yawValue, yawValue + 4, result + 8);
+        copy(yawValue, yawValue + 4, result + 8);
         
-        //copy(gxValue, gxValue + 4, result + 12);
-        //copy(gyValue, gyValue + 4, result + 16);
-        //copy(gzValue, gzValue + 4, result + 20);
+        copy(gxValue, gxValue + 4, result + 12);
+        copy(gyValue, gyValue + 4, result + 16);
+        copy(gzValue, gzValue + 4, result + 20);
         
         
         //union all arrays
@@ -104,7 +72,7 @@
 
 private:
     BLE                              &ble;
-    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[16])>  buttonState;
+    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[24])>  buttonState;
 };
 
 #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */