-
Notifications
You must be signed in to change notification settings - Fork 1
/
CapacitorController.h
45 lines (35 loc) · 976 Bytes
/
CapacitorController.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
#if !defined(CAPACITOR_CONTROLLER_H)
#define CAPACITOR_CONTROLLER_H
#include "ComponentController.h"
class CapacitorController : public ComponentController
{
public:
enum Direction { NONE, DOWN, UP };
enum Speed { IDLE, FAST, SLOW, FINE };
enum State { DISABLED, PWM_HIGH, PWM_LOW };
CapacitorController();
virtual ~CapacitorController();
void setDirection(Direction dir);
Direction getDirection() const;
void setSpeed(Speed speed);
Speed getSpeed() const;
void setOneShot(bool oneShot);
bool getOneShot() const;
virtual void process();
virtual void setup();
void forceStop();
private:
Direction direction_;
Speed speed_;
// PWM control
State pwmState_;
int pwmPin_;
int pwmHighTimeMs_;
int pwmLowTimeMs_;
bool oneShot_;
unsigned long pwmStateStartTime_;
void enableTuningPin_();
void disableTuningPins_();
void setPwmSettings(int pin, int highTimeMs, int lowTimeMs);
};
#endif // CAPACITOR_CONTROLLER_H