123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
-
-
- #include <unistd.h>
- #include <signal.h>
- #include <iostream>
- #include "adc121c021.h"
-
- using namespace std;
-
- int shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
- int main(int argc, char **argv)
- {
- signal(SIGINT, sig_handler);
-
-
-
-
- upm::ADC121C021 *adc = new upm::ADC121C021(ADC121C021_I2C_BUS,
- ADC121C021_DEFAULT_I2C_ADDR);
-
-
-
-
- while (shouldRun)
- {
- uint16_t val = adc->value();
- cout << "ADC value: " << val << " Volts = "
- << adc->valueToVolts(val) << endl;
- usleep(50000);
- }
-
-
- cout << "Exiting..." << endl;
-
- delete adc;
- return 0;
- }
|