2014-12-12 13:55:24 -05:00
|
|
|
/*
|
|
|
|
* Author: Zion Orent <zorent@ics.com>
|
|
|
|
* Copyright (c) 2014 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.
|
2014-12-12 13:55:24 -05:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-12-12 13:55:24 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "biss0001.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2014-12-12 13:55:24 -05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int shouldRun = true;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
2014-12-12 13:55:24 -05:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
if (signo == SIGINT)
|
|
|
|
shouldRun = false;
|
2014-12-12 13:55:24 -05:00
|
|
|
}
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
2014-12-12 13:55:24 -05:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
signal(SIGINT, sig_handler);
|
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
// Instantiate a Grove Motion sensor on GPIO pin D2
|
|
|
|
upm::BISS0001 motion(2);
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
while (shouldRun) {
|
|
|
|
bool val = motion.value();
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
if (val)
|
|
|
|
cout << "Detecting moving object";
|
|
|
|
else
|
|
|
|
cout << "No moving objects detected";
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << endl;
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay(1);
|
|
|
|
}
|
|
|
|
//! [Interesting]
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Exiting" << endl;
|
2014-12-12 13:55:24 -05:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
return 0;
|
2014-12-12 13:55:24 -05:00
|
|
|
}
|