一、相關API
1、begin:需要在其他CUIREIMU前調用
//********************************************************************************************* //函數名稱:CurieImu.begin() //輸入參數:無 //函數返回:無 //函數功能:開六軸傳感器,必須第一個調用 //********************************************************************************************* CurieIMU.begin();
2、得到陀螺儀的采樣頻率
//********************************************************************************************* //函數名稱:CurieImu.getGyroRate() //輸入參數:無 //函數返回:25 50 100 200 400 800 1600 3200(Hz) //函數功能:得到陀螺儀的采樣頻率
//********************************************************************************************* CurieIMU.getGyroRate();
3、設置陀螺儀的采樣頻率
他的數據速率也是采樣頻率,並影響讀數的帶寬。
//********************************************************************************************* //函數名稱:CurieImu.setGyroRate(int rate) //輸入參數:rate 采樣頻率 25 50 100 200 400 800 1600 3200(Hz) //函數返回:無 //函數功能:無 //********************************************************************************************* CurieImu.setGyroRate(int rate);
4、得到加速度計的采樣頻率
//********************************************************************************************* //函數名稱:CurieImu.getAccelerometerRate() //輸入參數:無
//函數返回:rate 采樣頻率 12.5 25 50 100 200 400 800 1600
//函數功能:返回加速度計的采樣頻率 //********************************************************************************************* CurieIMU.getAccelerometerRate()
5、設置加速度計的采樣頻率
//********************************************************************************************* //函數名稱:CurieImu.setAccelerometerRate(float rate) //輸入參數:rate 采樣頻率 12.5 25 50 100 200 400 800 1600 //函數返回:無 //函數功能:返回加速度計的采樣頻率 //********************************************************************************************* CurieIMU.setAccelerometerRate(float rate)
6、返回陀螺儀測量范圍
//********************************************************************************************* //函數名稱:CurieImu.getGyroRange() //輸入參數:無 //函數返回:2000 (+/-2000°/s) // 1000 (+/-1000°/s) // 500 (+/-500°/s) // 250 (+/-250°/s) // 125 (+/-125°/s) //函數功能:返回陀螺儀的測量范圍 //********************************************************************************************* CurieIMU.getGyroRange()
7、設置陀螺儀測量范圍
//********************************************************************************************* //函數名稱:CurieImu.setGyroRange() //輸入參數:2000 (+/-2000°/s) // 1000 (+/-1000°/s) // 500 (+/-500°/s) // 250 (+/-250°/s) // 125 (+/-125°/s) //函數返回:無 //函數功能:返回陀螺儀的測量范圍 //********************************************************************************************* CurieIMU.setGyroRange()
8、得到加速度計的測量范圍
//********************************************************************************************* //函數名稱:CurieImu.getAccelerometerRange() //輸入參數:無 //函數返回:2 (+/- 2g) // 4 (+/- 4g) // 8 (+/- 8g) // 16 (+/- 16g) //函數功能:返回陀螺儀的測量范圍 //********************************************************************************************* CurieIMU.getAccelerometerRange()
9、設置加速度計的測量范圍
//********************************************************************************************* //函數名稱:CurieImu.setAccelerometerRange(int range) //輸入參數:2 (+/- 2g) // 4 (+/- 4g) // 8 (+/- 8g) // 16 (+/- 16g) //函數返回:無 //函數功能:返回陀螺儀的測量范圍 //********************************************************************************************* CurieIMU.setAccelerometerRange(int range)
10、自動進行陀螺儀偏移計算
//********************************************************************************************* //函數名稱:CurieImu.autoCalibrateGyroOffset() //輸入參數:無 //函數返回:無 //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.autoCalibrateGyroOffset()
11、自動進行加速計偏移計算
//********************************************************************************************* //函數名稱:CurieImu.autoCalibrateAccelerometerOffset(int, axis, int target) //輸入參數:axis: X_AXIS // Y_AXIS // Z_AXIS // target: it can be 0 or 1. 1表示要取消重力的影響,即平躺時Z軸應該寫1 //函數返回:無 //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.autoCalibrateAccelerometerOffset(int, axis, int target)
12、偏移修正開關
//關閉 CurieIMU.noGyroOffset(); CurieIMU.noAccelerometerOffset(); //打開 CurieIMU.gyroOffsetEnabled(); CurieIMU.accelerometerOffsetEnabled();
13、得到陀螺儀偏移修正的數值
//********************************************************************************************* //函數名稱:CurieImu.getGyroOffset(int axis) //輸入參數:axis: X_AXIS // Y_AXIS // Z_AXIS //函數返回:修正的偏移值,The returned value is from -31.25 °/s to +31.25 °/s in discrete steps of 0.061 °/s. //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.getGyroOffset(int axis)
14、設置陀螺儀偏移
//********************************************************************************************* //函數名稱:CurieImu.setGyroOffset(int axis, int offset) //輸入參數:axis: X_AXIS // Y_AXIS // Z_AXIS // offset 偏移 //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.setGyroOffset(int axis, int offset)
15、得到陀螺儀偏移
//********************************************************************************************* //函數名稱:CurieImu.getAccelerometerOffset(int axis) //輸入參數:axis: X_AXIS // Y_AXIS // Z_AXIS //函數返回: //函數功能: //********************************************************************************************* CurieIMU.getAccelerometerOffset(int axis)
16、設置陀螺儀偏移
//********************************************************************************************* //函數名稱:CurieImu.setAccelerometerOffset(int axis, int offset) //輸入參數:axis: X_AXIS // Y_AXIS // Z_AXIS // offset 偏移 //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.setAccelerometerOffset(int axis, int offset)
17、得到檢測閾值
//********************************************************************************************* //函數名稱:CurieImu.getDetectionThreshold(int feature) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_TAP //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.getDetectionThreshold(int feature)
18、設置檢測閾值
//********************************************************************************************* //函數名稱:CurieImu.setDetectionThreshold(int feature, float value) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_TAP //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.setDetectionThreshold(int feature, float value)
19、得到檢測的持續時間
//********************************************************************************************* //函數名稱:CurieImu.getDetectionDuration(int feature) //輸入參數:feature: the requested feature. It can assume one of these values:
- CURIE_IMU_TAP
- CURIE_IMU_TAP_QUIET
- CURIE_IMU_DOUBLE_TAP
- CURIE_IMU_ZERO_MOTION
//函數返回: //函數功能:檢測持續時間 //********************************************************************************************* CurieIMU.getDetectionDuration(int feature)
20、設置檢測的持續時間
//********************************************************************************************* //函數名稱:CurieImu.setDetectionDuration(int feature, float value) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_DOUBLE_TAP // CURIE_IMU_TAP_SHOCK // CURIE_IMU_TAP_QUIET P //函數返回: //函數功能:檢測持續時間 //********************************************************************************************* CurieIMU.setDetectionDuration(int feature, float value)
21、允許某個特征產生中斷
//********************************************************************************************* //函數名稱:CurieImu.interrupts(int feature) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_STEP // CURIE_IMU_TAP // CURIE_IMU_TAP_SHOCK // CURIE_IMU_TAP_QUIET // CURIE_IMU_DOUBLE_TAP //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.interrupts(int feature)
22、關閉某個特征產生中斷
//********************************************************************************************* //函數名稱:CurieImu.noInterrupts(int feature) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_STEP // CURIE_IMU_TAP // CURIE_IMU_TAP_SHOCK // CURIE_IMU_TAP_QUIET // CURIE_IMU_DOUBLE_TAP //函數返回: //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.noInterrupts(int feature)
23、返回某個特征是否開了中斷
//********************************************************************************************* //函數名稱:CurieImu.interruptEnabled(int feature) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_STEP // CURIE_IMU_TAP // CURIE_IMU_TAP_SHOCK // CURIE_IMU_TAP_QUIET // CURIE_IMU_DOUBLE_TAP //函數返回:TURE FALSE //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.interruptEnabled(int feature)
24、檢測是否進入中斷狀態
//********************************************************************************************* //函數名稱:CurieImu.getInterruptStatus(int feature) //輸入參數:feature: the requested feature. It can assume one of these values: // CURIE_IMU_FREEFALL // CURIE_IMU_SHOCK // CURIE_IMU_MOTION // CURIE_IMU_ZERO_MOTION // CURIE_IMU_STEP // CURIE_IMU_TAP // CURIE_IMU_TAP_SHOCK // CURIE_IMU_TAP_QUIET // CURIE_IMU_DOUBLE_TAP //函數返回:TURE FALSE //函數功能:進行陀螺儀偏移計算 //********************************************************************************************* CurieIMU.getInterruptStatus(int feature)
25、返回步進檢測模式的值
//********************************************************************************************* //函數名稱:CurieImu.getStepDetectionMode() //輸入參數:CURIE_IMU_STEP_MODE_NORMAL // CURIE_IMU_STEP_MODE_SENSITIVE // CURIE_IMU_STEP_MODE_ROBUST // CURIE_IMU_STEP_MODE_UNKNOWN //函數返回:TURE FALSE //********************************************************************************************* CurieIMU.getStepDetectionMode()
26、設置步進檢測模式的值
//********************************************************************************************* //函數名稱:CurieImu.setStepDetectionMode(int mode) //輸入參數:CURIE_IMU_STEP_MODE_NORMAL // CURIE_IMU_STEP_MODE_SENSITIVE // CURIE_IMU_STEP_MODE_ROBUST // CURIE_IMU_STEP_MODE_UNKNOWN //函數返回:TURE FALSE //********************************************************************************************* CurieIMU.setStepDetectionMode(in mode)
27、讀取6軸傳感器的數值
//********************************************************************************************* //函數名稱:CurieImu.readMotionSensor(int ax, int ay, int az, int gx, int gy, int gz) //輸入參數:ax: a variable in which the accelerometer's value along x will be stored. // ay: a variable in which the accelerometer's value along y will be stored. // az: a variable in which the accelerometer's value along z will be stored. // gx: a variable in which the gyro's value along x will be stored. // gy: a variable in which the gyro's value along y will be stored. // gz: a variable in which the gyro's value along z will be stored. //函數返回: //********************************************************************************************* CurieIMU.readMotionSensor(int ax, int ay, int az, int gx, int gy, int gz)
28、讀取加速度的數值
//********************************************************************************************* //函數名稱:CurieImu.readAccelerometer(int ax, int ay, int az) //輸入參數:ax: a variable in which the accelerometer's value along x will be stored. // ay: a variable in which the accelerometer's value along y will be stored. // az: a variable in which the accelerometer's value along z will be stored. //函數返回: //********************************************************************************************* CurieIMU.readAccelerometer(int ax, int ay, int az)
29、讀取陀螺儀的數值
//********************************************************************************************* //函數名稱:CurieImu.readGyro(int gx, int gy, int gz) //輸入參數: // gx: a variable in which the gyro's value along x will be stored. // gy: a variable in which the gyro's value along y will be stored. // gz: a variable in which the gyro's value along z will be stored. //函數返回: //********************************************************************************************* CurieIMU.readGyro(int gx, int gy, int gz)
30、讀取溫度值
//********************************************************************************************* //函數名稱:CurieImu.readTemperature() //輸入參數: //函數返回:Celsius=(raw/32767.0)+23 16位的 //********************************************************************************************* CurieIMU.readTemperature()
31、檢測晃動
//********************************************************************************************* //函數名稱:CurieIMU.shockDetected(int axis, int direction) //輸入參數:axis: the axis to check for shock detection. It must have one of these values: // X_AXIS // Y_AXIS // Z_AXIS // direction: the direction to check for shock detection. It must have one of these values: // POSITIVE from zero to positive axis values // NEGATIVE from zero to negative axis values //函數返回:Ture False //********************************************************************************************* CurieIMU.shockDetected(int axis, int direction)
32、檢測動作
//********************************************************************************************* //函數名稱:CurieImu.motionDetected(int axis, int direction) //輸入參數:axis: the axis to check for shock detection. It must have one of these values: // X_AXIS // Y_AXIS // Z_AXIS // direction: the direction to check for shock detection. It must have one of these values: // POSITIVE from zero to positive axis values // NEGATIVE from zero to negative axis values //函數返回:Ture False //********************************************************************************************* CurieIMU.motionDetected(int axis, int direction)
33、其他檢測
CurieIMU.tapDetected(int axis, int direction)
CurieIMU.stepsDetected()
34、注冊中斷函數
//********************************************************************************************* //函數名稱:CurieIMU.attachInterrupt(voidFuncPtr callback) //輸入參數:注冊中斷函數 //函數返回:無 //********************************************************************************************* CurieIMU.attachInterrupt(voidFuncPtr callback)
35、取消注冊中斷函數
CurieIMU.detachInterrupt()
二、
