2014-06-24 18:17:46 +00:00
|
|
|
/*
|
2015-07-16 16:56:23 -06:00
|
|
|
* Author: Jon Trulson <jtrulson@ics.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
2014-06-24 18:17:46 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2014-06-24 18:17:46 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-06-24 18:17:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2015-07-16 16:56:23 -06:00
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "mpu9150.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2014-06-24 18:17:46 +00:00
|
|
|
|
2015-07-16 16:56:23 -06:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int shouldRun = true;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
2014-06-24 18:17:46 +00:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
if (signo == SIGINT)
|
|
|
|
shouldRun = false;
|
2015-07-16 16:56:23 -06:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
2015-07-16 16:56:23 -06:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
signal(SIGINT, sig_handler);
|
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
upm::MPU9150 sensor;
|
|
|
|
|
|
|
|
sensor.init();
|
|
|
|
|
|
|
|
while (shouldRun) {
|
|
|
|
sensor.update();
|
|
|
|
|
|
|
|
float x, y, z;
|
|
|
|
|
|
|
|
sensor.getAccelerometer(&x, &y, &z);
|
|
|
|
cout << "Accelerometer: ";
|
|
|
|
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
|
|
|
|
|
|
|
|
sensor.getGyroscope(&x, &y, &z);
|
|
|
|
cout << "Gryoscope: ";
|
|
|
|
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
|
|
|
|
|
|
|
|
sensor.getMagnetometer(&x, &y, &z);
|
|
|
|
cout << "Magnetometer: ";
|
|
|
|
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
|
|
|
|
|
|
|
|
cout << "Temperature: " << sensor.getTemperature() << endl;
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
upm_delay_us(500000);
|
2015-07-16 16:56:23 -06:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
cout << "Exiting..." << endl;
|
2015-07-16 16:56:23 -06:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
return 0;
|
2014-06-24 18:17:46 +00:00
|
|
|
}
|