bool L3G4200D::begin(l3g4200d_dps_t scale, l3g4200d_odrbw_t odrbw) { // Reset calibrate values d.XAxis = 0; d.YAxis = 0; d.ZAxis = 0; useCalibrate = false; // Reset threshold values t.XAxis = 0; t.YAxis = 0; t.ZAxis = 0; actualThreshold = 0; Wire.begin(); // Check L3G4200D Who Am I Register if (fastRegister8(L3G4200D_REG_WHO_AM_I) != 0xD3) { return false; } // Enable all axis and setup normal mode + Output Data Range & Bandwidth uint8_t reg1 = 0x00; reg1 |= 0x0F; // Enable all axis and setup normal mode reg1 |= (odrbw << 4); // Set output data rate & bandwidh writeRegister8(L3G4200D_REG_CTRL_REG1, reg1); // Disable high pass filter writeRegister8(L3G4200D_REG_CTRL_REG2, 0x00); // Generata data ready interrupt on INT2 writeRegister8(L3G4200D_REG_CTRL_REG3, 0x08); // Set full scale selection in continous mode writeRegister8(L3G4200D_REG_CTRL_REG4, scale << 4); switch(scale) { case L3G4200D_SCALE_250DPS: dpsPerDigit = .00875f; break; case L3G4200D_SCALE_500DPS: dpsPerDigit = .0175f; break; case L3G4200D_SCALE_2000DPS: dpsPerDigit = .07f; break; default: break; } // Boot in normal mode, disable FIFO, HPF disabled writeRegister8(L3G4200D_REG_CTRL_REG5, 0x00); return true; }
bool HMC5883L::begin() { Wire.begin(); if ((fastRegister8(HMC5883L_REG_IDENT_A) != 0x48) || (fastRegister8(HMC5883L_REG_IDENT_B) != 0x34) || (fastRegister8(HMC5883L_REG_IDENT_C) != 0x33)) { return false; } setRange(HMC5883L_RANGE_1_3GA); setMeasurementMode(HMC5883L_CONTINOUS); setDataRate(HMC5883L_DATARATE_15HZ); setSamples(HMC5883L_SAMPLES_1); mgPerDigit = 0.92f; return true; }
bool ADXL345::begin() { f.XAxis = 0; f.YAxis = 0; f.ZAxis = 0; Wire.begin(); // Check ADXL345 REG DEVID if (fastRegister8(ADXL345_REG_DEVID) != 0xE5) { return false; } // Enable measurement mode (0b00001000) writeRegister8(ADXL345_REG_POWER_CTL, 0x08); clearSettings(); return true; }