Added firmware to options (EEPROM editor)

Some preparations to support EEPROM editor
Only enable checksums and EEPROM editor for debug right now
This commit is contained in:
NeoTheFox 2015-03-07 01:48:17 +03:00
parent c174c93ed8
commit e7ad6a0013
13 changed files with 346 additions and 29 deletions

View File

@ -20,20 +20,24 @@ SOURCES += main.cpp\
aboutwindow.cpp \ aboutwindow.cpp \
errorwindow.cpp \ errorwindow.cpp \
erroricon.cpp \ erroricon.cpp \
sdwindow.cpp sdwindow.cpp \
eepromwindow.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
settingswindow.h \ settingswindow.h \
aboutwindow.h \ aboutwindow.h \
errorwindow.h \ errorwindow.h \
erroricon.h \ erroricon.h \
sdwindow.h sdwindow.h \
repraptor.h \
eepromwindow.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
settingswindow.ui \ settingswindow.ui \
aboutwindow.ui \ aboutwindow.ui \
errorwindow.ui \ errorwindow.ui \
sdwindow.ui sdwindow.ui \
eepromwindow.ui
RESOURCES += \ RESOURCES += \
graphics.qrc graphics.qrc

47
eepromwindow.cpp Normal file
View File

@ -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()
{
}

28
eepromwindow.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef EEPROMWINDOW_H
#define EEPROMWINDOW_H
#include <QDialog>
#include <QtWidgets>
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

84
eepromwindow.ui Normal file
View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EEPROMWindow</class>
<widget class="QDialog" name="EEPROMWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>EEPROM Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="eepromWidgets">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>267</width>
<height>251</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EEPROMWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>282</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EEPROMWindow</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>277</x>
<y>288</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -9,5 +9,6 @@
<file>icons/settings.png</file> <file>icons/settings.png</file>
<file>icons/about.png</file> <file>icons/about.png</file>
<file>icons/exit.png</file> <file>icons/exit.png</file>
<file>icons/eeprom.png</file>
</qresource> </qresource>
</RCC> </RCC>

BIN
icons/eeprom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

View File

