Disabled EEPROM editor for firmwares different from Repetier

This commit is contained in:
NeoTheFox 2015-03-08 18:22:49 +03:00
parent 2c09580633
commit 4b29cc979d
3 changed files with 101 additions and 77 deletions

View File

@ -7,71 +7,82 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
QSettings settings;
firmware = settings.value("printer/firmware").toInt();
QLayout *layout = new QVBoxLayout(); QLayout *layout = new QVBoxLayout();
int j = 0; if(firmware == Repetier)
foreach (QString str, eepromLines)
{ {
str.remove("EPR:"); // Clear the unneeded part int j = 0;
foreach (QString str, eepromLines)
repetierEEPROMline currentLine; //Storage for EEPROM values
QStringList tmp = str.split(' ');
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) + " "); //Rejoin the rest
QLayout *line = new QGridLayout();
QLabel *label = new QLabel(msg, this);
QLineEdit *edit = new QLineEdit(currentLine.S,this);
QFrame* hline = new QFrame();
hline->setFrameShape(QFrame::HLine);
hline->setFrameShadow(QFrame::Sunken);
line->addWidget(hline);
edit->setObjectName("e"+QString::number(j)); //Name the LineEdit, so when it emits signal we know where it came from
QRegExpValidator *doublevalidator = new QRegExpValidator(
QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$",
Qt::CaseInsensitive), this);
doublevalidator->setLocale(QLocale::English);
switch(currentLine.T) // set right validator for the line
{ {
case 0: str.remove("EPR:"); // Clear the unneeded part
edit->setValidator(new QIntValidator(-128, 255, this));
case 1: repetierEEPROMline currentLine; //Storage for EEPROM values
case 2:
edit->setValidator(new QIntValidator(this)); QStringList tmp = str.split(' ');
break;
case 3: currentLine.T = tmp.at(0).toInt();
edit->setValidator(doublevalidator); currentLine.P = tmp.at(1).toInt();
break; currentLine.S = tmp.at(2);
default:
break; lines.append(currentLine);
QString msg;
for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); //Rejoin the rest
QLayout *line = new QGridLayout();
QLabel *label = new QLabel(msg, this);
QLineEdit *edit = new QLineEdit(currentLine.S,this);
QFrame* hline = new QFrame();
hline->setFrameShape(QFrame::HLine);
hline->setFrameShadow(QFrame::Sunken);
line->addWidget(hline);
edit->setObjectName("e"+QString::number(j)); //Name the LineEdit, so when it emits signal we know where it came from
QRegExpValidator *doublevalidator = new QRegExpValidator(
QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$",
Qt::CaseInsensitive), this);
doublevalidator->setLocale(QLocale::English);
switch(currentLine.T) // set right validator for the line
{
case 0:
edit->setValidator(new QIntValidator(-128, 255, this));
case 1:
case 2:
edit->setValidator(new QIntValidator(this));
break;
case 3:
edit->setValidator(doublevalidator);
break;
default:
break;
}
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(lineChanged(QString)));
line->addWidget(label);
line->addWidget(edit);
line->setMargin(2);
layout->addItem(line);
j++; // increase counter
} }
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(lineChanged(QString)));
line->addWidget(label);
line->addWidget(edit);
line->setMargin(2);
layout->addItem(line);
j++; // increase counter
}
for(int i = 0; i < lines.size(); i++) changed.append(false); for(int i = 0; i < lines.size(); i++) changed.append(false);
ui->eepromWidgets->setLayout(layout); ui->eepromWidgets->setLayout(layout);
}
else if(firmware == Marlin)
{
}
} }
EEPROMWindow::~EEPROMWindow() EEPROMWindow::~EEPROMWindow()
@ -81,33 +92,48 @@ EEPROMWindow::~EEPROMWindow()
void EEPROMWindow::lineChanged(QString s) void EEPROMWindow::lineChanged(QString s)
{ {
int num = sender()->objectName().remove(0, 1).toInt(); if(firmware == Repetier)
{
int num = sender()->objectName().remove(0, 1).toInt();
lines[num].S = s; lines[num].S = s;
changed[num] = true; changed[num] = true;
}
else if(firmware == Marlin)
{
}
} }
void EEPROMWindow::on_buttonBox_accepted() void EEPROMWindow::on_buttonBox_accepted()
{ {
QStringList gcode; QStringList gcode;
for(int i=0; i < changed.size(); i++)
if(firmware == Repetier)
{ {
if(changed.at(i)) for(int i=0; i < changed.size(); i++)
{ {
QString command; if(changed.at(i))
{
QString command;
command+=QString("M206"); command+=QString("M206");
command+=QString("T"); command+=QString("T");
command+=QString::number(lines.at(i).T); command+=QString::number(lines.at(i).T);
command+=QString("P"); command+=QString("P");
command+=QString::number(lines.at(i).P); command+=QString::number(lines.at(i).P);
if(lines.at(i).T == 3) command+=QString("X"); if(lines.at(i).T == 3) command+=QString("X");
else command+=QString("S"); else command+=QString("S");
command+=lines.at(i).S; command+=lines.at(i).S;
gcode.append(command); gcode.append(command);
}
} }
} }
else if(firmware == Marlin)
{
}
emit changesComplete(gcode); emit changesComplete(gcode);
} }

View File

@ -24,6 +24,7 @@ private:
Ui::EEPROMWindow *ui; Ui::EEPROMWindow *ui;
QVector <repetierEEPROMline> lines; QVector <repetierEEPROMline> lines;
QVector <bool> changed; QVector <bool> changed;
int firmware;
signals: signals:
void changesComplete(QStringList changed); void changesComplete(QStringList changed);

View File

@ -267,7 +267,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(firmware == Repetier) ui->actionEEPROM_editor->setDisabled(false);
//if(checkingTemperature) injectCommand("M105"); //if(checkingTemperature) injectCommand("M105");
} }
} }
@ -708,9 +708,6 @@ void MainWindow::on_actionAbout_triggered()
void MainWindow::injectCommand(QString command) void MainWindow::injectCommand(QString command)
{ {
//if(checkingTemperature && command == "M105" && userCommands.contains("M105")) return;
//if(chekingSDStatus && command == "M27" && userCommands.contains("M27")) return;
if(!userCommands.contains(command)) userCommands.enqueue(command); if(!userCommands.contains(command)) userCommands.enqueue(command);
} }
@ -872,7 +869,7 @@ void MainWindow::requestEEPROMSettings()
switch(firmware) switch(firmware)
{ {
case Marlin: case Marlin:
injectCommand("M501"); injectCommand("M503");
break; break;
case Repetier: case Repetier:
injectCommand("M205"); injectCommand("M205");