LSM303DLHC Full Driver: Readings For Acc, Mag and Temp; Class Method for frequently-used 13 sensor parameters; Class Method to direct modify registers; Support Calibration (offset+scale);
Diff: LSM303DLHC.cpp
- Revision:
- 1:e68ce5025dad
- Parent:
- 0:7864abfabe2f
- Child:
- 3:522d01930e6a
--- a/LSM303DLHC.cpp Mon Jun 06 07:40:45 2016 +0000 +++ b/LSM303DLHC.cpp Tue Jun 07 06:20:17 2016 +0000 @@ -26,6 +26,7 @@ // CUSTOM THE INITIAL CTRL FOR YOURSELF ACtrl(LP_OFF); // ACC Normal Power Mode ACtrl(ODR3); // ACC ON and Date Rate 25Hz + ACtrl(XYZ); // ACC XYZ Axis Enable ACtrl(HPF_ON); // ACC internal HPF In Use ACtrl(HPF_CF0); // ACC HPF Cutoff Freq = option 0 ACtrl(HPF_NORM); // ACC HPF Model = Normal @@ -87,6 +88,14 @@ i2c.write(ACC_ADDRESS, data, 2); } +void LSM303DLHC::ACtrl(ACC_AXIS cmd){ + data[0] = CTRL_REG1_A; + i2c.write(ACC_ADDRESS, data, 1); + i2c.read(ACC_ADDRESS, &data[1], 1); + data[1] = data[1] & (0b11111000) | (cmd<<0); + i2c.write(ACC_ADDRESS, data, 2); +} + void LSM303DLHC::ACtrl(ACC_HPM cmd){ data[0] = CTRL_REG2_A; i2c.write(ACC_ADDRESS, data, 1);