2015-02-25 15:57:48 -05:00
|
|
|
/*
|
|
|
|
* Author: Zion Orent <zorent@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-02-25 15:57:48 -05:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-02-25 15:57:48 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-09-08 13:55:23 -07:00
|
|
|
#include "gsr.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2015-02-25 15:57:48 -05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
bool shouldRun = true;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
2015-02-25 15:57:48 -05:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
if (signo == SIGINT)
|
|
|
|
shouldRun = false;
|
2015-02-25 15:57:48 -05:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
2015-02-25 15:57:48 -05:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
signal(SIGINT, sig_handler);
|
2015-02-25 15:57:48 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
|
|
|
// The was tested with the GSR Galvanic Skin Response Sensor module.
|
2015-02-25 15:57:48 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
// Instantiate a GSR on analog pin A0
|
|
|
|
upm::GSR gsr(0);
|
|
|
|
cout << "Calibrating...." << endl;
|
|
|
|
gsr.calibrate();
|
2015-02-25 15:57:48 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
while (shouldRun) {
|
|
|
|
cout << gsr.value() << endl;
|
|
|
|
upm_delay_us(500000);
|
|
|
|
}
|
|
|
|
//! [Interesting]
|
2015-02-25 15:57:48 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Exiting" << endl;
|
2015-02-25 15:57:48 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
return 0;
|
2015-02-25 15:57:48 -05:00
|
|
|
}
|