EEPROM editing for Repetier enabled
This commit is contained in:
parent
e7ad6a0013
commit
e9edde0932
@ -8,17 +8,22 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
QLayout *layout = new QVBoxLayout();
|
||||
|
||||
int j = 0;
|
||||
foreach (QString str, eepromLines)
|
||||
{
|
||||
j++;
|
||||
str.remove("EPR:");
|
||||
int T, P;
|
||||
double S;
|
||||
|
||||
repetierEEPROMline currentLine;
|
||||
|
||||
QStringList tmp = str.split(' ');
|
||||
|
||||
T = tmp.at(0).toInt();
|
||||
P = tmp.at(1).toInt();
|
||||
S = tmp.at(2).toDouble();
|
||||
currentLine.T = tmp.at(0).toInt();
|
||||
currentLine.P = tmp.at(1).toInt();
|
||||
currentLine.S = tmp.at(2);
|
||||
|
||||
lines.append(currentLine);
|
||||
|
||||
QString msg;
|
||||
for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " ");
|
||||
@ -26,13 +31,39 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
|
||||
QLayout *line = new QHBoxLayout();
|
||||
|
||||
QLabel *label = new QLabel(msg, this);
|
||||
QLineEdit *edit = new QLineEdit(QString::number(S),this);
|
||||
QLineEdit *edit = new QLineEdit(currentLine.S,this);
|
||||
//QCheckBox *changebox = new QCheckBox("Save", this);
|
||||
|
||||
//changebox->setObjectName("b"+QString::number(j));
|
||||
edit->setObjectName("e"+QString::number(j));
|
||||
|
||||
switch(currentLine.T) // set right validator for the line
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
edit->setValidator(new QIntValidator(this));
|
||||
break;
|
||||
case 3:
|
||||
//edit->setValidator(new QDoubleValidator(this));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//connect(edit, SIGNAL(returnPressed()), changebox, SLOT(toggle()));
|
||||
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(lineChanged(QString)));
|
||||
//connect(changebox, SIGNAL(toggled(bool)), this, SLOT(lineChanged()));
|
||||
|
||||
line->addWidget(label);
|
||||
line->addWidget(edit);
|
||||
//line->addWidget(changebox);
|
||||
|
||||
line->setMargin(2);
|
||||
|
||||
layout->addItem(line);
|
||||
}
|
||||
for(int i = 0; i < lines.size(); i++) changed.append(false);
|
||||
ui->eepromWidgets->setLayout(layout);
|
||||
}
|
||||
|
||||
@ -41,7 +72,34 @@ EEPROMWindow::~EEPROMWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EEPROMWindow::lineChanged(QString s)
|
||||
{
|
||||
int num = sender()->objectName().remove(0, 1).toInt();
|
||||
|
||||
lines[num].S = s;
|
||||
changed[num] = true;
|
||||
}
|
||||
|
||||
void EEPROMWindow::on_buttonBox_accepted()
|
||||
{
|
||||
for(int i=0; i < changed.size(); i++)
|
||||
{
|
||||
if(changed.at(i))
|
||||
{
|
||||
QString tmp;
|
||||
|
||||
tmp+=QString("M206");
|
||||
tmp+=QString("T");
|
||||
tmp+=QString::number(lines.at(i).T);
|
||||
tmp+=QString("P");
|
||||
tmp+=QString::number(lines.at(i).P);
|
||||
if(lines.at(i).T == 3) tmp+=QString("X");
|
||||
else tmp+=QString("S");
|
||||
tmp+=lines.at(i).S;
|
||||
|
||||
gcode.append(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
emit changesComplete(gcode);
|
||||
}
|
||||
|
||||
@ -4,6 +4,10 @@
|
||||
#include <QDialog>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "repraptor.h"
|
||||
|
||||
using namespace RepRaptor;
|
||||
|
||||
namespace Ui {
|
||||
class EEPROMWindow;
|
||||
}
|
||||
@ -18,11 +22,16 @@ public:
|
||||
|
||||
private:
|
||||
Ui::EEPROMWindow *ui;
|
||||
QVector <repetierEEPROMline> lines;
|
||||
QVector <bool> changed;
|
||||
QStringList gcode;
|
||||
|
||||
signals:
|
||||
void changesComplete(QStringList changed);
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void lineChanged(QString s);
|
||||
};
|
||||
|
||||
#endif // EEPROMWINDOW_H
|
||||
|
||||
@ -16,6 +16,12 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
@ -690,7 +690,10 @@ void MainWindow::on_actionAbout_triggered()
|
||||
|
||||
void MainWindow::injectCommand(QString command)
|
||||
{
|
||||
userCommands.enqueue(command);
|
||||
//if(checkingTemperature && command == "M105" && userCommands.contains("M105")) return;
|
||||
//if(chekingSDStatus && command == "M27" && userCommands.contains("M27")) return;
|
||||
|
||||
if(!userCommands.contains(command)) userCommands.enqueue(command);
|
||||
}
|
||||
|
||||
void MainWindow::updateRecent()
|
||||
@ -934,5 +937,8 @@ void MainWindow::openEEPROMeditor()
|
||||
|
||||
void MainWindow::sendEEPROMsettings(QStringList changes)
|
||||
{
|
||||
|
||||
userCommands.clear();
|
||||
foreach (QString str, changes) {
|
||||
injectCommand(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef REPRAPTOR_H
|
||||
#define REPRAPTOR_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace RepRaptor
|
||||
{
|
||||
typedef struct
|
||||
@ -14,6 +16,12 @@ namespace RepRaptor
|
||||
Repetier,
|
||||
OtherFirmware
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int T, P;
|
||||
QString S;
|
||||
} repetierEEPROMline;
|
||||
}
|
||||
|
||||
#endif // REPRAPTOR_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user