getValues()

描述

取得六轴感测器经由偏移量校正后的数值。

语法


FreeIMU1.getValues(values)

参数

FreeIMU1FreeIMU1 型别的变数

valuesvalues 是一个指向浮点数阵列或双精度浮点数阵列的指标,该阵列应该至少有可以存放六个浮点数或双精度浮点数元素的空间。在 getValues() 执行完后,该阵列内容会依序存放加速度计 X,Y,Z 轴经偏移量校正后的数值及陀螺仪 X,Y,Z 轴经偏移量校正后的数值

回传

范例

#include <FreeIMU1.h> 
#include <Wire.h>
   
FreeIMU1 myIMU;

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  delay(500);
   
  myIMU.init();
  delay(500);
}
   
void loop()
{
  double values[6];
  char str[512];

  myIMU.getValues(values);
  sprintf(str, "%f\t%f\t%f\t%f\t%f\t%f\t", 
          values[0], values[1], values[2], 
          values[3], values[4], values[5]);
  Serial.print(str);
  Serial.print('\n');
  delay(20);
}

See also

getRawValues()


函式库参考主页面

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.