Added commands injection in printing time (for temperature check)

This commit is contained in:
NeoTheFox 2015-03-01 00:35:11 +03:00
parent 139d92b0db
commit f70f209bbc
2 changed files with 20 additions and 2 deletions

View File

@ -33,6 +33,8 @@ MainWindow::MainWindow(QWidget *parent) :
paused = false; paused = false;
commandDone = false; commandDone = false;
checkingTemperature = true; checkingTemperature = true;
injectingCommand = false;
userCommand = "";
currentLine = 0; currentLine = 0;
serialupdate(); serialupdate();
@ -419,7 +421,14 @@ void MainWindow::on_sendBtn_clicked()
void MainWindow::sendNext() void MainWindow::sendNext()
{ {
if(sending && !paused && printer.bytesToWrite() < 100 && commandDone) if(injectingCommand && commandDone && printer.bytesToWrite() < 100)
{
sendLine(userCommand);
commandDone=false;
injectingCommand=false;
return;
}
else if(sending && !paused && printer.bytesToWrite() < 100 && commandDone)
{ {
if(currentLine >= gcode.size()) //check if we are at the end of array if(currentLine >= gcode.size()) //check if we are at the end of array
{ {
@ -454,7 +463,7 @@ void MainWindow::on_pauseBtn_clicked()
void MainWindow::checkStatus() void MainWindow::checkStatus()
{ {
if(checkingTemperature && (sinceLastTemp.elapsed() < statusTimer.interval())) sendLine("M105"); if(checkingTemperature && (sinceLastTemp.elapsed() < statusTimer.interval())) injectCommand("M105");
} }
void MainWindow::on_checktemp_stateChanged(int arg1) void MainWindow::on_checktemp_stateChanged(int arg1)
@ -482,6 +491,12 @@ void MainWindow::on_actionAbout_triggered()
aboutwindow.exec(); aboutwindow.exec();
} }
void MainWindow::injectCommand(QString command)
{
injectingCommand = true;
userCommand = command;
}
void MainWindow::updateRecent() void MainWindow::updateRecent()
{ {

View File

@ -46,7 +46,9 @@ private:
bool paused; bool paused;
bool commandDone; bool commandDone;
bool checkingTemperature; bool checkingTemperature;
bool injectingCommand;
int currentLine; int currentLine;
QString userCommand;
private slots: private slots:
@ -61,6 +63,7 @@ private slots:
void sendNext(); void sendNext();
void checkStatus(); void checkStatus();
void updateRecent(); void updateRecent();
void injectCommand(QString command);
void xplus(); void xplus();
void yplus(); void yplus();