Browse Source

set xy-hbot setup in disable mode

master
zhaohe 2 years ago
parent
commit
1bd944d7ea
  1. 6
      components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp

6
components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp

@ -36,15 +36,16 @@ void XYRobotCtrlModule::initialize(int32_t id, IStepperMotor* stepM1, IStepperMo
} else { } else {
m_cfg = m_default_cfg; m_cfg = m_default_cfg;
} }
enable(false);
active_cfg(); active_cfg();
m_stepM1->setScaleDenominator(10); m_stepM1->setScaleDenominator(10);
m_stepM2->setScaleDenominator(10); m_stepM2->setScaleDenominator(10);
enable(true);
m_thread.init("XYRobotCtrlModule", 1024, osPriorityNormal); 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) { 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); zlock_guard lock(m_lock);
if (!m_enable) enable(true);
ZLOGI(TAG, "move_to x:%d y:%d", x, y); ZLOGI(TAG, "move_to x:%d y:%d", x, y);
int runspeed = speed; int runspeed = speed;
if (speed == 0) { 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) { 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); zlock_guard lock(m_lock);
if (!m_enable) enable(true);
ZLOGI(TAG, "move_by_no_limit dx:%d dy:%d", dx, dy); ZLOGI(TAG, "move_by_no_limit dx:%d dy:%d", dx, dy);
m_thread.stop(); 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) { 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); zlock_guard lock(m_lock);
if (!m_enable) enable(true);
ZLOGI(TAG, "move_by dx:%d dy:%d %d", dx, dy, speed); ZLOGI(TAG, "move_by dx:%d dy:%d %d", dx, dy, speed);
m_thread.stop(); m_thread.stop();

Loading…
Cancel
Save