restructured direction switching to fix rotation

needle rotation direction switches if the direction config button is
clicked while the motor is already moving