Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MMA8451Q by
Revision 5:d3d979cbf5b6, committed 2014-08-07
- Comitter:
- palheart
- Date:
- Thu Aug 07 08:36:48 2014 +0000
- Parent:
- 4:c4d879a39775
- Commit message:
- Renamed the whole thing in order to prevent messing up with the real library
Changed in this revision
MMA8451Q.cpp | Show annotated file Show diff for this revision Revisions of this file |
MMA8451Q.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MMA8451Q.cpp Fri Oct 12 11:35:07 2012 +0000 +++ b/MMA8451Q.cpp Thu Aug 07 08:36:48 2014 +0000 @@ -28,8 +28,13 @@ MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) { // activate the peripheral - uint8_t data[2] = {REG_CTRL_REG_1, 0x01}; +// uint8_t data[2] = {REG_CTRL_REG_1, 0x01}; + uint8_t data[2] = {REG_CTRL_REG_1, 0x15}; // 0001 0101. 200Hz, low noise, active + uint8_t dataa[2] = {0x2b, 0x12}; // high resoluition + writeRegs(data, 2); + writeRegs(dataa, 2); + } MMA8451Q::~MMA8451Q() { } @@ -40,6 +45,15 @@ return who_am_i; } +int16_t MMA8451Q::getAccXX() { + return (getAccAxis(REG_OUT_X_MSB)); +} + +int16_t MMA8451Q::getAccYY() { + return (getAccAxis(REG_OUT_Y_MSB)); +} + + float MMA8451Q::getAccX() { return (float(getAccAxis(REG_OUT_X_MSB))/4096.0); }
--- a/MMA8451Q.h Fri Oct 12 11:35:07 2012 +0000 +++ b/MMA8451Q.h Thu Aug 07 08:36:48 2014 +0000 @@ -76,6 +76,8 @@ * @returns X axis acceleration */ float getAccX(); + int16_t getAccXX(); + int16_t getAccYY(); /** * Get Y axis acceleration