From b223169932aaa30f6c640a82c14ce046e5f41924 Mon Sep 17 00:00:00 2001 From: Patrick Felixberger Date: Sun, 7 Feb 2021 14:26:26 +0100 Subject: [PATCH] Add support for G33/G76 --- Readme.md | 4 ++-- src/frmmain.cpp | 8 +++++--- src/parser/gcodeparser.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 75e5dda..c7dadf7 100644 --- a/Readme.md +++ b/Readme.md @@ -24,8 +24,8 @@ Linux: QT 5.12.2 with GCC Downloads: ---------- -* Windows: [Candle_2.1.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.1/Candle2.1.zip) -* Linux: [Candle_2.1_linux.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.1/Candle2.1_linux.zip) +* Windows: [Candle_2.2.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.1/Candle2.2.zip) +* Linux: [Candle_2.2_Linux.zip](https://github.com/Schildkroet/Candle2/releases/download/V2.1/Candle2.2_Linux.zip) Candle 2 GUI diff --git a/src/frmmain.cpp b/src/frmmain.cpp index b5d8e46..7a00402 100644 --- a/src/frmmain.cpp +++ b/src/frmmain.cpp @@ -718,7 +718,7 @@ void frmMain::onProcessData() break; } - if(m_serialHandWheel.isOpen() && m_serialHandWheel.canReadLine() && m_transferCompleted) + if(m_serialHandWheel.isOpen() && SerialIf_IsOpen() && m_serialHandWheel.canReadLine() && m_transferCompleted) { QString msg = m_serialHandWheel.readLine(); //qDebug() << "HW: " << msg; @@ -801,6 +801,8 @@ void frmMain::onSendSerial() void frmMain::onTimerUpdateSpindleParser() { + static bool updateSpinde = false; + if (SerialIf_IsOpen() && !m_homing && !ui->cmdFilePause->isChecked() && mCommandsWait.size() == 0) { if (m_updateSpindleSpeed) @@ -808,8 +810,8 @@ void frmMain::onTimerUpdateSpindleParser() m_updateSpindleSpeed = false; sendCommand(QString("S%1").arg(ui->slbSpindle->value()), -2, m_settings->showUICommands()); } - - if (m_updateParserStatus) + updateSpinde = !updateSpinde; + if (m_updateParserStatus || updateSpinde) { m_updateParserStatus = false; sendCommand("$G", -3, false); diff --git a/src/parser/gcodeparser.cpp b/src/parser/gcodeparser.cpp index 1879464..6645fcd 100644 --- a/src/parser/gcodeparser.cpp +++ b/src/parser/gcodeparser.cpp @@ -407,6 +407,7 @@ PointSegment * GcodeParser::handleGCode(float code, const QStringList &args) else if (code == 19.0f) this->m_currentPlane = PointSegment::YZ; else if (code == 20.0f) this->m_isMetric = false; else if (code == 21.0f) this->m_isMetric = true; + else if (code == 33.0f) ps = addLinearPointSegment(nextPoint, false); else if (code == 90.0f) this->m_inAbsoluteMode = true; else if (code == 90.1f) this->m_inAbsoluteIJKMode = true; else if (code == 91.0f) this->m_inAbsoluteMode = false; @@ -414,6 +415,43 @@ PointSegment * GcodeParser::handleGCode(float code, const QStringList &args) else if (code == 98.0f) this->m_retractOldZ = true; else if (code == 99.0f) this->m_retractOldZ = false; + else if (code == 76.0f) + { + // Currently only display the final cut + QVector3D dl_start(m_currentPoint); + QVector3D dl_end(m_currentPoint); + dl_end.setZ(nextPoint.z()); + char c; + double p = qQNaN(); + double j = qQNaN(); + double k = qQNaN(); + + for (int i = 0; i < args.length(); i++) { + if (args.at(i).length() > 0) { + c = args.at(i).at(0).toUpper().toLatin1(); + switch (c) { + case 'I': + p = args.at(i).mid(1).toDouble(); + break; + case 'J': + j = args.at(i).mid(1).toDouble(); + break; + case 'K': + k = args.at(i).mid(1).toDouble(); + break; + } + } + } + + float fin_depth = m_currentPoint.x() + p - k; + + dl_start.setX(fin_depth); + addLinearPointSegment(dl_start, true); + dl_start.setZ(dl_end.z()); + addLinearPointSegment(dl_start, false); + ps = addLinearPointSegment(dl_end, true); + } + else if (code == 81.0f || code == 82.0f || code == 83.0f) { // New point at X/Y