From ac5dbdd30601037dfff6b4702a9a50297493a382 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 26 Jun 2024 19:54:23 +0800 Subject: [PATCH] update --- .../xy_robot_ctrl_module/xy_robot_ctrl_module.cpp | 17 +++++++++++++++-- .../xy_robot_ctrl_module/xy_robot_ctrl_module.hpp | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) 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 3ec2f9f..4354741 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp @@ -65,6 +65,7 @@ int32_t XYRobotCtrlModule::module_active_cfg() { m_stepM2->enable(false); m_stepM1->setIHOLD_IRUN(m_cfg.ihold, m_cfg.irun, m_cfg.iholddelay); + m_stepM1->setGlobalScale(m_cfg.iglobalscaler); m_stepM1->setScale(m_cfg.one_circle_pulse / 2); m_stepM1->setScaleDenominator(m_cfg.one_circle_pulse_denominator); m_stepM1->set_vstart(m_cfg.vstart); @@ -78,6 +79,7 @@ int32_t XYRobotCtrlModule::module_active_cfg() { m_stepM1->set_enc_resolution(m_cfg.enc_resolution); m_stepM2->setIHOLD_IRUN(m_cfg.ihold, m_cfg.irun, m_cfg.iholddelay); + m_stepM2->setGlobalScale(m_cfg.iglobalscaler); m_stepM2->setScale(m_cfg.one_circle_pulse / 2); m_stepM2->setScaleDenominator(m_cfg.one_circle_pulse_denominator); m_stepM2->set_vstart(m_cfg.vstart); @@ -149,8 +151,18 @@ int32_t XYRobotCtrlModule::xymotor_read_pos(int32_t* x, int32_t* y) { } #define UPDATE_CFG(key) PROCESS_REG(kreg_xyrobot_##key, REG_GET(m_cfg.key), REG_SET(m_cfg.key)) - int32_t XYRobotCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& val) { + int32_t ret = __module_xxx_reg(param_id, read, val); + if (ret != 0) { + return ret; + } + + if (!read) { + module_active_cfg(); + } +} + +int32_t XYRobotCtrlModule::__module_xxx_reg(int32_t param_id, bool read, int32_t& val) { switch (param_id) { UPDATE_CFG(robot_type); UPDATE_CFG(one_circle_pulse); @@ -185,6 +197,7 @@ int32_t XYRobotCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& return err::kmodule_not_find_reg; break; } + return 0; } @@ -423,7 +436,7 @@ void XYRobotCtrlModule::befor_motor_move() { creg.module_status = 1; creg.module_errorcode = 0; - module_active_cfg(); + // module_active_cfg(); xymotor_enable(1); } void XYRobotCtrlModule::after_motor_move() { diff --git a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp index 3a4a3b4..03b9535 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp @@ -86,6 +86,7 @@ class XYRobotCtrlModule : public ZIXYMotor, public ZIModule { } virtual int32_t module_xxx_reg(int32_t param_id, bool read, int32_t& val) override; + int32_t __module_xxx_reg(int32_t param_id, bool read, int32_t& val); virtual int32_t module_stop() override; virtual int32_t module_active_cfg() override;