MPU6050センサ Wallbot_BLE用 サンプル
Dependencies: BLE_API mbed nRF51822
Diff: main.cpp
- Revision:
- 19:234f3afad29d
- Parent:
- 18:7ef0e3b768c2
- Child:
- 20:9ff36d021c34
--- a/main.cpp Wed May 27 13:57:42 2015 +0000 +++ b/main.cpp Sun May 31 05:29:47 2015 +0000 @@ -17,7 +17,7 @@ //#define MIN_CONN_INTERVAL 250 /**< Minimum connection interval */ //#define MAX_CONN_INTERVAL 350 /**< Maximum connection interval */ -#define CONN_INTERVAL 250 /**< connection interval 250ms; in multiples of 0.125ms. (durationInMillis * 1000) / UNIT_0_625_MS; */ +#define CONN_INTERVAL 25 /**< connection interval 250ms; in multiples of 0.125ms. (durationInMillis * 1000) / UNIT_0_625_MS; */ #define CONN_SUP_TIMEOUT 8000 /**< Connection supervisory timeout (6 seconds); in multiples of 0.125ms. */ #define SLAVE_LATENCY 0 @@ -38,21 +38,21 @@ //}; const uint8_t MPU6050_service_uuid[] = { - 0x79,0x0B,0x56,0x80,0x62,0xC3,0x58,0x90,0xC4,0x42,0xCC,0x39,0x76,0x5E,0xC1,0x64 + 0x45,0x35,0x56,0x80,0x0F,0xD8,0x5F,0xB5,0x51,0x48,0x30,0x27,0x06,0x9B,0x3F,0xD9 }; const uint8_t MPU6050_Accel_Characteristic_uuid[] = { - 0x79,0x0B,0x56,0x81,0x62,0xC3,0x58,0x90,0xC4,0x42,0xCC,0x39,0x76,0x5E,0xC1,0x64 + 0x45,0x35,0x56,0x81,0x0F,0xD8,0x5F,0xB5,0x51,0x48,0x30,0x27,0x06,0x9B,0x3F,0xD9 }; const uint8_t MPU6050_Write_Characteristic_uuid[] = { - 0x79,0x0B,0x56,0x83,0x62,0xC3,0x58,0x90,0xC4,0x42,0xCC,0x39,0x76,0x5E,0xC1,0x64 + 0x45,0x35,0x56,0x83,0x0F,0xD8,0x5F,0xB5,0x51,0x48,0x30,0x27,0x06,0x9B,0x3F,0xD9 }; uint8_t accelPayload[sizeof(float)*10] = {0,}; -uint8_t defaultWriteValue = 2; +uint8_t defaultWriteValue = 3; uint8_t writePayload[2] = {defaultWriteValue, defaultWriteValue,}; @@ -179,16 +179,16 @@ //pc.printf("write: %u, %u, %u\r\n", controller[0],controller[1],controller[2]); switch(controller[0]){ - case 0: + case 1: acceleroRange = MPU6050_ACCELERO_RANGE_2G; break; - case 1: + case 2: acceleroRange = MPU6050_ACCELERO_RANGE_4G; break; - case 2: + case 3: acceleroRange = MPU6050_ACCELERO_RANGE_8G; break; - case 3: + case 4: acceleroRange = MPU6050_ACCELERO_RANGE_16G; break; @@ -197,16 +197,16 @@ } switch(controller[1]){ - case 0: + case 1: gyroRange = MPU6050_GYRO_RANGE_250; break; - case 1: + case 2: gyroRange = MPU6050_GYRO_RANGE_500; break; - case 2: + case 3: gyroRange = MPU6050_GYRO_RANGE_1000; break; - case 3: + case 4: gyroRange = MPU6050_GYRO_RANGE_2000; break; default: @@ -248,20 +248,20 @@ // pc.printf("Start\n\r"); //#endif /* - #define MPU6050_ACCELERO_RANGE_2G 0 - #define MPU6050_ACCELERO_RANGE_4G 1 - #define MPU6050_ACCELERO_RANGE_8G 2 - #define MPU6050_ACCELERO_RANGE_16G 3 + #define MPU6050_ACCELERO_RANGE_2G 1 + #define MPU6050_ACCELERO_RANGE_4G 2 + #define MPU6050_ACCELERO_RANGE_8G 3 + #define MPU6050_ACCELERO_RANGE_16G 4 - #define MPU6050_GYRO_RANGE_250 0 - #define MPU6050_GYRO_RANGE_500 1 - #define MPU6050_GYRO_RANGE_1000 2 - #define MPU6050_GYRO_RANGE_2000 3 + #define MPU6050_GYRO_RANGE_250 1 + #define MPU6050_GYRO_RANGE_500 2 + #define MPU6050_GYRO_RANGE_1000 3 + #define MPU6050_GYRO_RANGE_2000 4 */ mpu.initialize(); - mpu.setAcceleroRange(defaultWriteValue); - mpu.setGyroRange(defaultWriteValue); + mpu.setAcceleroRange(MPU6050_ACCELERO_RANGE_8G); + mpu.setGyroRange(MPU6050_GYRO_RANGE_1000); if( mpu.testConnection() ){ //pc.printf("mpu test:OK\n\r");