diff --git a/pi.c b/pi.c index 934fff6..825ec22 100644 --- a/pi.c +++ b/pi.c @@ -72,25 +72,19 @@ static double pi_sample(struct servo *servo, case 1: s->offset[1] = offset; s->local[1] = local_ts; - *state = SERVO_UNLOCKED; - s->count = 2; - break; - case 2: + s->drift += (s->offset[1] - s->offset[0]) * 1e9 / (s->local[1] - s->local[0]); if (s->drift < -s->maxppb) s->drift = -s->maxppb; else if (s->drift > s->maxppb) s->drift = s->maxppb; - *state = SERVO_UNLOCKED; - s->count = 3; - break; - case 3: + *state = SERVO_JUMP; ppb = s->drift; - s->count = 4; + s->count = 2; break; - case 4: + case 2: /* * reset the clock servo when offset is greater than the max * offset value. Note that the clock jump will be performed in