1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include "mq9.h"
- #include <signal.h>
- #include <stdlib.h>
- #include <sys/time.h>
-
- int is_running = 0;
- uint16_t buffer [128];
- upm::MQ9 *sensor = NULL;
-
- void
- sig_handler(int signo)
- {
- printf("got signal\n");
- if (signo == SIGINT) {
- is_running = 1;
- }
- }
-
-
- int
- main(int argc, char **argv)
- {
- sensor = new upm::MQ9(0);
- signal(SIGINT, sig_handler);
-
- thresholdContext ctx;
- ctx.averageReading = 0;
- ctx.runningAverage = 0;
- ctx.averagedOver = 2;
-
- while (!is_running) {
- int len = sensor->getSampledWindow (2, 128, buffer);
- if (len) {
- int thresh = sensor->findThreshold (&ctx, 30, buffer, len);
- sensor->printGraph(&ctx, 5);
- if (thresh) {
-
- }
- }
- }
-
- std::cout << "exiting application" << std::endl;
-
- delete sensor;
-
- return 0;
- }
|