From c174c93ed8c7975f7a9c1ddc7795d969554f0b90 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 6 Mar 2015 21:57:46 +0300 Subject: [PATCH] More settings and UI bugfixes --- mainwindow.cpp | 50 +++++++++++++++---------- mainwindow.h | 2 + mainwindow.ui | 92 ++++++++++++++++++++++++++++------------------ settingswindow.cpp | 2 + settingswindow.ui | 21 +++++++---- 5 files changed, 105 insertions(+), 62 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 7eee236..30d99ba 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -13,9 +13,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->progressBar->setValue(0); ui->controlBox->setDisabled(true); ui->consoleGroup->setDisabled(true); - ui->pauseBtn->setDisabled("true"); - ui->actionPrint_from_SD->setDisabled("true"); - ui->actionSet_SD_printing_mode->setDisabled("true"); + ui->pauseBtn->setDisabled(true); + ui->actionPrint_from_SD->setDisabled(true); + ui->actionSet_SD_printing_mode->setDisabled(true); ui->baudbox->addItem(QString::number(4800)); ui->baudbox->addItem(QString::number(9600)); @@ -45,6 +45,7 @@ MainWindow::MainWindow(QWidget *parent) : autolock = settings.value("core/lockcontrols").toBool(); sendingChecksum = settings.value("core/checksums").toBool(); + chekingSDStatus = settings.value("core/checksdstatus").toBool(); sending = false; paused = false; @@ -83,7 +84,7 @@ MainWindow::MainWindow(QWidget *parent) : sendTimer.start(); progressSDTimer.setInterval(3000); - progressSDTimer.start(); + if(chekingSDStatus)progressSDTimer.start(); tempWarning.setInterval(10000); @@ -146,6 +147,7 @@ void MainWindow::parseFile(QFile &file) { if(sendingChecksum) { + //Checksum algorithm from RepRap wiki line = "N"+QString::number(n)+line+"*"; int cs = 0; for(int i = 0; line.at(i) != '*'; i++) cs = cs ^ line.at(i).toLatin1(); @@ -160,6 +162,8 @@ void MainWindow::parseFile(QFile &file) file.close(); sdprinting = false; ui->fileBox->setEnabled(true); + ui->progressBar->setEnabled(true); + ui->sendBtn->setText("Send"); ui->filename->setText(file.fileName().split("/").last()); ui->filelines->setText(QString::number(gcode.size()) + QString("/0 lines")); } @@ -234,8 +238,8 @@ void MainWindow::serialconnect() ui->progressBar->setValue(0); ui->controlBox->setDisabled(false); ui->consoleGroup->setDisabled(false); - ui->actionPrint_from_SD->setEnabled("true"); - ui->actionSet_SD_printing_mode->setEnabled("true"); + ui->actionPrint_from_SD->setEnabled(true); + ui->actionSet_SD_printing_mode->setEnabled(true); //if(checkingTemperature) injectCommand("M105"); } } @@ -250,8 +254,8 @@ void MainWindow::serialconnect() ui->progressBar->setValue(0); ui->controlBox->setDisabled(true); ui->consoleGroup->setDisabled(true); - ui->actionPrint_from_SD->setDisabled("true"); - ui->actionSet_SD_printing_mode->setDisabled("true"); + ui->actionPrint_from_SD->setDisabled(true); + ui->actionSet_SD_printing_mode->setDisabled(true); } } @@ -483,7 +487,7 @@ void MainWindow::readSerial() sdprinting=false; ui->progressBar->setValue(0); ui->filename->setText(""); - ui->fileBox->setDisabled("true"); + ui->fileBox->setDisabled(true); } else if(data.startsWith("start") && checkingTemperature) injectCommand("M105"); else if(data.startsWith("SD pr")) @@ -531,8 +535,8 @@ void MainWindow::on_sendBtn_clicked() sending = false; ui->sendBtn->setText("Send"); ui->pauseBtn->setText("Pause"); - ui->pauseBtn->setDisabled("true"); - if(autolock) ui->controlBox->setChecked("true"); + ui->pauseBtn->setDisabled(true); + if(autolock) ui->controlBox->setChecked(true); paused = false; } else if(!sending && !sdprinting) @@ -540,8 +544,8 @@ void MainWindow::on_sendBtn_clicked() sending=true; ui->sendBtn->setText("Stop"); ui->pauseBtn->setText("Pause"); - ui->pauseBtn->setEnabled("true"); - if(autolock) ui->controlBox->setChecked("false"); + ui->pauseBtn->setEnabled(true); + if(autolock) ui->controlBox->setChecked(false); paused = false; } else if(sdprinting) @@ -551,7 +555,7 @@ void MainWindow::on_sendBtn_clicked() injectCommand("M27"); ui->sendBtn->setText("Send"); ui->pauseBtn->setText("Pause"); - if(autolock) ui->controlBox->setChecked("true"); + if(autolock) ui->controlBox->setChecked(true); paused = false; } @@ -574,7 +578,7 @@ void MainWindow::sendNext() sending = false; currentLine = 0; ui->sendBtn->setText("Send"); - ui->pauseBtn->setDisabled("true"); + ui->pauseBtn->setDisabled(true); ui->filelines->setText(QString::number(gcode.size()) + QString("/") + QString::number(currentLine) @@ -672,8 +676,8 @@ void MainWindow::serialError(QSerialPort::SerialPortError error) ui->pauseBtn->setDisabled(true); ui->controlBox->setDisabled(true); ui->consoleGroup->setDisabled(true); - ui->actionPrint_from_SD->setDisabled("true"); - ui->actionSet_SD_printing_mode->setDisabled("true"); + ui->actionPrint_from_SD->setDisabled(true); + ui->actionSet_SD_printing_mode->setDisabled(true); qDebug() << error; @@ -804,8 +808,14 @@ void MainWindow::selectSDfile(QString file) QString filename = file.remove(" "+bytes); ui->filename->setText(filename); - ui->filelines->setText(bytes + QString("/0 bytes")); - ui->progressBar->setValue(0); + if(chekingSDStatus) + { + ui->filelines->setText(bytes + QString("/0 bytes")); + ui->progressBar->setEnabled(true); + ui->progressBar->setValue(0); + } + else ui->progressBar->setDisabled(true); + ui->sendBtn->setText("Start"); sdBytes = bytes.toDouble(); userCommands.clear(); @@ -827,7 +837,7 @@ void MainWindow::updateSDStatus() void MainWindow::checkSDStatus() { - if(sdprinting && sdWatcher.isFinished()) injectCommand("M27"); + if(sdprinting && chekingSDStatus && sdWatcher.isFinished()) injectCommand("M27"); } void MainWindow::on_stepspin_valueChanged(const QString &arg1) diff --git a/mainwindow.h b/mainwindow.h index 8dc35a9..7af73be 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -37,6 +37,7 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); +protected: QFile gfile; QVector gcode; QQueue userCommands; @@ -68,6 +69,7 @@ private: bool sdprinting; bool echo; bool sendingChecksum; + bool chekingSDStatus; long int currentLine; int readyRecieve; unsigned long int sdBytes; diff --git a/mainwindow.ui b/mainwindow.ui index 8a2a589..c2ff79a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -965,6 +965,12 @@ STOP + + + 190 + 16777215 + + Status @@ -1223,8 +1229,8 @@ STOP serialupdate() - 82 - 84 + 100 + 110 247 @@ -1255,8 +1261,8 @@ STOP serialconnect() - 82 - 116 + 100 + 142 247 @@ -1271,8 +1277,8 @@ STOP xhome() - 455 - 81 + 454 + 108 383 @@ -1288,7 +1294,7 @@ STOP 739 - 331 + 376 654 @@ -1303,8 +1309,8 @@ STOP xplus() - 323 - 110 + 329 + 138 383 @@ -1320,11 +1326,11 @@ STOP 739 - 360 + 405 739 - 389 + 434 @@ -1335,8 +1341,8 @@ STOP yminus() - 285 - 139 + 289 + 168 383 @@ -1351,8 +1357,8 @@ STOP yplus() - 285 - 81 + 289 + 108 383 @@ -1367,8 +1373,8 @@ STOP xminus() - 248 - 110 + 250 + 138 189 @@ -1383,8 +1389,8 @@ STOP zplus() - 367 - 81 + 368 + 108 356 @@ -1399,8 +1405,8 @@ STOP zminus() - 367 - 139 + 368 + 168 209 @@ -1415,8 +1421,8 @@ STOP ezero() - 411 - 110 + 408 + 138 220 @@ -1431,8 +1437,8 @@ STOP zhome() - 455 - 139 + 454 + 168 209 @@ -1447,8 +1453,8 @@ STOP yhome() - 455 - 110 + 454 + 138 383 @@ -1463,8 +1469,8 @@ STOP eplus() - 411 - 81 + 408 + 108 397 @@ -1479,8 +1485,8 @@ STOP eminus() - 411 - 139 + 408 + 168 475 @@ -1495,8 +1501,8 @@ STOP bedcenter() - 285 - 110 + 289 + 138 321 @@ -1511,8 +1517,8 @@ STOP homeall() - 257 - 165 + 329 + 198 200 @@ -1520,6 +1526,22 @@ STOP + + sendtext + returnPressed() + sendtext + clear() + + + 558 + 394 + + + 494 + 397 + + + open() diff --git a/settingswindow.cpp b/settingswindow.cpp index 8e626c8..b57ac9e 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -26,6 +26,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : ui->lockbox->setChecked(settings.value("core/lockcontrols").toBool()); ui->checksumbox->setChecked(settings.value("core/checksums").toBool()); + ui->sdbox->setChecked(settings.value("core/checksdstatus").toBool()); } @@ -43,4 +44,5 @@ void SettingsWindow::on_buttonBox_accepted() settings.setValue("core/echo", ui->echobox->isChecked()); settings.setValue("core/lockcontrols", ui->lockbox->isChecked()); settings.setValue("core/checksums", ui->checksumbox->isChecked()); + settings.setValue("core/checksdstatus", ui->sdbox->isChecked()); } diff --git a/settingswindow.ui b/settingswindow.ui index 39593c6..8468937 100644 --- a/settingswindow.ui +++ b/settingswindow.ui @@ -89,10 +89,10 @@ - - + + - ms + Sender @@ -103,14 +103,14 @@ - - + + - Sender + ms - + false @@ -142,6 +142,13 @@ + + + + Check SD printing status + + +