Browse Source

update

master
zhaohe 1 year ago
parent
commit
afc75059cb
  1. 22
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  2. 2
      usrc/project_configs.h

22
sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -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();

2
usrc/project_configs.h

@ -1,5 +1,5 @@
#pragma once #pragma once
#define PC_VERSION 600
#define PC_VERSION 601
#define PC_MANUFACTURER "http://www.iflytop.com/" #define PC_MANUFACTURER "http://www.iflytop.com/"
#define PC_PROJECT_NAME "a8000_subboard" #define PC_PROJECT_NAME "a8000_subboard"
#define PC_IFLYTOP_ENABLE_OS 1 #define PC_IFLYTOP_ENABLE_OS 1

Loading…
Cancel
Save