@@ -8,17 +8,16 @@ class PID
8
8
9
9
public:
10
10
11
- // Constants used in some of the functions below
12
- #define AUTOMATIC 1
13
- #define MANUAL 0
14
- #define DIRECT 0
15
- #define REVERSE 1
11
+ // Parameter types for some of the functions below
12
+ enum mode_t { AUTOMATIC = 1 , MANUAL = 0 };
13
+ enum direction_t { DIRECT = 0 , REVERSE = 1 };
16
14
17
15
// commonly used functions **************************************************************************
18
16
PID (double *, double *, double *, // * constructor. links the PID to the Input, Output, and
19
- double , double , double , int ); // Setpoint. Initial tuning parameters are also set here
17
+ double , double , double , // Setpoint. Initial tuning parameters are also set here
18
+ direction_t );
20
19
21
- void SetMode (int Mode ); // * sets PID to either Manual (0) or Auto (non-0 )
20
+ void SetMode (mode_t ); // * sets PID to either MANUAL (0) or AUTOMATIC (1 )
22
21
23
22
bool Compute (); // * performs the PID calculation. it should be
24
23
// called every time loop() cycles. ON/OFF and
@@ -35,8 +34,8 @@ class PID
35
34
void SetTunings (double , double , // * While most users will set the tunings once in the
36
35
double ); // constructor, this function gives the user the option
37
36
// of changing tunings during runtime for Adaptive control
38
- void SetControllerDirection (int ); // * Sets the Direction, or "Action" of the controller. DIRECT
39
- // means the output will increase when error is positive. REVERSE
37
+ void SetControllerDirection ( // * Sets the Direction, or "Action" of the controller. DIRECT
38
+ direction_t ); // means the output will increase when error is positive. REVERSE
40
39
// means the opposite. it's very unlikely that this will be needed
41
40
// once it is set in the constructor.
42
41
void SetSampleTime (int ); // * sets the frequency, in Milliseconds, with which
0 commit comments