From 9ad3ca5726c97670ada733e450bd2e406cebed75 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 5 Jun 2024 20:42:41 +0800 Subject: [PATCH] update --- a8000_protocol | 2 +- iflytop_canbus/iflytop_canbus_master.hpp | 14 +++++++------- src/tab/step_motor_ctrl_tab.cpp | 24 +++++++++++++----------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/a8000_protocol b/a8000_protocol index 7bfd98c..77eb032 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit 7bfd98cff4587d08a048aff876d8130bcb31d919 +Subproject commit 77eb03279eb3f348ded05b200978dae54fc86d1f diff --git a/iflytop_canbus/iflytop_canbus_master.hpp b/iflytop_canbus/iflytop_canbus_master.hpp index 558759e..ac97895 100644 --- a/iflytop_canbus/iflytop_canbus_master.hpp +++ b/iflytop_canbus/iflytop_canbus_master.hpp @@ -66,9 +66,9 @@ class IflytopCanbusMaster { /******************************************************************************* * TX CONTEXT * *******************************************************************************/ - mutex m_tx_lock; - uint8_t m_txbuf[1024]; - int32_t m_rxsize; + mutex m_tx_lock; + uint8_t m_txbuf[1024]; + int32_t m_rxsize; uint16_t m_txindex = 0; WaveshareCan m_waveCan; @@ -96,9 +96,9 @@ class IflytopCanbusMaster { void sendraw(int32_t fromId, uint8_t *data, size_t len); - int32_t getAck(int32_t index); - uint8_t* getAckBuf(); - int32_t getAckBufLen(); + int32_t getAck(int32_t index); + uint8_t *getAckBuf(); + int32_t getAckBufLen(); public: /*********************************************************************************************************************** @@ -114,7 +114,7 @@ class IflytopCanbusMaster { void step_motor_easy_move_to(int32_t device_id, int32_t position) { callcmd1(device_id, kstep_motor_easy_move_to, position); } void step_motor_easy_move_to_zero(int32_t device_id) { callcmd0(device_id, kstep_motor_easy_move_to_zero); } void step_motor_easy_set_current_pos(int32_t device_id, int32_t position) { callcmd1(device_id, kstep_motor_easy_set_current_pos, position); } - void step_motor_easy_move_to_io(int32_t device_id, int32_t io) { callcmd1(device_id, kstep_motor_easy_move_to_io, io); } + void step_motor_easy_move_to_io(int32_t device_id, int32_t io, int32_t direction) { callcmd1(device_id, kstep_motor_easy_move_to_io, io, direction); } void step_motor_active_cfg(int32_t device_id) { callcmd0(device_id, kstep_motor_active_cfg); } void step_motor_read_io_state(int32_t device_id, int32_t io, int32_t *state) { callcmd1(device_id, kstep_motor_read_io_state, io); diff --git a/src/tab/step_motor_ctrl_tab.cpp b/src/tab/step_motor_ctrl_tab.cpp index 2ef2b6f..a3266af 100644 --- a/src/tab/step_motor_ctrl_tab.cpp +++ b/src/tab/step_motor_ctrl_tab.cpp @@ -44,28 +44,30 @@ void StepMotorCtrlTab::construct(QTabWidget *fathertab) { { ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4); - // - box->newFunc("使能", {"enable"}, [this](int argn, const char **args) { ICM->step_motor_enable(getDeviceId(), atoi(args[0])); }); - box->newFunc("读取位置", {}, [this](int argn, const char **args) { - int32_t pos = 0; - ICM->step_motor_read_pos(getDeviceId(), &pos); - ZQUI::ins()->ishow("Pos:%d", pos); - }); + box->newFunc("停止", {}, [this](int argn, const char **args) { ICM->step_motor_stop(getDeviceId(), 0); }); + box->newFunc("激活配置", {}, [this](int argn, const char **args) { ICM->step_motor_active_cfg(getDeviceId()); }); + box->newFunc("", {}, [this](int argn, const char **args) {}); + box->newFunc("旋转", {"direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_rotate(getDeviceId(), atoi(args[0])); }); box->newFunc("相对移动", {"distance"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_by(getDeviceId(), atoi(args[0])); }); box->newFunc("移动到", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to(getDeviceId(), atoi(args[0])); }); box->newFunc("归零", {}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_zero(getDeviceId()); }); + box->newFunc("移动到终点", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kstep_motor_easy_move_to_end_point); }); + box->newFunc("移动到IO", {"ioindex", "direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_io(getDeviceId(), atoi(args[0]), atoi(args[1])); }); + + box->newFunc("", {}, [this](int argn, const char **args) {}); box->newFunc("设置当前位置", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_set_current_pos(getDeviceId(), atoi(args[0])); }); - box->newFunc("移动到IO", {"ioindex"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_io(getDeviceId(), atoi(args[0])); }); - box->newFunc("激活配置", {}, [this](int argn, const char **args) { ICM->step_motor_active_cfg(getDeviceId()); }); - box->newFunc("停止", {}, [this](int argn, const char **args) { ICM->step_motor_stop(getDeviceId(), 0); }); + box->newFunc("读取位置", {}, [this](int argn, const char **args) { + int32_t pos = 0; + ICM->step_motor_read_pos(getDeviceId(), &pos); + ZQUI::ins()->ishow("Pos:%d", pos); + }); box->newFunc("读取IO状态", {"ioindex"}, [this](int argn, const char **args) { int32_t io = 0; ICM->step_motor_read_io_state(getDeviceId(), atoi(args[0]), &io); ZQUI::ins()->ishow("IO:%d", io); }); - box->newFunc("读取5130电机详细状态", {"ioindex"}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kstep_motor_read_tmc5130_status);