Miroslav Lichvar
2014-03-12 11:51:02 UTC
The initial check if the clock should be stepped always passed after the
servo was reset (e.g. from clock sanity check). Fix the condition to
step only when the threshold is exceeded.
Signed-off-by: Miroslav Lichvar <***@redhat.com>
---
pi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pi.c b/pi.c
index 171ff55..52d4c2f 100644
--- a/pi.c
+++ b/pi.c
@@ -116,8 +116,8 @@ static double pi_sample(struct servo *servo,
else if (s->drift > s->maxppb)
s->drift = s->maxppb;
- if (!s->first_update ||
- (s->max_f_offset && (s->max_f_offset < fabs(offset))) ||
+ if ((s->first_update &&
+ s->max_f_offset && (s->max_f_offset < fabs(offset))) ||
(s->max_offset && (s->max_offset < fabs(offset))))
*state = SERVO_JUMP;
else
servo was reset (e.g. from clock sanity check). Fix the condition to
step only when the threshold is exceeded.
Signed-off-by: Miroslav Lichvar <***@redhat.com>
---
pi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pi.c b/pi.c
index 171ff55..52d4c2f 100644
--- a/pi.c
+++ b/pi.c
@@ -116,8 +116,8 @@ static double pi_sample(struct servo *servo,
else if (s->drift > s->maxppb)
s->drift = s->maxppb;
- if (!s->first_update ||
- (s->max_f_offset && (s->max_f_offset < fabs(offset))) ||
+ if ((s->first_update &&
+ s->max_f_offset && (s->max_f_offset < fabs(offset))) ||
(s->max_offset && (s->max_offset < fabs(offset))))
*state = SERVO_JUMP;
else
--
1.8.4.2
1.8.4.2