2014-07-04 18:01:51 +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-07-04 18:01:51 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-07-04 18:01:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "th02.hpp"
|
|
|
|
#include "upm_utilities.h"
|
2014-07-04 18:01:51 +00:00
|
|
|
|
|
|
|
int doWork = 0;
|
|
|
|
|
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
|
|
|
{
|
|
|
|
printf("got signal\n");
|
|
|
|
if (signo == SIGINT) {
|
|
|
|
printf("exiting application\n");
|
|
|
|
doWork = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-08-30 15:00:29 -07:00
|
|
|
main(int argc, char** argv)
|
2014-07-04 18:01:51 +00:00
|
|
|
{
|
|
|
|
//! [Interesting]
|
|
|
|
float temperature = 0.0;
|
|
|
|
float humidity = 0.0;
|
2017-08-30 15:00:29 -07:00
|
|
|
upm::TH02 sensor;
|
2014-07-04 18:01:51 +00:00
|
|
|
|
|
|
|
while (!doWork) {
|
2017-08-30 15:00:29 -07:00
|
|
|
temperature = sensor.getTemperature();
|
|
|
|
humidity = sensor.getHumidity();
|
2014-07-04 18:01:51 +00:00
|
|
|
std::cout << "Temperature = " << temperature << ", Humidity = " << humidity << std::endl;
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay_us(500000);
|
2014-07-04 18:01:51 +00:00
|
|
|
}
|
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
std::cout << "exiting application" << std::endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|