@ -16,6 +16,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
ui->actionPrint_from_SD->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->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(4800));
ui->baudbox->addItem(QString::number(9600)); ui->baudbox->addItem(QString::number(9600));
@ -47,6 +48,9 @@ MainWindow::MainWindow(QWidget *parent) :
sendingChecksum = settings.value("core/checksums").toBool(); sendingChecksum = settings.value("core/checksums").toBool();
chekingSDStatus = settings.value("core/checksdstatus").toBool(); chekingSDStatus = settings.value("core/checksdstatus").toBool();
if(firstrun) firmware = OtherFirmware;
else firmware = settings.value("printer/firmware").toInt();
sending = false; sending = false;
paused = false; paused = false;
readingFiles = false; readingFiles = false;
@ -55,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent) :
userCommand = ""; userCommand = "";
currentLine = 0; currentLine = 0;
readyRecieve = 0; readyRecieve = 0;
readingEEPROM = false;
EEPROMReadingStarted = false;
temperatureRegxp.setCaseSensitivity(Qt::CaseInsensitive); temperatureRegxp.setCaseSensitivity(Qt::CaseInsensitive);
temperatureRegxp.setPatternSyntax(QRegExp::RegExp); temperatureRegxp.setPatternSyntax(QRegExp::RegExp);
@ -74,6 +80,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&sdWatcher, SIGNAL(finished()), this, SLOT(updateSDStatus())); connect(&sdWatcher, SIGNAL(finished()), this, SLOT(updateSDStatus()));
connect(this, SIGNAL(sdReady()), this, SLOT(initSDprinting())); connect(this, SIGNAL(sdReady()), this, SLOT(initSDprinting()));
connect(&progressSDTimer, SIGNAL(timeout()), this, SLOT(checkSDStatus())); 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()); if(settings.value("core/statusinterval").toInt()) statusTimer.setInterval(settings.value("core/statusinterval").toInt());
else statusTimer.setInterval(3000); else statusTimer.setInterval(3000);
@ -89,6 +96,12 @@ MainWindow::MainWindow(QWidget *parent) :
tempWarning.setInterval(10000); tempWarning.setInterval(10000);
sinceLastTemp.start(); sinceLastTemp.start();
#ifdef QT_DEBUG
ui->actionEEPROM_editor->setEnabled(true);
#else
ui->actionEEPROM_editor->setDisabled(true);
#endif
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -240,6 +253,7 @@ void MainWindow::serialconnect()
ui->consoleGroup->setDisabled(false); ui->consoleGroup->setDisabled(false);
ui->actionPrint_from_SD->setEnabled(true); ui->actionPrint_from_SD->setEnabled(true);
ui->actionSet_SD_printing_mode->setEnabled(true); ui->actionSet_SD_printing_mode->setEnabled(true);
if(firmware != OtherFirmware) ui->actionEEPROM_editor->setDisabled(false);
//if(checkingTemperature) injectCommand("M105"); //if(checkingTemperature) injectCommand("M105");
} }
} }
@ -256,6 +270,7 @@ void MainWindow::serialconnect()
ui->consoleGroup->setDisabled(true); ui->consoleGroup->setDisabled(true);
ui->actionPrint_from_SD->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true);
ui->actionEEPROM_editor->setDisabled(false);
} }
} }
@ -454,6 +469,27 @@ void MainWindow::readSerial()
return; 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++; if(data.startsWith("ok")) readyRecieve++;
else if(checkingTemperature && data.startsWith("T:")) else if(checkingTemperature && data.startsWith("T:"))
{ {
@ -466,7 +502,7 @@ void MainWindow::readSerial()
{ {
if(gcode.isEmpty()) 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; return;
} }
int err = data.split(':')[1].toInt(); int err = data.split(':')[1].toInt();
@ -583,6 +619,7 @@ void MainWindow::sendNext()
+ QString("/") + QString("/")
+ QString::number(currentLine) + QString::number(currentLine)
+ QString(" Lines")); + QString(" Lines"));
if(sendingChecksum) injectCommand("M110 N0");
return; return;
} }
sendLine(gcode.at(currentLine)); sendLine(gcode.at(currentLine));
@ -619,10 +656,11 @@ void MainWindow::on_pauseBtn_clicked()
void MainWindow::checkStatus() void MainWindow::checkStatus()
{ {
if(checkingTemperature && if(checkingTemperature
(sinceLastTemp.elapsed() > statusTimer.interval()) &&(sinceLastTemp.elapsed() > statusTimer.interval())
&& statusWatcher.isFinished() && statusWatcher.isFinished()
&& !readingFiles) injectCommand("M105"); && !readingFiles
&& !readingEEPROM) injectCommand("M105");
} }
void MainWindow::on_checktemp_stateChanged(int arg1) void MainWindow::on_checktemp_stateChanged(int arg1)
@ -678,6 +716,7 @@ void MainWindow::serialError(QSerialPort::SerialPortError error)
ui->consoleGroup->setDisabled(true); ui->consoleGroup->setDisabled(true);
ui->actionPrint_from_SD->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true);
ui->actionEEPROM_editor->setDisabled(true);
qDebug() << error; qDebug() << error;
@ -859,3 +898,41 @@ void MainWindow::on_actionSet_SD_printing_mode_triggered()
sdprinting = true; sdprinting = true;
ui->fileBox->setDisabled(false); 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)
{
}

View File

