mma7660: C implementation; FTI; C++ wraps C

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2016-10-27 15:12:26 -06:00
parent 585f2eb331
commit c09ab37a59
16 changed files with 1252 additions and 510 deletions

View File

@ -44,36 +44,29 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an MMA7660 on I2C bus 0
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_DEFAULT_I2C_BUS,
MMA7660_DEFAULT_I2C_ADDR);
// place device in standby mode so we can write registers
accel->setModeStandby();
// enable 64 samples per second
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
accel->setSampleRate(MMA7660_AUTOSLEEP_64);
// place device into active mode
accel->setModeActive();
while (shouldRun)
{
int x, y, z;
accel->getRawValues(&x, &y, &z);
cout << "Raw values: x = " << x
<< " y = " << y
<< " z = " << z
<< endl;
float ax, ay, az;
accel->getAcceleration(&ax, &ay, &az);
cout << "Acceleration: x = " << ax
cout << "Acceleration: x = " << ax
<< "g y = " << ay
<< "g z = " << az
<< "g" << endl;
cout << endl;
usleep(500000);
}