diff options
-rw-r--r-- | tube-rotator/stepper.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tube-rotator/stepper.c b/tube-rotator/stepper.c index 349651f..24ce37b 100644 --- a/tube-rotator/stepper.c +++ b/tube-rotator/stepper.c @@ -90,8 +90,11 @@ static inline void stepper_handle(void) STEPPER_PORT = (STEPPER_PORT & STEPPER_OUTPUT_BITMASK ) | stepper_output; step_idx++; step_idx %= LENGTH_STEP_TABLE; - current_speed = (current_speed < target_speed) ? current_speed + 1 : target_speed; - OCR1A = current_speed; + + if(current_speed > target_speed) + OCR1A = --current_speed; + else if(current_speed < target_speed) + OCR1A = ++current_speed; } ISR(TIMER1_COMPA_vect) |