From 5314911664472096f949b4706277778307e8e41a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 19 May 2014 01:46:04 +0200 Subject: also decreasing current speed --- tube-rotator/stepper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tube-rotator') 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) -- cgit v1.2.3