2015-10-15 11:19:35 -07:00
|
|
|
/*
|
|
|
|
* Author: Jon Trulson <jtrulson@ics.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
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.
|
2015-10-15 11:19:35 -07:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-10-15 11:19:35 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "adxrs610.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2015-10-15 11:19:35 -07:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
bool shouldRun = true;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
2015-10-15 11:19:35 -07:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
if (signo == SIGINT)
|
|
|
|
shouldRun = false;
|
2015-10-15 11:19:35 -07:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
2015-10-15 11:19:35 -07:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
signal(SIGINT, sig_handler);
|
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
// Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
|
|
|
|
// analog A1 (temp out) with an analog reference voltage of
|
|
|
|
// 5.0
|
|
|
|
upm::ADXRS610 sensor(0, 1, 5.0);
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
// set a deadband region around the zero point to report 0.0 (optional)
|
|
|
|
sensor.setDeadband(0.015);
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
// Every tenth of a second, sample the ADXRS610 and output it's
|
|
|
|
// corresponding temperature and angular velocity
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
while (shouldRun) {
|
|
|
|
cout << "Vel (deg/s): " << sensor.getAngularVelocity() << endl;
|
|
|
|
cout << "Temp (C): " << sensor.getTemperature() << endl;
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay_us(100000);
|
2015-10-15 11:19:35 -07:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Exiting" << endl;
|
2015-10-15 11:19:35 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
return 0;
|
2015-10-15 11:19:35 -07:00
|
|
|
}
|