From a691152201906ca38d7448a6c76fc3be1496c608 Mon Sep 17 00:00:00 2001 From: pablozg Date: Sun, 12 Mar 2017 21:16:58 +0100 Subject: [PATCH 1/3] Added Probe Height offset --- src/frmmain.cpp | 15 ++++-- src/frmmain.ui | 18 +++---- src/frmsettings.cpp | 14 +++++- src/frmsettings.h | 4 ++ src/frmsettings.ui | 115 ++++++++++++++++++++++++++------------------ 5 files changed, 106 insertions(+), 60 deletions(-) diff --git a/src/frmmain.cpp b/src/frmmain.cpp index c290257e..f54f5a1a 100644 --- a/src/frmmain.cpp +++ b/src/frmmain.cpp @@ -300,6 +300,7 @@ bool frmMain::isGCodeFile(QString fileName) || fileName.endsWith(".nc", Qt::CaseInsensitive) || fileName.endsWith(".ncc", Qt::CaseInsensitive) || fileName.endsWith(".ngc", Qt::CaseInsensitive) + || fileName.endsWith(".gcode", Qt::CaseInsensitive) || fileName.endsWith(".tap", Qt::CaseInsensitive); } @@ -363,6 +364,7 @@ void frmMain::loadSettings() m_settings->setLaserPowerMax(set.value("laserPowerMax", 100).toInt()); m_settings->setRapidSpeed(set.value("rapidSpeed", 0).toInt()); m_settings->setHeightmapProbingFeed(set.value("heightmapProbingFeed", 0).toInt()); + m_settings->setHeightmapProbeHeight(set.value("heightmapProbeHeight", 0).toDouble()); m_settings->setAcceleration(set.value("acceleration", 10).toInt()); m_settings->setToolAngle(set.value("toolAngle", 0).toDouble()); m_settings->setToolType(set.value("toolType", 0).toInt()); @@ -516,6 +518,7 @@ void frmMain::saveSettings() set.setValue("restoreMode", m_settings->restoreMode()); set.setValue("rapidSpeed", m_settings->rapidSpeed()); set.setValue("heightmapProbingFeed", m_settings->heightmapProbingFeed()); + set.setValue("heightmapProbeHeight", m_settings->heightmapProbeHeight()); set.setValue("acceleration", m_settings->acceleration()); set.setValue("toolAngle", m_settings->toolAngle()); set.setValue("toolType", m_settings->toolType()); @@ -1173,6 +1176,7 @@ void frmMain::onSerialPortReadyRead() // "[PRB:0.000,0.000,0.000:0];ok" QRegExp rx(".*PRB:([^,]*),([^,]*),([^]^:]*)"); double z = qQNaN(); + if (rx.indexIn(response) != -1) { qDebug() << "probing coordinates:" << rx.cap(1) << rx.cap(2) << rx.cap(3); z = toMetric(rx.cap(3).toDouble()); @@ -1609,7 +1613,7 @@ void frmMain::on_cmdFileOpen_clicked() if (!saveChanges(false)) return; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), m_lastFolder, - tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt);;All files (*.*)")); + tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;All files (*.*)")); if (!fileName.isEmpty()) m_lastFolder = fileName.left(fileName.lastIndexOf(QRegExp("[/\\\\]+"))); @@ -2618,7 +2622,7 @@ bool frmMain::saveProgramToFile(QString fileName, GCodeTableModel *model) void frmMain::on_actFileSaveTransformedAs_triggered() { - QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt)"))); + QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)"))); if (!fileName.isEmpty()) { saveProgramToFile(fileName, &m_programHeightmapModel); @@ -2628,7 +2632,7 @@ void frmMain::on_actFileSaveTransformedAs_triggered() void frmMain::on_actFileSaveAs_triggered() { if (!m_heightMapMode) { - QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt)"))); + QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)"))); if (!fileName.isEmpty()) if (saveProgramToFile(fileName, &m_programModel)) { m_programFileName = fileName; @@ -3151,6 +3155,7 @@ bool frmMain::updateHeightMapGrid() // Generate probe program double gridStepX = gridPointsX > 1 ? borderRect.width() / (gridPointsX - 1) : 0; double gridStepY = gridPointsY > 1 ? borderRect.height() / (gridPointsY - 1) : 0; + double zoffset = m_settings->heightmapProbeHeight(); qDebug() << "generating probe program"; @@ -3164,6 +3169,8 @@ bool frmMain::updateHeightMapGrid() // .arg(ui->txtHeightMapGridZTop->value())); m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G38.2Z%1") .arg(ui->txtHeightMapGridZBottom->value())); + m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G92Z%1") // Set Z to Probe Height + .arg(zoffset)); m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G0Z%1") .arg(ui->txtHeightMapGridZTop->value())); @@ -3182,6 +3189,8 @@ bool frmMain::updateHeightMapGrid() } } + m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G0X0Y0")); // Return to Point of Origin + m_programLoading = false; if (m_currentDrawer == m_probeDrawer) updateParser(); diff --git a/src/frmmain.ui b/src/frmmain.ui index 81c8305a..1e77f344 100644 --- a/src/frmmain.ui +++ b/src/frmmain.ui @@ -664,7 +664,7 @@ QSlider::handle:horizontal:hover { 999.000000000000000 - 1.000000000000000 + 5.000000000000000 @@ -692,7 +692,7 @@ QSlider::handle:horizontal:hover { 999.000000000000000 - -1.000000000000000 + -10.000000000000000 @@ -822,10 +822,10 @@ QSlider::handle:horizontal:hover { QAbstractSpinBox::NoButtons - 0 + 2 - 2.000000000000000 + 0.100000000000000 1000.000000000000000 @@ -853,10 +853,10 @@ QSlider::handle:horizontal:hover { QAbstractSpinBox::NoButtons - 0 + 2 - 2.000000000000000 + 0.100000000000000 1000.000000000000000 @@ -1540,9 +1540,9 @@ QSlider::handle:horizontal:hover { 0 - -416 + 0 228 - 691 + 658 @@ -2616,7 +2616,7 @@ padding-right: 8; 0 0 952 - 26 + 21 diff --git a/src/frmsettings.cpp b/src/frmsettings.cpp index cdc87371..6d6cf541 100644 --- a/src/frmsettings.cpp +++ b/src/frmsettings.cpp @@ -330,6 +330,17 @@ void frmSettings::setHeightmapProbingFeed(int heightmapProbingFeed) ui->txtHeightMapProbingFeed->setValue(heightmapProbingFeed); } +double frmSettings::heightmapProbeHeight() +{ + return ui->txtHeightMapProbeHeight->value(); +} + +void frmSettings::setHeightmapProbeHeight(double heightmapProbeHeight) +{ + ui->txtHeightMapProbeHeight->setValue(heightmapProbeHeight); +} + + int frmSettings::acceleration() { return ui->txtAcceleration->value(); @@ -638,11 +649,12 @@ void frmSettings::on_cmdDefaults_clicked() setSpindleSpeedMax(10000); setLaserPowerMin(0); setLaserPowerMax(100); - setTouchCommand("G21G91G38.2Z-30F100; G0Z1; G38.2Z-2F10"); + setTouchCommand("G21G91G38.2Z-30F100; G0Z1; G38.2Z-2F1; G92Z0(change Z0 by your probe Height and delete this text); G1Z5F200"); setSafePositionCommand("G21G90; G53G0Z0"); setMoveOnRestore(false); setRestoreMode(0); setHeightmapProbingFeed(10); + setHeightmapProbeHeight(1.55); setUnits(0); setArcLength(0.0); diff --git a/src/frmsettings.h b/src/frmsettings.h index fc44eb81..9978a383 100644 --- a/src/frmsettings.h +++ b/src/frmsettings.h @@ -67,6 +67,8 @@ class frmSettings : public QDialog void setRapidSpeed(int rapidSpeed); int heightmapProbingFeed(); void setHeightmapProbingFeed(int heightmapProbingFeed); + double heightmapProbeHeight(); + void setHeightmapProbeHeight(double heightmapProbeHeight); int acceleration(); void setAcceleration(int acceleration); int queryStateTime(); @@ -142,6 +144,8 @@ private slots: void on_radGrayscaleZ_toggled(bool checked); + void on_chkGrayscale_clicked(); + private: Ui::frmSettings *ui; void searchPorts(); diff --git a/src/frmsettings.ui b/src/frmsettings.ui index d7b6d39d..82372969 100644 --- a/src/frmsettings.ui +++ b/src/frmsettings.ui @@ -6,8 +6,8 @@ 0 0 - 555 - 715 + 557 + 755 @@ -71,9 +71,9 @@ QGroupBox { 0 - 0 - 436 - 1749 + -376 + 391 + 1529 @@ -640,48 +640,69 @@ QGroupBox { Heightmap - - - - - - - Heightmap probing feed: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 9 - - - - Qt::AlignCenter - - - QAbstractSpinBox::NoButtons - - - 99999 - - - - + + + + + Heightmap probing feed: + + + + + + + + 9 + + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + 99999 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 28 + 20 + + + + + + + + Probe Height: + + + + + + + + 9 + + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + From 6b1a36207b77adb0ec7775282d56f0d2cb0cd661 Mon Sep 17 00:00:00 2001 From: pablozg Date: Sun, 12 Mar 2017 21:27:12 +0100 Subject: [PATCH 2/3] typo mismatch --- src/frmmain.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frmmain.ui b/src/frmmain.ui index 1e77f344..6dc5d52f 100644 --- a/src/frmmain.ui +++ b/src/frmmain.ui @@ -822,10 +822,10 @@ QSlider::handle:horizontal:hover { QAbstractSpinBox::NoButtons - 2 + 0 - 0.100000000000000 + 2.000000000000000 1000.000000000000000 @@ -853,10 +853,10 @@ QSlider::handle:horizontal:hover { QAbstractSpinBox::NoButtons - 2 + 0 - 0.100000000000000 + 2.000000000000000 1000.000000000000000 From 5505cc39f8f98bf69d58afec60a96202f7666fe1 Mon Sep 17 00:00:00 2001 From: pablozg Date: Fri, 17 Mar 2017 13:18:34 +0100 Subject: [PATCH 3/3] Add files via upload Added Laser mode switch and use probe height switch, you can choice between use or not the probe height while make height map. --- src/frmmain.cpp | 42 +++++++++++++++++++++++++++++++++++++--- src/frmmain.h | 4 ++++ src/frmmain.ui | 51 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 92 insertions(+), 5 deletions(-) diff --git a/src/frmmain.cpp b/src/frmmain.cpp index f54f5a1a..b06d13de 100644 --- a/src/frmmain.cpp +++ b/src/frmmain.cpp @@ -455,6 +455,9 @@ void frmMain::loadSettings() ui->cboHeightMapInterpolationType->setCurrentIndex(set.value("heightmapInterpolationType", 0).toInt()); ui->chkHeightMapInterpolationShow->setChecked(set.value("heightmapInterpolationShow", false).toBool()); + ui->chkLaserMode->setChecked(set.value("laserMode", false).toBool()); + ui->chkUseProbeHeight->setChecked(set.value("useProbeHeight", false).toBool()); + foreach (ColorPicker* pick, m_settings->colors()) { pick->setColor(QColor(set.value(pick->objectName().mid(3), "black").toString())); } @@ -587,6 +590,9 @@ void frmMain::saveSettings() set.setValue("heightmapInterpolationType", ui->cboHeightMapInterpolationType->currentIndex()); set.setValue("heightmapInterpolationShow", ui->chkHeightMapInterpolationShow->isChecked()); + set.setValue("laserMode", ui->chkLaserMode->isChecked()); + set.setValue("useProbeHeight", ui->chkUseProbeHeight->isChecked()); + foreach (ColorPicker* pick, m_settings->colors()) { set.setValue(pick->objectName().mid(3), pick->color().name()); } @@ -726,7 +732,12 @@ void frmMain::updateControlsState() { ui->cmdFileSend->menu()->actions().first()->setEnabled(!ui->cmdHeightMapMode->isChecked()); - m_selectionDrawer.setVisible(!ui->cmdHeightMapMode->isChecked()); + m_selectionDrawer.setVisible(!ui->cmdHeightMapMode->isChecked()); + + if (ui->cmdHeightMapMode->isChecked()) ui->chkUseProbeHeight->setVisible(true); + else{ + ui->chkUseProbeHeight->setVisible(false); + } } void frmMain::openPort() @@ -3169,8 +3180,20 @@ bool frmMain::updateHeightMapGrid() // .arg(ui->txtHeightMapGridZTop->value())); m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G38.2Z%1") .arg(ui->txtHeightMapGridZBottom->value())); - m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G92Z%1") // Set Z to Probe Height - .arg(zoffset)); + + if (ui->chkUseProbeHeight->isChecked()) + { + // Check if we have to set Z probe offset for non conductive materials + m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G92Z%1") // Set Z to Probe Height + .arg(zoffset)); + qDebug() << "Setting Z to Probe Height " << zoffset; + + }else + { + m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G92Z0")); // Set Z as 0 + qDebug() << "Setting Z to 0 as origin point"; + } + m_probeModel.setData(m_probeModel.index(m_probeModel.rowCount() - 1, 1), QString("G0Z%1") .arg(ui->txtHeightMapGridZTop->value())); @@ -3986,3 +4009,16 @@ void frmMain::on_cmdStop_clicked() m_queue.clear(); m_serialPort.write(QByteArray(1, char(0x85))); } + +void frmMain::on_chkLaserMode_toggled(bool checked) +{ + if(ui->chkLaserMode->isChecked()) + { + sendCommand("$32=1",-1,1); + }else + { + sendCommand("$32=0",-1,1); + } + + updateControlsState(); +} diff --git a/src/frmmain.h b/src/frmmain.h index a6b8ff81..77b7c143 100644 --- a/src/frmmain.h +++ b/src/frmmain.h @@ -193,6 +193,10 @@ private slots: void on_cmdStop_clicked(); + void on_chkLaserMode_clicked(); + + void on_chkLaserMode_toggled(bool checked); + protected: void showEvent(QShowEvent *se); void hideEvent(QHideEvent *he); diff --git a/src/frmmain.ui b/src/frmmain.ui index 6dc5d52f..b320d482 100644 --- a/src/frmmain.ui +++ b/src/frmmain.ui @@ -966,6 +966,31 @@ QSlider::handle:horizontal:hover { + + + + true + + + + 0 + 0 + + + + + 22 + 0 + + + + Use Probe Height + + + false + + + @@ -1540,9 +1565,9 @@ QSlider::handle:horizontal:hover { 0 - 0 + -416 228 - 658 + 685 @@ -2463,11 +2488,33 @@ QSlider::handle:horizontal:hover { + + + 0 + 0 + + Keyboard control + + + + true + + + + 0 + 0 + + + + Laser Mode + + +