当前位置: 首页>>代码示例>>C++>>正文


C++ HMC5883L::initialize方法代码示例

本文整理汇总了C++中HMC5883L::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ HMC5883L::initialize方法的具体用法?C++ HMC5883L::initialize怎么用?C++ HMC5883L::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HMC5883L的用法示例。


在下文中一共展示了HMC5883L::initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setupOther

void ExtendoHand::setupOther() {
    if (nineAxis) {
        // adjust the power settings after you call this method if you want the accelerometer
        // to enter standby mode, or another less demanding mode of operation
        accel.setRange(1); // 4g
        accel.setFullResolution(1); // maintain 4mg/LSB scale factor (irrespective of range)
        accel.initialize();
        if (!accel.testConnection()) {
            osc.sendError("ADXL345 connection failed");
        } else {
            randomSeed(accel.getAccelerationX() - accel.getAccelerationY() + accel.getAccelerationZ());
        }

#ifdef ENABLE_GYRO
        gyro.initialize();
        if (!gyro.testConnection()) {
            osc.sendError("ITG3200 connection failed");
        }
#endif // ENABLE_GYRO

#ifdef ENABLE_MAGNETOMETER
        magnet.initialize();
        if (!magnet.testConnection()) {
            osc.sendError("HMC5883L connection failed");
        }
#endif // ENABLE_MAGNETOMETER
    } else {
#ifdef THREE_AXIS
        randomSeed(motionSensor.rawX() + motionSensor.rawY() + motionSensor.rawZ());

        // 1.5g constants, sampled 2014-06-21
        motionSensor.calibrateX(272, 794);
        motionSensor.calibrateY(332, 841);
        motionSensor.calibrateZ(175, 700);
#endif // THREE_AXIS
    }

    vibrateStart = 0;
    alertStart = 0;
}
开发者ID:XixiLuo,项目名称:extendo,代码行数:40,代码来源:ExtendoHand.cpp

示例2: setupMotionSensors

int setupMotionSensors() {
  
  int error = 0;
  
  // Initialization
  Wire.begin();
  acc.initialize();
  mag.initialize();
  gyr.initialize();
  
  // Verification
  if (!acc.testConnection() ||
      !mag.testConnection() ||
      !gyr.testConnection())
      error = 1;
  
  // Configuration
  acc.setRange(ADXL345_RANGE_16G);
  mag.setMode(HMC5883L_MODE_CONTINUOUS);
    
  return error;
  
}
开发者ID:CarterA,项目名称:Oz,代码行数:23,代码来源:Motion.cpp

示例3: main

int main(int argc, char **argv) {
  printf("HMC5883L 3-axis acceleromter example program\n");
  I2Cdev::initialize();
  HMC5883L mag ;
  if ( mag.testConnection() ) 
    printf("HMC5883L connection test successful\n") ;
  else {
    fprintf( stderr, "HMC5883L connection test failed! something maybe wrong, continueing anyway though ...\n");
    //return 1;
  }
  mag.initialize();
  mag.setSampleAveraging(HMC5883L_AVERAGING_8);
  mag.setGain(HMC5883L_GAIN_1090);
  int16_t mx, my, mz;
  float heading ;
  while (true) {
    mag.getHeading(&mx, &my, &mz);
    heading = atan2(my, mx)  * 180 / PI;
    printf("  mx:  %d       my:  %d      mz:  %d     heading:  %3.1f deg\r", mx, my, mz, heading);
    fflush(stdout);
    bcm2835_delay(200);
  }
  return 1; 
}
开发者ID:0w0miki,项目名称:i2cdevlib,代码行数:24,代码来源:HMC5883L_example_1.cpp


注:本文中的HMC5883L::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。