예제 #1
0
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;
}
예제 #2
0
파일: Motion.cpp 프로젝트: CarterA/Oz
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;
  
}