Skip to content

Commit 9d72161

Browse files
Failsafe. Compute return 0
The compute method now returns 0 if the begin() method hasn't been called.
1 parent ac79675 commit 9d72161

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/PIDController.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ double PIDController::compute (double sensor, String graph, String verbose) {
7474
// Return false if it could not execute;
7575
// This is the actual PID algorithm executed every loop();
7676

77+
// Failsafe, return if the begin() method hasn't been called
78+
if (!init) return 0;
79+
7780
// Calculate time difference since last time executed
7881
unsigned long now = millis();
7982
double timeChange = (double)(now - lastTime);

0 commit comments

Comments
 (0)