add .clang-format
Change-Id: I6627b5569c2e0f730be7331403218b823a2c622f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/ec/pid.cpp b/pid/ec/pid.cpp
index a1c4e41..ef0df14 100644
--- a/pid/ec/pid.cpp
+++ b/pid/ec/pid.cpp
@@ -53,15 +53,15 @@
// calculate P, I, D, FF
// Pid
- error = setpoint - input;
- p_term = pidinfoptr->p_c * error;
+ error = setpoint - input;
+ p_term = pidinfoptr->p_c * error;
// pId
if (0.0f != pidinfoptr->i_c)
{
- i_term = pidinfoptr->integral;
- i_term += error * pidinfoptr->i_c * pidinfoptr->ts;
- i_term = clamp(i_term, pidinfoptr->i_lim.min, pidinfoptr->i_lim.max);
+ i_term = pidinfoptr->integral;
+ i_term += error * pidinfoptr->i_c * pidinfoptr->ts;
+ i_term = clamp(i_term, pidinfoptr->i_lim.min, pidinfoptr->i_lim.max);
}
// FF
@@ -79,8 +79,8 @@
if (pidinfoptr->slew_neg != 0.0f)
{
// Don't decrease too fast
- float min_out = pidinfoptr->last_output + pidinfoptr->slew_neg *
- pidinfoptr->ts;
+ float min_out =
+ pidinfoptr->last_output + pidinfoptr->slew_neg * pidinfoptr->ts;
if (output < min_out)
{
output = min_out;
@@ -89,8 +89,8 @@
if (pidinfoptr->slew_pos != 0.0f)
{
// Don't increase too fast
- float max_out = pidinfoptr->last_output + pidinfoptr->slew_pos *
- pidinfoptr->ts;
+ float max_out =
+ pidinfoptr->last_output + pidinfoptr->slew_pos * pidinfoptr->ts;
if (output > max_out)
{
output = max_out;
@@ -107,12 +107,12 @@
// Clamp again because having limited the output may result in a
// larger integral term
- i_term = clamp(i_term, pidinfoptr->i_lim.min, pidinfoptr->i_lim.max);
+ i_term = clamp(i_term, pidinfoptr->i_lim.min, pidinfoptr->i_lim.max);
pidinfoptr->integral = i_term;
- pidinfoptr->initialized = true;
- pidinfoptr->last_output = output;
+ pidinfoptr->initialized = true;
+ pidinfoptr->last_output = output;
return output;
}
-}
+} // namespace ec
diff --git a/pid/ec/pid.hpp b/pid/ec/pid.hpp
index e138933..6b1030a 100644
--- a/pid/ec/pid.hpp
+++ b/pid/ec/pid.hpp
@@ -7,8 +7,8 @@
typedef struct
{
- float min;
- float max;
+ float min;
+ float max;
} limits_t;
/* Note: If you update these structs you need to update the copy code in
@@ -16,21 +16,21 @@
*/
typedef struct
{
- bool initialized; // has pid been initialized
+ bool initialized; // has pid been initialized
- float ts; // sample time in seconds
- float integral; // intergal of error
- float last_output; // value of last output
+ float ts; // sample time in seconds
+ float integral; // intergal of error
+ float last_output; // value of last output
- float p_c; // coeff for P
- float i_c; // coeff for I
- float ff_off; // offset coeff for feed-forward term
- float ff_gain; // gain for feed-forward term
+ float p_c; // coeff for P
+ float i_c; // coeff for I
+ float ff_off; // offset coeff for feed-forward term
+ float ff_gain; // gain for feed-forward term
- limits_t i_lim; // clamp of integral
- limits_t out_lim; // clamp of output
- float slew_neg;
- float slew_pos;
+ limits_t i_lim; // clamp of integral
+ limits_t out_lim; // clamp of output
+ float slew_neg;
+ float slew_pos;
} pid_info_t;
float pid(pid_info_t* pidinfoptr, float input, float setpoint);
@@ -38,16 +38,15 @@
/* Condensed version for use by the configuration. */
struct pidinfo
{
- float ts; // sample time in seconds
- float p_c; // coeff for P
- float i_c; // coeff for I
- float ff_off; // offset coeff for feed-forward term
- float ff_gain; // gain for feed-forward term
- ec::limits_t i_lim; // clamp of integral
- ec::limits_t out_lim; // clamp of output
- float slew_neg;
- float slew_pos;
+ float ts; // sample time in seconds
+ float p_c; // coeff for P
+ float i_c; // coeff for I
+ float ff_off; // offset coeff for feed-forward term
+ float ff_gain; // gain for feed-forward term
+ ec::limits_t i_lim; // clamp of integral
+ ec::limits_t out_lim; // clamp of output
+ float slew_neg;
+ float slew_pos;
};
-
-}
+} // namespace ec