サイコン用プログラム BLE通信送信確認
Dependencies: mbed BLE_API nRF51822
Revision 14:700c99bb766c, committed 2015-05-19
- Comitter:
- mbed_tw_hoehoe
- Date:
- Tue May 19 11:35:13 2015 +0000
- Parent:
- 13:7b4edf8b8c1b
- Child:
- 15:f0306f9dc7ad
- Commit message:
- change axis6 values.
Changed in this revision
MPU6050_Mod.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MPU6050_Mod.lib Thu Apr 09 11:39:10 2015 +0000 +++ b/MPU6050_Mod.lib Tue May 19 11:35:13 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/mbed_tw_hoehoe/code/MPU6050_Mod/#8ed0265c2c92 +http://developer.mbed.org/users/mbed_tw_hoehoe/code/MPU6050_Mod/#01634c0bcfd9
--- a/main.cpp Thu Apr 09 11:39:10 2015 +0000 +++ b/main.cpp Tue May 19 11:35:13 2015 +0000 @@ -60,18 +60,18 @@ 0xC6, 0xDD, 0xB5, 0xAE, 0x7F, 0xA5 }; -uint8_t accelPayload[sizeof(float)*9] = {0,}; +uint8_t accelPayload[sizeof(float)*10] = {0,}; uint8_t defaultWriteValue = 2; uint8_t writePayload[3] = {0, defaultWriteValue, defaultWriteValue,}; GattCharacteristic accelChar (MPU6050_Accel_Characteristic_uuid, - accelPayload, (sizeof(float) * 9), (sizeof(float) * 9), + accelPayload, (sizeof(float) * 10), (sizeof(float) * 10), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ); GattCharacteristic writeChar (MPU6050_Write_Characteristic_uuid, - writePayload, 3, 3, + writePayload, 2, 2, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE); GattCharacteristic *ControllerChars[] = { &accelChar, &writeChar, }; @@ -83,22 +83,30 @@ float acData[3]; float gyData[3]; float tempData = 0.0f; - float t = 0.0f; - float interval = 0.0f; + float at = 0.0f; + float gt = 0.0f; + float tickerInterval = 0.0f; Timer timer; timer.start(); //加速度を取得 mpu.getAccelero(acData); - + timer.stop(); + at = timer.read_ms(); + timer.reset(); + memcpy(accelPayload+sizeof(float)*0, &acData[0], sizeof(acData[0])); memcpy(accelPayload+sizeof(float)*1, &acData[1], sizeof(acData[1])); memcpy(accelPayload+sizeof(float)*2, &acData[2], sizeof(acData[2])); //ジャイロを取得 + timer.start(); mpu.getGyro(gyData); - + timer.stop(); + gt = timer.read_ms(); + timer.reset(); + memcpy(accelPayload+sizeof(float)*3, &gyData[0], sizeof(gyData[0])); memcpy(accelPayload+sizeof(float)*4, &gyData[1], sizeof(gyData[1])); memcpy(accelPayload+sizeof(float)*5, &gyData[2], sizeof(gyData[2])); @@ -120,14 +128,11 @@ pc.printf("Temp: %.3lf\r\n", *(float*)&accelPayload[sizeof(float)*6]); */ + memcpy(accelPayload+sizeof(float)*7, &at, sizeof(at)); + memcpy(accelPayload+sizeof(float)*8, >, sizeof(gt)); - timer.stop(); - t = timer.read_ms(); - memcpy(accelPayload+sizeof(float)*7, &t, sizeof(t)); - timer.reset(); - - interval = (float)Gap::MSEC_TO_GAP_DURATION_UNITS(CONN_INTERVAL); - memcpy(accelPayload+sizeof(float)*8, &interval, sizeof(interval)); + tickerInterval = 0.02f;//(float)Gap::MSEC_TO_GAP_DURATION_UNITS(CONN_INTERVAL); + memcpy(accelPayload+sizeof(float)*9, &tickerInterval, sizeof(tickerInterval)); ble.updateCharacteristicValue(accelChar.getValueAttribute().getHandle(), accelPayload, sizeof(accelPayload)); //Mod ble.updateCharacteristicValue(writeChar.getValueAttribute().getHandle(), writePayload, sizeof(writePayload)); //Mod