Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion drivers/pid/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ namespace pimoroni {

return (error * kp) + (error_sum * ki) - (value_change * kd);
}
}

float PID::get_error_sum() const {
return error_sum;
}

void PID::reset_error_sum() {
error_sum = 0.0f;
}
}
3 changes: 3 additions & 0 deletions drivers/pid/pid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace pimoroni {
float calculate(float value);
float calculate(float value, float value_change);

[[nodiscard]] float get_error_sum() const;
void reset_error_sum();

public:
float kp;
float ki;
Expand Down