sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
temp.h
Go to the documentation of this file.
1 #ifndef TEMP_H
2 #define TEMP_H
3 
4 #include "dev_data.h"
5 #include "features.h"
6 
7 #if defined(N_TEMP)
8 
9 #define TEMP_AGAIN (int16_t)0x8000
10 
11 // values are °C << 5
12 // we could use K here, but we're not because most sensors return °C anyway
13 typedef struct {
14  uint8_t flags;
15  uint8_t device;
16  int16_t value;
17  int16_t lower;
18  int16_t upper;
19 } temp_t;
20 extern temp_t temps[];
21 
22 typedef void temp_init_fn(void);
23 typedef void temp_setup_fn(uint8_t devno);
24 typedef int16_t temp_poll_fn(uint8_t devno);
25 
26 typedef struct {
27  temp_init_fn *init;
28  temp_setup_fn *setup;
29  temp_poll_fn *poll;
30 } temp_call_t;
31 
32 #define TDEFS(_s) \
33  temp_init_fn temp_init_ ## _s; \
34  temp_setup_fn temp_setup_ ## _s; \
35  temp_poll_fn temp_poll_ ## _s;
36 
37 #define TFUNCPTRS(_s) \
38 { \
39  &temp_init_ ## _s, \
40  &temp_setup_ ## _s, \
41  &temp_poll_ ## _s, \
42 }
43 
44 #define TEMP_TC_DEFINE(x) \
45  TDEFS(x)
46 #include "_temp_defs.h"
47 #undef TEMP_TC_DEFINE
48 
49 // the first two bits are used for temp_out_t, i.e. PO_* constants. Hardcoded.
50 #define TEMP_MASK ((1<<5)-1) // drievr number
51 #define TEMP_ALERT (1<<5) // trigger an alarm when stepping over boundary
52 #define TEMP_IS_ALERT_L (1<<6) // alarm triggered (low)?
53 #define TEMP_IS_ALERT_H (1<<7) // alarm triggered (high)?
54 
55 #ifdef CONDITIONAL_SEARCH
56 
57 extern uint8_t temp_changed_cache;
58 static inline char temp_alert(void) {
59  if (temp_changed_cache)
60  return 1;
61  return 0;
62 }
63 
64 #else
65 #define temp_alert() 0
66 #endif
67 
68 #else // no i/o
69 
70 #define alert_temp() 0
71 
72 #endif // any inputs or outputs at all
73 #endif // temp_h
void setup()
Definition: Due_AS7265X_Spectrometer.ino:55
def init
Definition: ow-slave-test.py:11