Simple step tracking

Dependencies:   MPU9250 mbed-os

Fork of ST by alonso palomino

Revision:
9:e265a634306d
Parent:
8:1bac78ab3acc
Child:
10:f5cd99dd9efa
diff -r 1bac78ab3acc -r e265a634306d ButtonService.h
--- a/ButtonService.h	Fri Oct 20 16:53:30 2017 +0000
+++ b/ButtonService.h	Fri Oct 20 18:28:34 2017 +0000
@@ -34,7 +34,7 @@
         ble.gattServer().addService(buttonService);
     }
 
-    void updateButtonState(float roll, float pitch, float yaw, float gx, float gy, float gz) {      
+    void updateButtonState(float roll, float pitch, float yaw, int16_t gx, int16_t gy, int16_t gz) {      
         uint8_t *rollValue;
         rollValue = reinterpret_cast<uint8_t*>(&roll);
         
@@ -53,26 +53,22 @@
         uint8_t *gzValue;
         gzValue = reinterpret_cast<uint8_t*>(&gz);
         
-        //sensorValues = 
-        uint8_t * result = new uint8_t[24];
+        uint8_t result[20];
+        
         copy(rollValue, rollValue + 4, result);
         copy(pitchValue, pitchValue + 4, result + 4);
         copy(yawValue, yawValue + 4, result + 8);
         
-        copy(gxValue, gxValue + 4, result + 12);
-        copy(gyValue, gyValue + 4, result + 16);
-        copy(gzValue, gzValue + 4, result + 20);
-        
-        
-        //union all arrays
-        
+        copy(gxValue, gxValue + 2, result + 12);
+        copy(gyValue, gyValue + 2, result + 14);
+        copy(gzValue, gzValue + 2, result + 16);
+                
         ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)result, sizeof(result));
-        //ble.updateCharacteristicValue(buttonState.getValueHandle(), (uint8_t *)v ,sizeof(v));
     }
 
 private:
     BLE                              &ble;
-    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[24])>  buttonState;
+    ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[20])>  buttonState;
 };
 
 #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */