123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
-
- #include "am2315.h"
-
- volatile int doWork = 0;
-
- upm::AM2315 *sensor = NULL;
-
- void
- sig_handler(int signo)
- {
- if (signo == SIGINT) {
- printf("\nCtrl-C received.\n");
- doWork = 1;
- }
- }
-
- int
- main(int argc, char **argv)
- {
-
- signal(SIGINT, sig_handler);
-
-
- float humidity = 0.0;
- float temperature = 0.0;
-
- sensor = new upm::AM2315(0, AM2315_I2C_ADDRESS);
-
- sensor->testSensor();
-
- while (!doWork) {
- humidity = sensor->getHumidity();
- temperature = sensor->getTemperature();
-
- std::cout << "humidity value = " <<
- humidity <<
- ", temperature value = " <<
- temperature << std::endl;
- usleep (500000);
- }
-
-
- std::cout << "exiting application" << std::endl;
-
- delete sensor;
-
- return 0;
- }
|