Edson Alcala
/
StepTracking
Simple step tracking
Fork of ST by
Diff: ButtonService.h
- Revision:
- 4:b741278722c1
- Parent:
- 3:3157e61f2bfd
- Child:
- 5:2fbd60a970d6
diff -r 3157e61f2bfd -r b741278722c1 ButtonService.h --- a/ButtonService.h Tue Oct 17 20:55:04 2017 +0000 +++ b/ButtonService.h Thu Oct 19 21:11:05 2017 +0000 @@ -35,40 +35,63 @@ } void updateButtonState(float roll, float pitch, float yaw, float gx, float gy, float gz) { - uint8_t sensorValues[12] = {0}; - - uint16_t rollValue = (uint16_t)roll; - uint16_t pitchValue = (uint16_t)pitch; - uint16_t yawValue = (uint16_t)yaw; + //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); + //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[2]= pitchValue & 0xff; - sensorValues[3]= (pitchValue >> 8); - - sensorValues[4]= yawValue & 0xff; - sensorValues[5]= (yawValue >> 8); + //sensorValues[8]= gyValue & 0xff; + //sensorValues[9]= (gyValue >> 8); - sensorValues[6]= gxValue & 0xff; - sensorValues[7]= (gxValue >> 8); + //sensorValues[10]= gzValue & 0xff; + //sensorValues[11]= (gzValue >> 8); + + //converted:00 00 00 00 00 00 02 00 00 00 00 00 + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); + + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); + + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); + + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); + + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); + + uint8_t *rollValue; + rollValue = reinterpret_cast<uint8_t*>(&roll); - sensorValues[8]= gyValue & 0xff; - sensorValues[9]= (gyValue >> 8); - - sensorValues[10]= gzValue & 0xff; - sensorValues[11]= (gzValue >> 8); - - ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)sensorValues, sizeof(sensorValues)); + ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)array, sizeof(array)); //ble.updateCharacteristicValue(buttonState.getValueHandle(), (uint8_t *)v ,sizeof(v)); } private: BLE &ble; - ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[12])> buttonState; + ReadOnlyArrayGattCharacteristic<uint8_t, sizeof(uint8_t[4])> buttonState; }; #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */