diff --git a/RepRaptor.pro b/RepRaptor.pro index 1d65d70..6c423e0 100644 --- a/RepRaptor.pro +++ b/RepRaptor.pro @@ -20,20 +20,24 @@ SOURCES += main.cpp\ aboutwindow.cpp \ errorwindow.cpp \ erroricon.cpp \ - sdwindow.cpp + sdwindow.cpp \ + eepromwindow.cpp HEADERS += mainwindow.h \ settingswindow.h \ aboutwindow.h \ errorwindow.h \ erroricon.h \ - sdwindow.h + sdwindow.h \ + repraptor.h \ + eepromwindow.h FORMS += mainwindow.ui \ settingswindow.ui \ aboutwindow.ui \ errorwindow.ui \ - sdwindow.ui + sdwindow.ui \ + eepromwindow.ui RESOURCES += \ graphics.qrc diff --git a/eepromwindow.cpp b/eepromwindow.cpp new file mode 100644 index 0000000..0365fd2 --- /dev/null +++ b/eepromwindow.cpp @@ -0,0 +1,47 @@ +#include "eepromwindow.h" +#include "ui_eepromwindow.h" + +EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) : + QDialog(parent), + ui(new Ui::EEPROMWindow) +{ + ui->setupUi(this); + + QLayout *layout = new QVBoxLayout(); + foreach (QString str, eepromLines) + { + str.remove("EPR:"); + int T, P; + double S; + + QStringList tmp = str.split(' '); + + T = tmp.at(0).toInt(); + P = tmp.at(1).toInt(); + S = tmp.at(2).toDouble(); + + QString msg; + for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); + + QLayout *line = new QHBoxLayout(); + + QLabel *label = new QLabel(msg, this); + QLineEdit *edit = new QLineEdit(QString::number(S),this); + + line->addWidget(label); + line->addWidget(edit); + + layout->addItem(line); + } + ui->eepromWidgets->setLayout(layout); +} + +EEPROMWindow::~EEPROMWindow() +{ + delete ui; +} + +void EEPROMWindow::on_buttonBox_accepted() +{ + +} diff --git a/eepromwindow.h b/eepromwindow.h new file mode 100644 index 0000000..9b2f946 --- /dev/null +++ b/eepromwindow.h @@ -0,0 +1,28 @@ +#ifndef EEPROMWINDOW_H +#define EEPROMWINDOW_H + +#include +#include + +namespace Ui { +class EEPROMWindow; +} + +class EEPROMWindow : public QDialog +{ + Q_OBJECT + +public: + explicit EEPROMWindow(QStringList eepromLines, QWidget *parent = 0); + ~EEPROMWindow(); + +private: + Ui::EEPROMWindow *ui; + +signals: + void changesComplete(QStringList changed); +private slots: + void on_buttonBox_accepted(); +}; + +#endif // EEPROMWINDOW_H diff --git a/eepromwindow.ui b/eepromwindow.ui new file mode 100644 index 0000000..b3ad01f --- /dev/null +++ b/eepromwindow.ui @@ -0,0 +1,84 @@ + + + EEPROMWindow + + + + 0 + 0 + 287 + 300 + + + + EEPROM Editor + + + + + + true + + + + + 0 + 0 + 267 + 251 + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + buttonBox + accepted() + EEPROMWindow + accept() + + + 227 + 282 + + + 157 + 274 + + + + + buttonBox + rejected() + EEPROMWindow + reject() + + + 277 + 288 + + + 286 + 274 + + + + + diff --git a/graphics.qrc b/graphics.qrc index b04c82a..a96caec 100644 --- a/graphics.qrc +++ b/graphics.qrc @@ -9,5 +9,6 @@ icons/settings.png icons/about.png icons/exit.png + icons/eeprom.png diff --git a/icons/eeprom.png b/icons/eeprom.png new file mode 100644 index 0000000..4c71a24 Binary files /dev/null and b/icons/eeprom.png differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 30d99ba..2efc018 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,6 +16,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->pauseBtn->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true); + ui->actionEEPROM_editor->setDisabled(true); ui->baudbox->addItem(QString::number(4800)); ui->baudbox->addItem(QString::number(9600)); @@ -47,6 +48,9 @@ MainWindow::MainWindow(QWidget *parent) : sendingChecksum = settings.value("core/checksums").toBool(); chekingSDStatus = settings.value("core/checksdstatus").toBool(); + if(firstrun) firmware = OtherFirmware; + else firmware = settings.value("printer/firmware").toInt(); + sending = false; paused = false; readingFiles = false; @@ -55,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent) : userCommand = ""; currentLine = 0; readyRecieve = 0; + readingEEPROM = false; + EEPROMReadingStarted = false; temperatureRegxp.setCaseSensitivity(Qt::CaseInsensitive); temperatureRegxp.setPatternSyntax(QRegExp::RegExp); @@ -74,6 +80,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(&sdWatcher, SIGNAL(finished()), this, SLOT(updateSDStatus())); connect(this, SIGNAL(sdReady()), this, SLOT(initSDprinting())); connect(&progressSDTimer, SIGNAL(timeout()), this, SLOT(checkSDStatus())); + connect(this, SIGNAL(eepromReady()), this, SLOT(openEEPROMeditor())); if(settings.value("core/statusinterval").toInt()) statusTimer.setInterval(settings.value("core/statusinterval").toInt()); else statusTimer.setInterval(3000); @@ -89,6 +96,12 @@ MainWindow::MainWindow(QWidget *parent) : tempWarning.setInterval(10000); sinceLastTemp.start(); + + #ifdef QT_DEBUG + ui->actionEEPROM_editor->setEnabled(true); + #else + ui->actionEEPROM_editor->setDisabled(true); + #endif } MainWindow::~MainWindow() @@ -240,6 +253,7 @@ void MainWindow::serialconnect() ui->consoleGroup->setDisabled(false); ui->actionPrint_from_SD->setEnabled(true); ui->actionSet_SD_printing_mode->setEnabled(true); + if(firmware != OtherFirmware) ui->actionEEPROM_editor->setDisabled(false); //if(checkingTemperature) injectCommand("M105"); } } @@ -256,6 +270,7 @@ void MainWindow::serialconnect() ui->consoleGroup->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true); + ui->actionEEPROM_editor->setDisabled(false); } } @@ -454,6 +469,27 @@ void MainWindow::readSerial() return; } + if(readingEEPROM) + { + if(firmware == Repetier) + { + if(data.startsWith("EPR")) + { + EEPROMSettings.append(data); + EEPROMReadingStarted = true; + } + else if(EEPROMReadingStarted) + { + readingEEPROM = false; + EEPROMReadingStarted = false; + emit eepromReady(); + } + + printMsg(QString(data)); //echo + return; + } + } + if(data.startsWith("ok")) readyRecieve++; else if(checkingTemperature && data.startsWith("T:")) { @@ -466,7 +502,7 @@ void MainWindow::readSerial() { if(gcode.isEmpty()) { - injectCommand("M110"); //This means we rebooted, file is gone, so we need to reset counter + injectCommand("M110 N0"); //This means we rebooted, file is gone, so we need to reset counter return; } int err = data.split(':')[1].toInt(); @@ -583,6 +619,7 @@ void MainWindow::sendNext() + QString("/") + QString::number(currentLine) + QString(" Lines")); + if(sendingChecksum) injectCommand("M110 N0"); return; } sendLine(gcode.at(currentLine)); @@ -619,10 +656,11 @@ void MainWindow::on_pauseBtn_clicked() void MainWindow::checkStatus() { - if(checkingTemperature && - (sinceLastTemp.elapsed() > statusTimer.interval()) + if(checkingTemperature + &&(sinceLastTemp.elapsed() > statusTimer.interval()) && statusWatcher.isFinished() - && !readingFiles) injectCommand("M105"); + && !readingFiles + && !readingEEPROM) injectCommand("M105"); } void MainWindow::on_checktemp_stateChanged(int arg1) @@ -678,6 +716,7 @@ void MainWindow::serialError(QSerialPort::SerialPortError error) ui->consoleGroup->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true); + ui->actionEEPROM_editor->setDisabled(true); qDebug() << error; @@ -859,3 +898,41 @@ void MainWindow::on_actionSet_SD_printing_mode_triggered() sdprinting = true; ui->fileBox->setDisabled(false); } + +void MainWindow::requestEEPROMSettings() +{ + userCommands.clear(); + + switch(firmware) + { + case Marlin: + injectCommand("M501"); + break; + case Repetier: + injectCommand("M205"); + break; + case OtherFirmware: + return; + } + + readingEEPROM = true; +} + +void MainWindow::on_actionEEPROM_editor_triggered() +{ + requestEEPROMSettings(); +} + +void MainWindow::openEEPROMeditor() +{ + EEPROMWindow eepromwindow(EEPROMSettings, this); + + connect(&eepromwindow, SIGNAL(changesComplete(QStringList)), this, SLOT(sendEEPROMsettings(QStringList))); + + eepromwindow.exec(); +} + +void MainWindow::sendEEPROMsettings(QStringList changes) +{ + +} diff --git a/mainwindow.h b/mainwindow.h index 7af73be..4631bb2 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -18,17 +18,15 @@ #include "aboutwindow.h" #include "errorwindow.h" #include "sdwindow.h" +#include "repraptor.h" +#include "eepromwindow.h" +using namespace RepRaptor; namespace Ui { class MainWindow; } -typedef struct -{ - double e, b; -} TemperatureReadings; - class MainWindow : public QMainWindow { Q_OBJECT @@ -49,6 +47,7 @@ protected: QSettings settings; QStringList recentFiles; QStringList sdFiles; + QStringList EEPROMSettings; QFutureWatcher statusWatcher; QFutureWatcher sdWatcher; QRegExp temperatureRegxp; @@ -66,10 +65,13 @@ private: bool paused; bool checkingTemperature; bool readingFiles; + bool readingEEPROM; + bool EEPROMReadingStarted; bool sdprinting; bool echo; bool sendingChecksum; bool chekingSDStatus; + int firmware; long int currentLine; int readyRecieve; unsigned long int sdBytes; @@ -95,6 +97,9 @@ private slots: void updateSDStatus(); TemperatureReadings parseStatus(QByteArray data); double parseSDStatus(QByteArray data); + void requestEEPROMSettings(); + void openEEPROMeditor(); + void sendEEPROMsettings(QStringList changes); void xplus(); void yplus(); @@ -140,8 +145,11 @@ private slots: void on_actionSet_SD_printing_mode_triggered(); + void on_actionEEPROM_editor_triggered(); + signals: void sdReady(); + void eepromReady(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index c2ff79a..0c6695d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1076,6 +1076,8 @@ STOP + + @@ -1200,6 +1202,21 @@ STOP Set SD printing mode + + + true + + + + :/icons/eeprom.png:/icons/eeprom.png + + + EEPROM editor + + + To use EEPROM editor you need to set firmware in settings + + @@ -1561,5 +1578,6 @@ STOP ezero() yhome() bedcenter() + requestEEPROMSettings() diff --git a/repraptor.h b/repraptor.h new file mode 100644 index 0000000..72d4b06 --- /dev/null +++ b/repraptor.h @@ -0,0 +1,20 @@ +#ifndef REPRAPTOR_H +#define REPRAPTOR_H + +namespace RepRaptor +{ + typedef struct + { + double e, b; + } TemperatureReadings; + + enum Firmware + { + Marlin, + Repetier, + OtherFirmware + }; +} + +#endif // REPRAPTOR_H + diff --git a/settingswindow.cpp b/settingswindow.cpp index b57ac9e..01d6d51 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -28,6 +28,19 @@ SettingsWindow::SettingsWindow(QWidget *parent) : ui->checksumbox->setChecked(settings.value("core/checksums").toBool()); ui->sdbox->setChecked(settings.value("core/checksdstatus").toBool()); + ui->firmwarecombo->addItem("Marlin"); + ui->firmwarecombo->addItem("Repetier"); + ui->firmwarecombo->addItem("Other"); + + if(firstrun) ui->firmwarecombo->setCurrentIndex(OtherFirmware); + else ui->firmwarecombo->setCurrentIndex(settings.value("printer/firmware").toInt()); + + #ifdef QT_DEBUG + ui->checksumbox->setEnabled(true); + #else + ui->checksumbox->setDisabled(true); + #endif + } SettingsWindow::~SettingsWindow() @@ -45,4 +58,5 @@ void SettingsWindow::on_buttonBox_accepted() settings.setValue("core/lockcontrols", ui->lockbox->isChecked()); settings.setValue("core/checksums", ui->checksumbox->isChecked()); settings.setValue("core/checksdstatus", ui->sdbox->isChecked()); + settings.setValue("printer/firmware", ui->firmwarecombo->currentIndex()); } diff --git a/settingswindow.h b/settingswindow.h index 1851a00..4dd6dba 100644 --- a/settingswindow.h +++ b/settingswindow.h @@ -3,6 +3,9 @@ #include #include +#include "repraptor.h" + +using namespace RepRaptor; namespace Ui { class SettingsWindow; diff --git a/settingswindow.ui b/settingswindow.ui index 8468937..3880247 100644 --- a/settingswindow.ui +++ b/settingswindow.ui @@ -7,7 +7,7 @@ 0 0 253 - 330 + 386 @@ -113,7 +113,7 @@ - false + true Checksums @@ -164,14 +164,7 @@ Printer - - - - Bed size - - - - + 1 @@ -181,14 +174,14 @@ - + X - + 1 @@ -198,6 +191,23 @@ + + + + Bed size + + + + + + + Firmware + + + + + + @@ -209,6 +219,9 @@ QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + true + @@ -224,8 +237,8 @@ accept() - 248 - 254 + 243 + 376 157 @@ -240,11 +253,11 @@ reject() - 316 - 260 + 243 + 376 - 286 + 252 274