diff --git a/mainwindow.cpp b/mainwindow.cpp index 366ff0d..7fb3dc6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -34,15 +34,18 @@ MainWindow::MainWindow(QWidget *parent) : checkingTemperature = settings.value("core/checktemperature").toBool(); ui->checktemp->setChecked(checkingTemperature); + if(!firstrun) echo = settings.value("core/echo").toBool(); + else echo = false; + sending = false; paused = false; - commandDone = false; injectingCommand = false; readingFiles = false; sdprinting = false; sdBytes = 0; userCommand = ""; currentLine = 0; + readyRecieve = 0; serialupdate(); @@ -143,13 +146,10 @@ bool MainWindow::sendLine(QString line) { if(printer.write(line.toUtf8()+'\n')) { - printMsg(line + '\n'); + if(echo) printMsg(line + '\n'); return true; } - else - { - return false; - } + else return false; } else return false; @@ -208,7 +208,6 @@ void MainWindow::serialconnect() ui->progressBar->setValue(0); ui->controlBox->setDisabled(false); ui->consoleGroup->setDisabled(false); - commandDone = true; if(checkingTemperature) injectCommand("M105"); } } @@ -380,7 +379,8 @@ void MainWindow::readSerial() } } - if(data.startsWith("ok") || data.startsWith("wait")) commandDone = true; //Can send next command + if(data.startsWith("ok")) readyRecieve++; + else if(data.startsWith("wait")) readyRecieve = 1; else if(checkingTemperature && data.startsWith("T:")) { QFuture parseThread = QtConcurrent::run(this, &MainWindow::parseStatus, data); @@ -393,7 +393,7 @@ void MainWindow::readSerial() if(currentLine < 0) currentLine = 0; } else if(data.startsWith("Done")) sdprinting = false; - else if(data.startsWith("SD printing byte")) + else if(data.startsWith("SD printing byte") && sdWatcher.isFinished()) { QFuture parseSDThread = QtConcurrent::run(this, &MainWindow::parseSDStatus, data); sdWatcher.setFuture(parseSDThread); @@ -465,14 +465,14 @@ void MainWindow::on_sendBtn_clicked() void MainWindow::sendNext() { - if(injectingCommand && printer.isWritable() && commandDone) + if(injectingCommand && printer.isWritable() && readyRecieve > 0) { sendLine(userCommand); - commandDone=false; + readyRecieve--; injectingCommand=false; return; } - else if(sending && !paused && commandDone && !sdprinting && printer.isWritable()) + else if(sending && !paused && readyRecieve > 0 && !sdprinting && printer.isWritable()) { if(currentLine >= gcode.size()) //check if we are at the end of array { @@ -485,7 +485,7 @@ void MainWindow::sendNext() } sendLine(gcode.at(currentLine)); currentLine++; - commandDone = false; + readyRecieve--; ui->filelines->setText(QString::number(gcode.size()) + QString("/") + QString::number(currentLine) + QString(" Lines")); ui->progressBar->setValue(((float)currentLine/gcode.size()) * 100); diff --git a/mainwindow.h b/mainwindow.h index 5448555..9818826 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -58,12 +58,13 @@ private: bool firstrun; bool sending; bool paused; - bool commandDone; bool checkingTemperature; bool injectingCommand; bool readingFiles; bool sdprinting; + bool echo; int currentLine; + int readyRecieve; double sdBytes; QString userCommand; diff --git a/settingswindow.cpp b/settingswindow.cpp index caf176a..9e96c95 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -10,6 +10,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : if(!settings.value("core/firstrun").toBool()) ui->senderbox->setValue(4); else ui->senderbox->setValue(settings.value("core/senderinterval").toFloat()); + if(!settings.value("core/firstrun").toBool()) ui->echobox->setChecked(false); + else ui->echobox->setChecked(settings.value("core/echo").toBool()); + if(settings.value("core/statusinterval").toInt()) ui->statusbox->setValue(settings.value("core/statusinterval").toInt()); else ui->statusbox->setValue(1500); @@ -32,4 +35,5 @@ void SettingsWindow::on_buttonBox_accepted() settings.setValue("core/statusinterval", ui->statusbox->value()); settings.setValue("printer/bedy", ui->bedybox->value()); settings.setValue("printer/bedx", ui->bedxbox->value()); + settings.setValue("core/echo", ui->echobox->isChecked()); } diff --git a/settingswindow.ui b/settingswindow.ui index c9624b7..fc381de 100644 --- a/settingswindow.ui +++ b/settingswindow.ui @@ -29,17 +29,17 @@ QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + 10 10 - 201 - 96 + 171 + 123 - Intervals + Internal @@ -49,6 +49,28 @@ + + + + A good default is 2, lower = fater, higher = less CPU load. 0 would execute as soon as possible. + + + -1 + + + + + + 0.000000000000000 + + + 999.990000000000009 + + + 0.100000000000000 + + + @@ -86,25 +108,10 @@ - - - - A good default is 2, lower = fater, higher = less CPU load. 0 would execute as soon as possible. - - - -1 - - - - - - 0.000000000000000 - - - 999.990000000000009 - - - 0.100000000000000 + + + + Echo commands @@ -114,7 +121,7 @@ 10 - 110 + 130 201 66