diff --git a/src/atcore.h b/src/atcore.h --- a/src/atcore.h +++ b/src/atcore.h @@ -334,6 +334,12 @@ */ void setRelativePosition(); + /** + * @brief Disables idle hold of motors after a delay + * @param delay: Seconds until idle hold is released. 0= No delay + */ + void setIdleHold(uint delay = 0); + /** * @brief set the Printers speed * @param speed: speed in % (default is 100); diff --git a/src/atcore.cpp b/src/atcore.cpp --- a/src/atcore.cpp +++ b/src/atcore.cpp @@ -615,3 +615,12 @@ { return serial()->validBaudRates(); } + +void AtCore::setIdleHold(uint delay) +{ + if (delay != 0) { + pushCommand(GCode::toCommand(GCode::M84, QString::number(delay))); + } else { + pushCommand(GCode::toCommand(GCode::M84)); + } +} diff --git a/src/gcodecommands.cpp b/src/gcodecommands.cpp --- a/src/gcodecommands.cpp +++ b/src/gcodecommands.cpp @@ -509,6 +509,13 @@ { switch (gcode) { + case M84: { + if (!value1.isEmpty()) { + return QStringLiteral("M84 S%1").arg(value1); + } else { + return QStringLiteral("M84"); + } + } case M104: { if (!value2.isEmpty()) { return QStringLiteral("M104 P%1 S%2").arg(value1).arg(value2); diff --git a/testclient/mainwindow.h b/testclient/mainwindow.h --- a/testclient/mainwindow.h +++ b/testclient/mainwindow.h @@ -146,6 +146,11 @@ */ void flowRatePBClicked(); + /** + * @brief disableMotorsPB has been clicked + */ + void disableMotorsPBClicked(); + /** * @brief printerStateChanged Catch and proccess printer state commands * @param state: new printer state diff --git a/testclient/mainwindow.cpp b/testclient/mainwindow.cpp --- a/testclient/mainwindow.cpp +++ b/testclient/mainwindow.cpp @@ -94,6 +94,7 @@ connect(ui->flowRatePB, &QPushButton::clicked, this, &MainWindow::flowRatePBClicked); connect(ui->showMessagePB, &QPushButton::clicked, this, &MainWindow::showMessage); connect(ui->pluginCB, &QComboBox::currentTextChanged, this, &MainWindow::pluginCBChanged); + connect(ui->disableMotorsPB, &QPushButton::clicked, this, &MainWindow::disableMotorsPBClicked); connect(core, &AtCore::stateChanged, this, &MainWindow::printerStateChanged); connect(this, &MainWindow::printFile, core, &AtCore::print); connect(ui->stopPB, &QPushButton::clicked, core, &AtCore::stop); @@ -572,3 +573,8 @@ core->pushCommand(GCode::toCommand(GCode::G1, QStringLiteral("%1%2").arg(axis, QString::number(value)))); core->setAbsolutePosition(); } + +void MainWindow::disableMotorsPBClicked() +{ + core->setIdleHold(0); +} diff --git a/testclient/mainwindow.ui b/testclient/mainwindow.ui --- a/testclient/mainwindow.ui +++ b/testclient/mainwindow.ui @@ -744,6 +744,13 @@ + + + + Disable Motors + + + diff --git a/unittests/gcodetests.h b/unittests/gcodetests.h --- a/unittests/gcodetests.h +++ b/unittests/gcodetests.h @@ -59,6 +59,7 @@ void string_G161(); void string_G162(); + void command_M84(); void command_M104(); void command_M105(); void command_M106(); diff --git a/unittests/gcodetests.cpp b/unittests/gcodetests.cpp --- a/unittests/gcodetests.cpp +++ b/unittests/gcodetests.cpp @@ -183,6 +183,12 @@ QVERIFY(GCode::toString(GCode::G162) == QObject::tr("G162: Home axis to maximum")); } +void GCodeTests::command_M84() +{ + QVERIFY(GCode::toCommand(GCode::M84) == QStringLiteral("M84")); + QVERIFY(GCode::toCommand(GCode::M84, QStringLiteral("10")) == QStringLiteral("M84 S10")); +} + void GCodeTests::command_M104() { QVERIFY(GCode::toCommand(GCode::M104) == QStringLiteral("ERROR! M104: It's obligatory to have an argument"));