1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
-
-
- #include <unistd.h>
- #include <signal.h>
- #include <iostream>
- #include "mma7660.h"
-
- using namespace std;
-
- int shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
- int main(int argc, char **argv)
- {
- signal(SIGINT, sig_handler);
-
-
-
-
- upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
- MMA7660_DEFAULT_I2C_ADDR);
-
-
- accel->setModeStandby();
-
-
- accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
-
-
- 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
- << "g y = " << ay
- << "g z = " << az
- << "g" << endl;
-
- usleep(500000);
- }
-
-
-
- cout << "Exiting..." << endl;
-
- delete accel;
- return 0;
- }
|