Library for accelerometer KXR94-2050
Diff: KXR94_2050.cpp
- Revision:
- 2:1e4a75b43643
- Parent:
- 0:2700ada3a245
--- a/KXR94_2050.cpp Sat Jan 03 15:09:22 2015 +0000 +++ b/KXR94_2050.cpp Sat Jan 03 15:21:49 2015 +0000 @@ -8,21 +8,21 @@ Z_ZERO_VAL = 2052; } -void KXR94_2050::gsetZeroVal(uint16_t x_zero, uint16_t y_zero, uint16_t z_zero) { +void KXR94_2050::setZeroVal(uint16_t x_zero, uint16_t y_zero, uint16_t z_zero) { X_ZERO_VAL = x_zero; Y_ZERO_VAL = y_zero; Z_ZERO_VAL = z_zero; } -void KXR94_2050::getRawData(float &pitch, float &roll) { - uint16_t Xacc = X_value.read_u16(); - uint16_t Yacc = Y_value.read_u16(); - uint16_t Zacc = Z_value.read_u16(); +void KXR94_2050::getRawData(float *pitch, float *roll) { + uint16_t Xacc = _OutX.read_u16(); + uint16_t Yacc = _OutY.read_u16(); + uint16_t Zacc = _OutZ.read_u16(); int xval = Xacc - X_ZERO_VAL; int yval = Yacc - Y_ZERO_VAL; int zval = Zacc - Z_ZERO_VAL; - roll = atan2l(yval, zval) * 180.0 / PI; - pitch = atan2l(xval, zval) * 180.0 / PI; + *roll = atan2l(yval, zval) * 180.0 / PI; + *pitch = atan2l(xval, zval) * 180.0 / PI; } \ No newline at end of file