|
|
@ -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; |
|
|
|
} |
|
|
|