@ -18,17 +18,15 @@
#include "aboutwindow.h" #include "aboutwindow.h"
#include "errorwindow.h" #include "errorwindow.h"
#include "sdwindow.h" #include "sdwindow.h"
#include "repraptor.h"
#include "eepromwindow.h"
using namespace RepRaptor;
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
typedef struct
{
double e, b;
} TemperatureReadings;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -49,6 +47,7 @@ protected:
QSettings settings; QSettings settings;
QStringList recentFiles; QStringList recentFiles;
QStringList sdFiles; QStringList sdFiles;
QStringList EEPROMSettings;
QFutureWatcher<TemperatureReadings> statusWatcher; QFutureWatcher<TemperatureReadings> statusWatcher;
QFutureWatcher<double> sdWatcher; QFutureWatcher<double> sdWatcher;
QRegExp temperatureRegxp; QRegExp temperatureRegxp;
@ -66,10 +65,13 @@ private:
bool paused; bool paused;
bool checkingTemperature; bool checkingTemperature;
bool readingFiles; bool readingFiles;
bool readingEEPROM;
bool EEPROMReadingStarted;
bool sdprinting; bool sdprinting;
bool echo; bool echo;
bool sendingChecksum; bool sendingChecksum;
bool chekingSDStatus; bool chekingSDStatus;
int firmware;
long int currentLine; long int currentLine;
int readyRecieve; int readyRecieve;
unsigned long int sdBytes; unsigned long int sdBytes;
@ -95,6 +97,9 @@ private slots:
void updateSDStatus(); void updateSDStatus();
TemperatureReadings parseStatus(QByteArray data); TemperatureReadings parseStatus(QByteArray data);
double parseSDStatus(QByteArray data); double parseSDStatus(QByteArray data);
void requestEEPROMSettings();
void openEEPROMeditor();
void sendEEPROMsettings(QStringList changes);
void xplus(); void xplus();
void yplus(); void yplus();
@ -140,8 +145,11 @@ private slots:
void on_actionSet_SD_printing_mode_triggered(); void on_actionSet_SD_printing_mode_triggered();
void on_actionEEPROM_editor_triggered();
signals: signals:
void sdReady(); void sdReady();
void eepromReady();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -1076,6 +1076,8 @@ STOP</string>
</property> </property>
<addaction name="actionPrint_from_SD"/> <addaction name="actionPrint_from_SD"/>
<addaction name="actionSet_SD_printing_mode"/> <addaction name="actionSet_SD_printing_mode"/>
<addaction name="separator"/>
<addaction name="actionEEPROM_editor"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuTools"/> <addaction name="menuTools"/>
@ -1200,6 +1202,21 @@ STOP</string>
<string>Set SD printing mode</string> <string>Set SD printing mode</string>
</property> </property>
</action> </action>
<action name="actionEEPROM_editor">
<property name="enabled">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="graphics.qrc">
<normaloff>:/icons/eeprom.png</normaloff>:/icons/eeprom.png</iconset>
</property>
<property name="text">
<string>EEPROM editor</string>
</property>
<property name="toolTip">
<string>To use EEPROM editor you need to set firmware in settings</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources> <resources>
@ -1561,5 +1578,6 @@ STOP</string>
<slot>ezero()</slot> <slot>ezero()</slot>
<slot>yhome()</slot> <slot>yhome()</slot>
<slot>bedcenter()</slot> <slot>bedcenter()</slot>
<slot>requestEEPROMSettings()</slot>
</slots> </slots>
</ui> </ui>

20
repraptor.h Normal file
View File

@ -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

View File

@ -28,6 +28,19 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
ui->checksumbox->setChecked(settings.value("core/checksums").toBool()); ui->checksumbox->setChecked(settings.value("core/checksums").toBool());
ui->sdbox->setChecked(settings.value("core/checksdstatus").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() SettingsWindow::~SettingsWindow()
@ -45,4 +58,5 @@ void SettingsWindow::on_buttonBox_accepted()
settings.setValue("core/lockcontrols", ui->lockbox->isChecked()); settings.setValue("core/lockcontrols", ui->lockbox->isChecked());
settings.setValue("core/checksums", ui->checksumbox->isChecked()); settings.setValue("core/checksums", ui->checksumbox->isChecked());
settings.setValue("core/checksdstatus", ui->sdbox->isChecked()); settings.setValue("core/checksdstatus", ui->sdbox->isChecked());
settings.setValue("printer/firmware", ui->firmwarecombo->currentIndex());
} }

View File

@ -3,6 +3,9 @@
#include <QDialog> #include <QDialog>
#include <QSettings> #include <QSettings>
#include "repraptor.h"
using namespace RepRaptor;
namespace Ui { namespace Ui {
class SettingsWindow; class SettingsWindow;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>253</width> <width>253</width>
<height>330</height> <height>386</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -113,7 +113,7 @@
<item row="6" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="checksumbox"> <widget class="QCheckBox" name="checksumbox">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Checksums</string> <string>Checksums</string>
@ -164,14 +164,7 @@
<string>Printer</string> <string>Printer</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="1" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bed size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="bedxbox"> <widget class="QSpinBox" name="bedxbox">
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
@ -181,14 +174,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>X</string> <string>X</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="1" column="3">
<widget class="QSpinBox" name="bedybox"> <widget class="QSpinBox" name="bedybox">
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
@ -198,6 +191,23 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bed size</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Firmware</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="firmwarecombo"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -209,6 +219,9 @@
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -224,8 +237,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>248</x> <x>243</x>
<y>254</y> <y>376</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
@ -240,11 +253,11 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>316</x> <x>243</x>
<y>260</y> <y>376</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>252</x>
<y>274</y> <y>274</y>
</hint> </hint>
</hints> </hints>