-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSprayHandler.h
59 lines (40 loc) · 1.07 KB
/
SprayHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <Arduino.h>
#ifndef _SPRAY_HANDLER_H_
#define _SPRAY_HANDLER_H_
class SprayValve;
typedef void (SprayValve::*SprayValveStateFN)(void);
class SprayValve {
public:
SprayValve();
SprayValve *nextValve;
void initialize();
void resetValve( bool triggerLongSpray = false );
void startValve();
//state functions
bool done = false;
SprayValve* perform();
SprayValveStateFN state;
void waitingToOpenValve();
void openValve();
void valveOpen();
uint8_t pin;
bool triggerLongSpray = true;
unsigned long dt = 0;
unsigned long duration; //time valve is open
unsigned long interval; //time until next valve should open
};
class SprayHandler;
typedef void (SprayHandler::*SprayHandlerStateFN)(void);
class SprayHandler {
public:
SprayHandler(uint8_t valveAPin, uint8_t valveBPin, uint8_t valveCPin);
void initialize();
void triggerLongSpray();
void perform();
private:
SprayValve *currentValve;
SprayValve valveA;
SprayValve valveB;
SprayValve valveC;
};
#endif