Skip to content

Commit

Permalink
Added Shutdown command to Terminal menu
Browse files Browse the repository at this point in the history
VESCs with auto-shutdown support can now be powered down via VESC Tool/App

Signed-off-by: Dado Mista <[email protected]>
  • Loading branch information
surfdado committed Jan 14, 2024
1 parent d1cafe3 commit 0b8d209
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,15 @@ void Commands::reboot()
emitData(vb);
}

void Commands::shutdown()
{
VByteArray vb;
vb.vbAppendInt8(COMM_SHUTDOWN);
vb.vbAppendInt8(0);
vb.vbAppendInt8(0);
emitData(vb);
}

void Commands::sendAlive()
{
VByteArray vb;
Expand Down
1 change: 1 addition & 0 deletions commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public slots:
void setAppConfNoStore();
void detectMotorParam(double current, double min_rpm, double low_duty);
void reboot();
void shutdown();
void sendAlive();
void getDecodedPpm();
void getDecodedAdc();
Expand Down
6 changes: 6 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionClearConfigurationBackups->setIcon(Utility::getIcon("icons/Delete-96.png"));
ui->actionBackupConfiguration->setIcon(Utility::getIcon("icons/Save as-96.png"));
ui->actionReboot->setIcon(Utility::getIcon("icons/Refresh-96.png"));
ui->actionShutdown->setIcon(Utility::getIcon("icons/Shutdown-96.png"));
ui->actionExit->setIcon(Utility::getIcon("icons/Shutdown-96.png"));
ui->pageLabel->setPixmap(Utility::getIcon("logo.png"));
ui->actionReconnect->setIcon(Utility::getIcon("icons/Connected-96.png"));
Expand Down Expand Up @@ -1050,6 +1051,11 @@ void MainWindow::on_actionReboot_triggered()
mVesc->commands()->reboot();
}

void MainWindow::on_actionShutdown_triggered()
{
mVesc->commands()->shutdown();
}

void MainWindow::on_stopButton_clicked()
{
mVesc->commands()->setCurrent(0);
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private slots:
void on_actionReconnect_triggered();
void on_actionDisconnect_triggered();
void on_actionReboot_triggered();
void on_actionShutdown_triggered();
void on_stopButton_clicked();
void on_fullBrakeButton_clicked();
void on_actionReadMcconf_triggered();
Expand Down
11 changes: 10 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@
<addaction name="actionTerminalClear"/>
<addaction name="separator"/>
<addaction name="actionReboot"/>
<addaction name="actionShutdown"/>
</widget>
<widget class="QMenu" name="menuCommands">
<property name="font">
Expand Down Expand Up @@ -756,7 +757,15 @@
<string>Reboot</string>
</property>
<property name="toolTip">
<string>Reboot</string>
<string>Reboot via CPU reset</string>
</property>
</action>
<action name="actionShutdown">
<property name="text">
<string>Shutdown</string>
</property>
<property name="toolTip">
<string>Shutdown (for controllers with auto-shutdown support only)</string>
</property>
</action>
<action name="actionCanFwd">
Expand Down
7 changes: 7 additions & 0 deletions mobile/Terminal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ Item {
}
}
}
MenuItem {
text: "Reboot"
onTriggered: {
mCommands.shutdown()
}
}
}
}
}

Expand Down

0 comments on commit 0b8d209

Please sign in to comment.