From 1bd944d7ea168f6378ac8d8da86badf4c2f0ba27 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 28 Dec 2023 10:45:18 +0800 Subject: [PATCH] set xy-hbot setup in disable mode --- components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp index b22401d..326cf7a 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp @@ -36,15 +36,16 @@ void XYRobotCtrlModule::initialize(int32_t id, IStepperMotor* stepM1, IStepperMo } else { m_cfg = m_default_cfg; } + enable(false); active_cfg(); m_stepM1->setScaleDenominator(10); m_stepM2->setScaleDenominator(10); - enable(true); m_thread.init("XYRobotCtrlModule", 1024, osPriorityNormal); } int32_t XYRobotCtrlModule::move_to(int32_t x, int32_t y, int32_t speed, action_cb_status_t status_cb) { zlock_guard lock(m_lock); + if (!m_enable) enable(true); ZLOGI(TAG, "move_to x:%d y:%d", x, y); int runspeed = speed; if (speed == 0) { @@ -85,6 +86,7 @@ int32_t XYRobotCtrlModule::move_to(int32_t x, int32_t y, int32_t speed, action_c int32_t XYRobotCtrlModule::move_by_no_limit(int32_t dx, int32_t dy, int32_t speed, action_cb_status_t status_cb) { zlock_guard lock(m_lock); + if (!m_enable) enable(true); ZLOGI(TAG, "move_by_no_limit dx:%d dy:%d", dx, dy); m_thread.stop(); @@ -117,6 +119,8 @@ int32_t XYRobotCtrlModule::move_by_no_limit(int32_t dx, int32_t dy, int32_t spee int32_t XYRobotCtrlModule::move_by(int32_t dx, int32_t dy, int32_t speed, action_cb_status_t status_cb) { zlock_guard lock(m_lock); + if (!m_enable) enable(true); + ZLOGI(TAG, "move_by dx:%d dy:%d %d", dx, dy, speed); m_thread.stop();