Library for accelerometer KXR94-2050
Revision 2:1e4a75b43643, committed 2015-01-03
- Comitter:
- 66keg
- Date:
- Sat Jan 03 15:21:49 2015 +0000
- Parent:
- 1:b3acee234ab5
- Commit message:
- revise
Changed in this revision
KXR94_2050.cpp | Show annotated file Show diff for this revision Revisions of this file |
KXR94_2050.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r b3acee234ab5 -r 1e4a75b43643 KXR94_2050.cpp --- 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
diff -r b3acee234ab5 -r 1e4a75b43643 KXR94_2050.h --- a/KXR94_2050.h Sat Jan 03 15:09:22 2015 +0000 +++ b/KXR94_2050.h Sat Jan 03 15:21:49 2015 +0000 @@ -7,9 +7,8 @@ class KXR94_2050 { public: KXR94_2050(PinName OutX, PinName OutY, PinName OutZ); - ~KXR94_2050(); void setZeroVal(uint16_t x_zero, uint16_t y_zero, uint16_t z_zero); - void getRawData(float &pitch, float &roll); // degree data + void getRawData(float *pitch, float *roll); // degree data private: AnalogIn _OutX, _OutY, _OutZ;