-
Notifications
You must be signed in to change notification settings - Fork 0
/
tray.h
63 lines (47 loc) · 1.04 KB
/
tray.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
60
61
62
63
#ifndef __TRAY_H
#define __TRAY_H
#include <Arduino.h>
#include <inttypes.h>
#include <Bounce2.h>
#include "timer.h"
class Tray {
public:
enum State {
Open,
Closed,
Opening,
Closing,
Off
};
Tray(uint8_t clsdPIPin, uint8_t openPIPin,
uint8_t motorCtrlEnabledPin, uint8_t motorDirection1Pin, uint8_t motorDirection2Pin);
~Tray();
void init();
State getCurrentState();
State getDesiredState();
void setDesiredState(State desiredState);
unsigned long getClosingDelay();
void setClosingDelay(unsigned long delay);
unsigned long getOpeningDelay();
void setOpeningDelay(unsigned long delay);
void update();
private:
uint8_t _clsdPIPin;
uint8_t _openPIPin;
uint8_t _motorCtrlEnabledPin;
uint8_t _motorDirection1Pin;
uint8_t _motorDirection2Pin;
Bounce* _clsdPI;
Bounce* _openPI;
State _desiredState;
State _controllerState;
Timer* _closingTimer;
Timer* _openingTimer;
unsigned long _closingDelay;
unsigned long _openingDelay;
State _determineControllerState();
void _open();
void _close();
void _off();
};
#endif