|
@ -483,7 +483,8 @@ int32_t StepMotorCtrlModule::step_motor_easy_move_to(int32_t tox) { |
|
|
if (m_state.has_move_to_zero == 0) { |
|
|
if (m_state.has_move_to_zero == 0) { |
|
|
return err::kstep_motor_not_move_to_zero; |
|
|
return err::kstep_motor_not_move_to_zero; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_cfg.min_d != 0 && tox < m_cfg.min_d) tox = m_cfg.min_d; |
|
|
|
|
|
if (m_cfg.max_d != 0 && tox > m_cfg.max_d) tox = m_cfg.max_d; |
|
|
return do_step_motor_easy_move_to(tox); |
|
|
return do_step_motor_easy_move_to(tox); |
|
|
} |
|
|
} |
|
|
int32_t StepMotorCtrlModule::step_motor_easy_move_to_zero() { |
|
|
int32_t StepMotorCtrlModule::step_motor_easy_move_to_zero() { |
|
@ -604,9 +605,17 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_rotate(int32_t direction) { |
|
|
[this]() { m_stepM1->stop(); }); |
|
|
[this]() { m_stepM1->stop(); }); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_by(int32_t distance) { |
|
|
|
|
|
int32_t motor_pos = 0; |
|
|
|
|
|
step_motor_read_pos(&motor_pos); |
|
|
|
|
|
motor_pos += distance; |
|
|
|
|
|
|
|
|
|
|
|
int32_t ecode = check_befor_run(); |
|
|
|
|
|
if (ecode != 0) return ecode; |
|
|
|
|
|
|
|
|
|
|
|
return do_step_motor_easy_move_to(motor_pos); |
|
|
|
|
|
} |
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_to(int32_t tox) { |
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_to(int32_t tox) { |
|
|
if (m_cfg.min_d != 0 && tox < m_cfg.min_d) tox = m_cfg.min_d; |
|
|
|
|
|
if (m_cfg.max_d != 0 && tox > m_cfg.max_d) tox = m_cfg.max_d; |
|
|
|
|
|
m_thread.stop(); |
|
|
m_thread.stop(); |
|
|
creg.module_status = 1; |
|
|
creg.module_status = 1; |
|
|
m_thread.start( |
|
|
m_thread.start( |
|
@ -628,12 +637,7 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_move_to(int32_t tox) { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_by(int32_t distance) { |
|
|
|
|
|
int32_t motor_pos = 0; |
|
|
|
|
|
step_motor_read_pos(&motor_pos); |
|
|
|
|
|
motor_pos += distance; |
|
|
|
|
|
return step_motor_easy_move_to(motor_pos); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_zero() { |
|
|
int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_zero() { |
|
|
m_thread.stop(); |
|
|
m_thread.stop(); |
|
|