Accès aux registres d'un capteur IAQ (qualité de l'air)
#include <sysio/delay.h>
#include <sysio/iaq.h>
#include <stdlib.h>
#include <signal.h>
#include <assert.h>
#include <stdio.h>
#define DEFAULT_I2C_BUS "/dev/i2c-1"
xIaq * sensor;
static void
vSigIntHandler (int sig) {
if ( (sig == SIGINT) || (sig == SIGTERM)) {
perror ("iIaqClose");
exit (EXIT_FAILURE);
}
printf ("\n# everything was closed.\n# Have a nice day !\n");
exit (EXIT_SUCCESS);
}
}
int
main (void) {
int ret;
bool bIsWarmUp = false;
printf ("\n# IAQ Demo\n");
signal (SIGINT, vSigIntHandler);
signal (SIGTERM, vSigIntHandler);
printf ("# Press Ctrl+C to abort ...\n");
printf ("# Co2(ppm) Voc(ppb)\n");
for (;;) {
switch (ret) {
case 0:
break;
if (bIsWarmUp == false) {
printf ("# Warming, please wait of about 5 minutes...\n");
bIsWarmUp = true;
}
break;
default:
printf ("iIaqRead() return %d\n", ret);
break;
}
}
return 0;
}