Skip to content

Commit

Permalink
Added test for auto mode setting
Browse files Browse the repository at this point in the history
  • Loading branch information
m-lundberg committed Jan 30, 2019
1 parent af2ab1b commit b376820
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ def test_monotonic():
assert _current_time == time.monotonic


def test_auto_mode():
pid = PID(1, 0, 0, setpoint=10, sample_time=None)

# ensure updates happen by default
assert pid(0) == 10
assert pid(5) == 5

# ensure no new updates happen when auto mode is off
pid.auto_mode = False
assert pid(1) == 5
assert pid(7) == 5

# should reset when reactivating
pid.auto_mode = True
assert pid._last_input is None
assert pid._error_sum == 0
assert pid(8) == 2


def test_clamp():
from simple_pid.PID import _clamp

Expand Down

0 comments on commit b376820

Please sign in to comment.