Browse Source

update

master
zhaohe 1 year ago
parent
commit
3f3ac1af7e
  1. 2
      a8000_protocol
  2. 9
      src/tab/step_motor_ctrl_tab.cpp
  3. 24
      src/tab/xyrobot_tab.cpp

2
a8000_protocol

@ -1 +1 @@
Subproject commit 653a4997e1a69abf06244714b255876534ca55a8
Subproject commit 59082bcc8c2a856133f693619bbd1fdc64dba0fd

9
src/tab/step_motor_ctrl_tab.cpp

@ -43,13 +43,6 @@ void StepMotorCtrlTab::construct(QTabWidget *fathertab) {
ZQUI::ins()->ishow("Pos:%d", pos);
});
box->newSubButton("读取位置2", [this](int argn, const char **args) {
int32_t pos = 0;
ICM->callcmd0(getDeviceId(), kstep_motor_read_pos_and_enc_pos);
ZQUI::ins()->ishow("Pos :%d", ICM->getAck(0));
ZQUI::ins()->ishow("EncPos:%d", ICM->getAck(1));
});
box->newSubButton("读取IO状态", [this](int argn, const char **args) {
int32_t portState = 0;
int32_t indexInStm32 = 0;
@ -118,8 +111,6 @@ void StepMotorCtrlTab::construct(QTabWidget *fathertab) {
tableBox->addReg("pos", kreg_step_motor_pos, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("dpos", kreg_step_motor_dpos, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("enc_val", kreg_step_motor_enc_val, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("denc_val", kreg_step_motor_denc_val, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("shift", kreg_step_motor_shift, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("shaft", kreg_step_motor_shaft, ZRegItem::krw | ZRegItem::kdec);
tableBox->addReg("one_circle_pulse", kreg_step_motor_one_circle_pulse, ZRegItem::krw | ZRegItem::kdec);

24
src/tab/xyrobot_tab.cpp

@ -50,14 +50,23 @@ void XYRobotTab::construct(QTabWidget *fathertab) {
y = ICM->getAck(1);
ZQUI::ins()->ishow("x,y(%d,%d)", x, y);
});
box->newSubButton("直接读取电机编码器", [this](int argn, const char **args) {
ICM->callcmd0(getDeviceId(), kxymotor_read_enc_direct);
int32_t motor1_enc = ICM->getAck(0);
int32_t motor2_enc = ICM->getAck(1);
ZQUI::ins()->ishow("motor1_enc:%d motor2_enc:%d", motor1_enc, motor2_enc);
});
box->newFunc("设置位置", {"x", "y"}, [this](int argn, const char **args) { ICM->callcmd2(getDeviceId(), kxymotor_set_pos, atoi(args[0]), atoi(args[1])); });
box->newFunc("相对移动", {"dx", "dy", "velocity"}, [this](int argn, const char **args) { ICM->callcmd3(getDeviceId(), kxymotor_move_by, atoi(args[0]), atoi(args[1]), atoi(args[2])); });
box->newFunc("绝对移动", {"x", "y", "velocity"}, [this](int argn, const char **args) { ICM->callcmd3(getDeviceId(), kxymotor_move_to, atoi(args[0]), atoi(args[1]), atoi(args[2])); });
box->newFunc("直接控制电机相对移动", {"motor1_dpos", "motor2_dpos"}, [this](int argn, const char **args) { ICM->callcmd3(getDeviceId(), kxymotor_motor_move_by_direct, atoi(args[0]), atoi(args[1])); });
box->newFunc("读取全部输入IO", {}, [this](int argn, const char **args) {
int32_t portState = 0;
int32_t indexInStm32 = 0;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 4; i++) {
try {
ICM->callcmd1(getDeviceId(), kxymotor_read_inio_index_in_stm32, i);
indexInStm32 = ICM->getAck(0);
@ -65,7 +74,18 @@ void XYRobotTab::construct(QTabWidget *fathertab) {
portState = ICM->getAck(0);
if (indexInStm32 == 0) continue;
ZQUI::ins()->ishow("io%d(%s):%d", i, stm32pin2str((Pin_t)indexInStm32).c_str(), portState);
const char *tag = "x-zero";
if (i == 0) {
tag = "x-zero";
} else if (i == 1) {
tag = "y-zero";
} else if (i == 2) {
tag = "x-limit";
} else if (i == 3) {
tag = "y-limit";
}
ZQUI::ins()->ishow("%s (%s):%d", tag, stm32pin2str((Pin_t)indexInStm32).c_str(), portState);
} catch (const std::exception &e) {
break;
}

Loading…
Cancel
Save