Firmware SDK
twr_flood_detector.h
1 #ifndef _TWR_FLOOD_DETECTOR_H
2 #define _TWR_FLOOD_DETECTOR_H
3 
4 #include <twr_tick.h>
5 #include <twr_module_sensor.h>
6 #include <twr_scheduler.h>
7 #include <twr_gpio.h>
8 
12 
14 
15 typedef enum
16 {
17  TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_A,
18  TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_B,
19  TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_C
20 
22 
24 
25 typedef enum
26 {
27  TWR_FLOOD_DETECTOR_EVENT_ERROR,
28  TWR_FLOOD_DETECTOR_EVENT_UPDATE,
29 
31 
33 
35 
37 
38 typedef enum
39 {
40  TWR_FLOOD_DETECTOR_STATE_ERROR = -1,
41  TWR_FLOOD_DETECTOR_STATE_INITIALIZE = 0,
42  TWR_FLOOD_DETECTOR_STATE_READY = 1,
43  TWR_FLOOD_DETECTOR_STATE_MEASURE = 2,
44 
45 } twr_flood_detector_state_t;
46 
48 {
50  void (*_event_handler)(twr_flood_detector_t *, twr_flood_detector_event_t, void *);
51  void *_event_param;
52  twr_tick_t _update_interval;
53  twr_flood_detector_state_t _state;
54  twr_scheduler_task_id_t _task_id_interval;
55  twr_scheduler_task_id_t _task_id_measure;
56  bool _measurement_active;
57  bool _alarm;
58 
59 };
60 
62 
66 
68 
73 
74 void twr_flood_detector_set_event_handler(twr_flood_detector_t *self, void (*event_handler)(twr_flood_detector_t *,twr_flood_detector_event_t, void*), void *event_param);
75 
79 
81 
86 
88 
93 
95 
97 
98 #endif // _TWR_FLOOD_DETECTOR_H
struct twr_flood_detector_t twr_flood_detector_t
Instance.
void twr_flood_detector_init(twr_flood_detector_t *self, twr_flood_detector_type_t type)
Initialize flood detector.
bool twr_flood_detector_is_alarm(twr_flood_detector_t *self)
Is alarm.
bool twr_flood_detector_measure(twr_flood_detector_t *self)
Start measurement manually.
twr_flood_detector_type_t
Type sensor.
twr_flood_detector_event_t
Callback events.
void twr_flood_detector_set_update_interval(twr_flood_detector_t *self, twr_tick_t interval)
Set measurement interval.
void twr_flood_detector_set_event_handler(twr_flood_detector_t *self, void(*event_handler)(twr_flood_detector_t *, twr_flood_detector_event_t, void *), void *event_param)
Set callback function.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: twr_scheduler.h:22
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16