1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include "gy65.h"
- #include <signal.h>
-
- int doWork = 0;
- upm::GY65 *sensor = NULL;
-
- void
- sig_handler(int signo)
- {
- printf("got signal\n");
- if (signo == SIGINT) {
- printf("exiting application\n");
- doWork = 1;
- }
- }
-
- int
- main(int argc, char **argv)
- {
-
- uint32_t presure = 0;
- float temperature = 0;
- float altitude = 0;
- uint32_t sealevel = 0;
-
-
- sensor = new upm::GY65(0, ADDR);
-
-
-
- while (!doWork) {
- presure = sensor->getPressure ();
- temperature = sensor->getTemperature ();
- altitude = sensor->getAltitude ();
- sealevel = sensor->getSealevelPressure ();
-
- std::cout << "pressure value = " <<
- presure <<
- ", altitude value = " <<
- altitude <<
- ", sealevel value = " <<
- sealevel <<
- ", temperature = " <<
- temperature << std::endl;
- usleep (100000);
- }
-
-
- std::cout << "exiting application" << std::endl;
-
- delete sensor;
-
- return 0;
- }
|