9 changed files with 192 additions and 40 deletions
-
2CMakeLists.txt
-
24README.md
-
2a8000_protocol
-
29iflytop_canbus/iflytop_canbus_master.cpp
-
12iflytop_canbus/iflytop_canbus_master.hpp
-
2src/mainwindow.cpp
-
20src/mainwindow.ui
-
98src/tab/xyrobot_tab.cpp
-
43src/tab/xyrobot_tab.hpp
@ -1 +1 @@ |
|||
Subproject commit 6486ccf75f3e6bd05c7454ff994d8c003d908227 |
|||
Subproject commit fad4311315d63e2db871959f67a0fb5e5c07af38 |
@ -0,0 +1,98 @@ |
|||
#include "xyrobot_tab.hpp"
|
|||
|
|||
#include "iflytop_canbus/iflytop_canbus_master.hpp"
|
|||
#include "logger.hpp"
|
|||
#include "qt_serial_datachannel.hpp"
|
|||
#include "zexception.hpp"
|
|||
#include "zui/z_function_list_box.hpp"
|
|||
#include "zui/z_reg_table_list_box.hpp"
|
|||
#include "zui/zq_vtab_page.hpp"
|
|||
//
|
|||
#include "../basic/stm32_pin.hpp"
|
|||
#include "./mainwindow.h"
|
|||
#include "zui\zqui.hpp"
|
|||
//
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
extern Ui::MainWindow *main_ui; |
|||
|
|||
extern int getDeviceId(); |
|||
|
|||
XYRobotTab *XYRobotTab::inst() { |
|||
static XYRobotTab *ins = new XYRobotTab(); |
|||
return ins; |
|||
} |
|||
|
|||
static inline const char *hex2binstr(int32_t hex) { |
|||
static char buf[32]; |
|||
sprintf(buf, "%d%d%d%d_%d%d%d%d", (hex >> 7) & 1, (hex >> 6) & 1, (hex >> 5) & 1, (hex >> 4) & 1, (hex >> 3) & 1, (hex >> 2) & 1, (hex >> 1) & 1, (hex >> 0) & 1); |
|||
return buf; |
|||
} |
|||
|
|||
void XYRobotTab::construct(QTabWidget *fathertab) { |
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "XY-Robot"); |
|||
/***********************************************************************************************************************
|
|||
* 模块操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4); |
|||
|
|||
box->newFunc("使能", {}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kxymotor_enable, 1); }); |
|||
box->newFunc("失能", {}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kxymotor_enable, 0); }); |
|||
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("移动到原点", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kxymotor_move_to_zero); }); |
|||
box->newFunc("读取位置", {}, [this](int argn, const char **args) { |
|||
int32_t x, y; |
|||
ICM->callcmd0(getDeviceId(), kxymotor_read_pos); |
|||
x = ICM->getAck(0); |
|||
y = ICM->getAck(1); |
|||
ZQUI::ins()->ishow("x,y(%d,%d)", x, y); |
|||
}); |
|||
} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* 寄存器操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
ZRegTableList *tableBox = new ZRegTableList(tab, "寄存器操作"); |
|||
tableBox->initializeRegOperation( |
|||
[this](int32_t add, int32_t val) { //
|
|||
ICM->writereg(getDeviceId(), add, val); |
|||
return true; |
|||
}, |
|||
[this](int32_t add, int32_t *val) { //
|
|||
ICM->readreg(getDeviceId(), add, val); |
|||
return true; |
|||
}); |
|||
|
|||
tableBox->addReg("default_velocity", kreg_xyrobot_default_velocity, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("default_acc", kreg_xyrobot_default_acc, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("default_dec", kreg_xyrobot_default_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("default_break_dec", kreg_xyrobot_default_break_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("run_to_zero_speed", kreg_xyrobot_run_to_zero_speed, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("run_to_zero_dec", kreg_xyrobot_run_to_zero_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("look_zero_edge_speed", kreg_xyrobot_look_zero_edge_speed, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("look_zero_edge_dec", kreg_xyrobot_look_zero_edge_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("ihold", kreg_xyrobot_ihold, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("irun", kreg_xyrobot_irun, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("iholddelay", kreg_xyrobot_iholddelay, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("robot_type", kreg_xyrobot_robot_type, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("x_shift", kreg_xyrobot_x_shift, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("y_shift", kreg_xyrobot_y_shift, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("x_shaft", kreg_xyrobot_x_shaft, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("y_shaft", kreg_xyrobot_y_shaft, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("x_one_circle_pulse", kreg_xyrobot_x_one_circle_pulse, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("y_one_circle_pulse", kreg_xyrobot_y_one_circle_pulse, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("run_to_zero_max_x_d", kreg_xyrobot_run_to_zero_max_x_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("run_to_zero_max_y_d", kreg_xyrobot_run_to_zero_max_y_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("look_zero_edge_max_x_d", kreg_xyrobot_look_zero_edge_max_x_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("look_zero_edge_max_y_d", kreg_xyrobot_look_zero_edge_max_y_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("io_state0", kreg_xyrobot_io_state0, ZRegItem::krw | ZRegItem::kbinary); |
|||
|
|||
tableBox->addSpacer(); |
|||
} |
|||
|
|||
tab->addSpacer(); |
|||
} |
@ -0,0 +1,43 @@ |
|||
#pragma once
|
|||
|
|||
#include <QDateTime>
|
|||
#include <QMainWindow>
|
|||
#include <QMessageBox>
|
|||
#include <QObject>
|
|||
#include <QtConcurrent>
|
|||
#include <QtCore/QVariant>
|
|||
#include <QtSerialPort/QSerialPort>
|
|||
#include <QtSerialPort/QSerialPortInfo>
|
|||
#include <QtWidgets/QAction>
|
|||
#include <QtWidgets/QApplication>
|
|||
#include <QtWidgets/QComboBox>
|
|||
#include <QtWidgets/QFormLayout>
|
|||
#include <QtWidgets/QGridLayout>
|
|||
#include <QtWidgets/QGroupBox>
|
|||
#include <QtWidgets/QHBoxLayout>
|
|||
#include <QtWidgets/QLabel>
|
|||
#include <QtWidgets/QLineEdit>
|
|||
#include <QtWidgets/QMainWindow>
|
|||
#include <QtWidgets/QMenu>
|
|||
#include <QtWidgets/QMenuBar>
|
|||
#include <QtWidgets/QPushButton>
|
|||
#include <QtWidgets/QSpacerItem>
|
|||
#include <QtWidgets/QStatusBar>
|
|||
#include <QtWidgets/QTabWidget>
|
|||
#include <QtWidgets/QTextBrowser>
|
|||
#include <QtWidgets/QTextEdit>
|
|||
#include <QtWidgets/QVBoxLayout>
|
|||
#include <QtWidgets/QWidget>
|
|||
//
|
|||
#include <functional>
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
class XYRobotTab { |
|||
public: |
|||
static XYRobotTab *inst(); |
|||
|
|||
void construct(QTabWidget *fathertab); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue