您的位置:首页 > 产品设计 > UI/UE

Arduino101学习笔记(十三)—— 101六轴传感器

2016-11-13 14:47 417 查看

一、相关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()


二、
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: