Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
chemo_detect.c
Go to the documentation of this file.
1 #include "chemo_detect.h"
2 #include "enose.h"
3 
4 #define DETECT_PERIOD 8 /* *4Hz */
5 #define THRESHOLD 150
6 
8 
9 void chemo_init(void)
10 {
11  chemo_sensor = 0;
12 }
13 
14 void chemo_periodic(void)
15 {
16 #ifdef ENOSE
18  static int idx;
19 
20  /* Detection on the first sensor */
21  int dval = enose_val[0] - vals[0][idx];
22  if (dval < -THRESHOLD) {
23  chemo_sensor = -dval;
24  } else {
25  chemo_sensor = 0;
26  }
27 
28  int i;
29  for (i = 0; i < ENOSE_NB_SENSOR; i++) {
30  vals[i][idx] = enose_val[i];
31  }
32 
33  idx++;
34  if (idx > DETECT_PERIOD) {
35  idx = 0;
36  }
37 #endif /* ENOSE */
38 }
#define THRESHOLD
Definition: chemo_detect.c:5
unsigned short uint16_t
Definition: types.h:16
static uint32_t idx
#define DETECT_PERIOD
Definition: chemo_detect.c:4
uint16_t enose_val[ENOSE_NB_SENSOR]
Definition: sim_enose.c:5
void chemo_periodic(void)
Definition: chemo_detect.c:14
uint16_t chemo_sensor
Definition: chemo_detect.c:7
void chemo_init(void)
Definition: chemo_detect.c:9
#define ENOSE_NB_SENSOR
Definition: enose.h:6