From 89e87e3e598a565d28bcc43d092f546183613e7c Mon Sep 17 00:00:00 2001 From: virtualabs Date: Wed, 4 Sep 2024 00:39:26 +0200 Subject: [PATCH] Fixed a small error in our motor driver. --- cutcutgo.X/src/hal/motor.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cutcutgo.X/src/hal/motor.c b/cutcutgo.X/src/hal/motor.c index f4c4020..2d2c07e 100644 --- a/cutcutgo.X/src/hal/motor.c +++ b/cutcutgo.X/src/hal/motor.c @@ -624,7 +624,7 @@ int hal_motor_step(hal_motor_driver_t *motor, int steps, hal_motor_direction_t d break; case HAL_MOTOR_DIR_CW: - { + { offset = motor->rel_pos_th - motor->rel_pos; } break; @@ -632,7 +632,13 @@ int hal_motor_step(hal_motor_driver_t *motor, int steps, hal_motor_direction_t d default: break; } - + + /* Do not exceed an extra step. */ + if (offset > 8) + { + offset = 8; + } + motor->command_steps = 8 + offset; motor->current_steps = 0; motor->error_steps = 0;