diff --git a/commands.cpp b/commands.cpp
index 45d79c68b..f176f9f78 100755
--- a/commands.cpp
+++ b/commands.cpp
@@ -284,6 +284,7 @@ void Commands::processPacket(QByteArray data)
quint8 status = vb.vbPopFrontUint8();
values.has_timeout = status & 1;
values.kill_sw_active = (status >> 1) & 1;
+ values.motor_disabled = (status >> 2) & 1;
}
}
@@ -1509,6 +1510,14 @@ void Commands::shutdown()
emitData(vb);
}
+void Commands::disableMotor(bool disable)
+{
+ VByteArray vb;
+ vb.vbAppendInt8(COMM_DISABLE);
+ vb.vbAppendInt8(disable ? 1 : 0);
+ emitData(vb);
+}
+
void Commands::sendAlive()
{
VByteArray vb;
diff --git a/commands.h b/commands.h
index ff21cb23a..6af9ec71c 100644
--- a/commands.h
+++ b/commands.h
@@ -204,6 +204,7 @@ public slots:
void detectMotorParam(double current, double min_rpm, double low_duty);
void reboot();
void shutdown();
+ void disableMotor(bool disable);
void sendAlive();
void getDecodedPpm();
void getDecodedAdc();
diff --git a/datatypes.h b/datatypes.h
index 97064fcb0..62b4e1221 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -188,6 +188,7 @@ struct MC_VALUES {
Q_PROPERTY(double vq MEMBER vq)
Q_PROPERTY(bool has_timeout MEMBER has_timeout)
Q_PROPERTY(bool kill_sw_active MEMBER kill_sw_active)
+ Q_PROPERTY(bool motor_disabled MEMBER motor_disabled)
public:
MC_VALUES() {
@@ -216,6 +217,7 @@ struct MC_VALUES {
vq = 0.0;
has_timeout = false;
kill_sw_active = false;
+ motor_disabled = false;
}
bool operator==(const MC_VALUES &other) const {
@@ -254,6 +256,7 @@ struct MC_VALUES {
double vq;
bool has_timeout;
bool kill_sw_active;
+ bool motor_disabled;
};
Q_DECLARE_METATYPE(MC_VALUES)
@@ -1038,6 +1041,8 @@ typedef enum {
COMM_CAN_UPDATE_BAUD_ALL = 158,
COMM_MOTOR_ESTOP = 159,
+
+ COMM_DISABLE = 160,
} COMM_PACKET_ID;
// CAN commands
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6a9f762e7..1b00d0f25 100755
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -220,6 +220,7 @@ MainWindow::MainWindow(QWidget *parent) :
mPreferences->setVesc(mVesc);
mStatusInfoTime = 0;
+ mMotorDisabledNow = false;
mStatusLabel = new QLabel(this);
ui->statusBar->addPermanentWidget(mStatusLabel);
mDebugTimer = new QTimer(this);
@@ -796,8 +797,11 @@ void MainWindow::timerSlot()
}
} else {
QString str = mVesc->getConnectedPortName();
+ if (mMotorDisabledNow && mVesc->isPortConnected()) {
+ str += tr(" | MOTOR DISABLED");
+ }
if (str != mStatusLabel->text()) {
- mStatusLabel->setText(mVesc->getConnectedPortName());
+ mStatusLabel->setText(str);
static QString statusLast = "";
if (str != statusLast) {
mPageDebugPrint->printConsole("Status: " + str + "
");
@@ -1075,6 +1079,7 @@ void MainWindow::valuesReceived(MC_VALUES values, unsigned int mask)
(void)mask;
ui->dispCurrent->setVal(values.current_motor);
ui->dispDuty->setVal(values.duty_now * 100.0);
+ mMotorDisabledNow = values.motor_disabled;
}
void MainWindow::paramChangedDouble(QObject *src, QString name, double newParam)
@@ -1118,6 +1123,25 @@ void MainWindow::on_actionShutdown_triggered()
mVesc->commands()->shutdown();
}
+void MainWindow::on_actionMotorDisable_triggered()
+{
+ QMessageBox::StandardButton answer = QMessageBox::question(
+ this,
+ tr("Disable Motor"),
+ tr("This will disable the motor until it is enabled again. Continue?"),
+ QMessageBox::Yes | QMessageBox::Cancel
+ );
+
+ if (answer == QMessageBox::Yes) {
+ mVesc->commands()->disableMotor(true);
+ }
+}
+
+void MainWindow::on_actionMotorEnable_triggered()
+{
+ mVesc->commands()->disableMotor(false);
+}
+
void MainWindow::on_stopButton_clicked()
{
mVesc->commands()->setCurrent(0);
diff --git a/mainwindow.h b/mainwindow.h
index efd3c8e15..64f0f60a6 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -104,6 +104,8 @@ private slots:
void on_actionDisconnect_triggered();
void on_actionReboot_triggered();
void on_actionShutdown_triggered();
+ void on_actionMotorDisable_triggered();
+ void on_actionMotorEnable_triggered();
void on_stopButton_clicked();
void on_fullBrakeButton_clicked();
void on_actionReadMcconf_triggered();
@@ -177,6 +179,7 @@ private slots:
QTimer *mTimer;
QLabel *mStatusLabel;
int mStatusInfoTime;
+ bool mMotorDisabledNow;
bool mKeyLeft;
bool mKeyRight;
bool mMcConfRead;
diff --git a/mainwindow.ui b/mainwindow.ui
index 3478322d9..dccc71b60 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -673,6 +673,10 @@
+
+
+
+