2014-06-18 09:37:50 +00:00
|
|
|
/*
|
|
|
|
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.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-06-18 09:37:50 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-06-18 09:37:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "pulsensor.hpp"
|
|
|
|
#include "upm_utilities.h"
|
2014-06-18 09:37:50 +00:00
|
|
|
|
2016-01-11 16:45:57 -08:00
|
|
|
using namespace upm;
|
|
|
|
|
2014-06-18 09:37:50 +00:00
|
|
|
int doWork = 0;
|
|
|
|
|
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
|
|
|
{
|
|
|
|
printf("got signal\n");
|
|
|
|
if (signo == SIGINT) {
|
|
|
|
printf("exiting application\n");
|
|
|
|
doWork = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:58:12 -08:00
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
class mycb : public virtual Callback
|
2017-08-30 15:00:29 -07:00
|
|
|
{
|
2018-01-23 11:58:12 -08:00
|
|
|
public:
|
|
|
|
virtual void run(clbk_data arg)
|
|
|
|
{
|
|
|
|
printf("callback data (%d)\n", arg.is_heart_beat);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-18 09:37:50 +00:00
|
|
|
|
|
|
|
int
|
2017-08-30 15:00:29 -07:00
|
|
|
main(int argc, char** argv)
|
2014-06-18 09:37:50 +00:00
|
|
|
{
|
2018-01-23 11:58:12 -08:00
|
|
|
mycb cb;
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2018-01-23 11:58:12 -08:00
|
|
|
Pulsensor sensor(&cb);
|
2016-10-13 12:18:52 -07:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
sensor.start_sampler();
|
2014-06-18 09:37:50 +00:00
|
|
|
while (!doWork) {
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay_us(5);
|
2014-06-18 09:37:50 +00:00
|
|
|
}
|
2017-08-30 15:00:29 -07:00
|
|
|
sensor.stop_sampler();
|
|
|
|
//! [Interesting]
|
2014-06-18 09:37:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|