From afc75059cb0751d0a1cd328a4ebefe727dd721e3 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 3 Aug 2024 15:46:50 +0800 Subject: [PATCH] update --- .../step_motor_ctrl_module.cpp | 22 +++++++++++++--------- usrc/project_configs.h | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 203922b..9754667 100644 --- a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/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) { 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); } 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(); }); 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) { - 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(); creg.module_status = 1; m_thread.start( @@ -628,12 +637,7 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_move_to(int32_t tox) { 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() { m_thread.stop(); diff --git a/usrc/project_configs.h b/usrc/project_configs.h index c6a5e35..a32adcc 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,5 +1,5 @@ #pragma once -#define PC_VERSION 600 +#define PC_VERSION 601 #define PC_MANUFACTURER "http://www.iflytop.com/" #define PC_PROJECT_NAME "a8000_subboard" #define PC_IFLYTOP_ENABLE_OS 1