diff --git a/src/core/atcore.h b/src/core/atcore.h --- a/src/core/atcore.h +++ b/src/core/atcore.h @@ -267,7 +267,7 @@ * @param newProgress : Message * @sa percentagePrinted() */ - void printProgressChanged(const float &newProgress); + void printProgressChanged(const float newProgress); /** * @brief New message was received from the printer diff --git a/src/core/atcore.cpp b/src/core/atcore.cpp --- a/src/core/atcore.cpp +++ b/src/core/atcore.cpp @@ -584,6 +584,9 @@ void AtCore::setExtruderTemp(uint temp, uint extruder, bool andWait) { + temp = std::min(temp, 10000); + extruder = std::min(extruder, 10000); + if (andWait) { pushCommand(GCode::toCommand(GCode::M109, QString::number(temp), QString::number(extruder))); } else { @@ -593,6 +596,8 @@ void AtCore::setBedTemp(uint temp, bool andWait) { + temp = std::min(temp, 10000); + if (andWait) { pushCommand(GCode::toCommand(GCode::M190, QString::number(temp))); } else { @@ -602,16 +607,21 @@ void AtCore::setFanSpeed(uint speed, uint fanNumber) { + speed = std::min(speed, 10000); + fanNumber = std::min(fanNumber, 10000); + pushCommand(GCode::toCommand(GCode::M106, QString::number(fanNumber), QString::number(speed))); } void AtCore::setPrinterSpeed(uint speed) { + speed = std::min(speed, 10000); pushCommand(GCode::toCommand(GCode::M220, QString::number(speed))); } void AtCore::setFlowRate(uint speed) { + speed = std::min(speed, 10000); pushCommand(GCode::toCommand(GCode::M221, QString::number(speed))); } diff --git a/src/core/printthread.h b/src/core/printthread.h --- a/src/core/printthread.h +++ b/src/core/printthread.h @@ -59,7 +59,7 @@ /** * @brief The print job's progress has changed */ - void printProgressChanged(float); + void printProgressChanged(const float); /** * @brief the next command of the job diff --git a/src/core/printthread.cpp b/src/core/printthread.cpp --- a/src/core/printthread.cpp +++ b/src/core/printthread.cpp @@ -138,8 +138,8 @@ d->cline = d->gcodestream->readLine(); qCDebug(PRINT_THREAD) << "Nextline:" << d->cline; d->stillSize -= d->cline.size() + 1; //remove read chars - d->printProgress = float(d->totalSize - d->stillSize) * 100.0 / float(d->totalSize); - qCDebug(PRINT_THREAD) << "progress:" << QString::number(d->printProgress); + d->printProgress = float(d->totalSize - d->stillSize) * 100 / float(d->totalSize); + qCDebug(PRINT_THREAD) << "progress:" << QString::number(double(d->printProgress)); emit printProgressChanged(d->printProgress); if (d->cline.startsWith(QStringLiteral(";-"))) { @@ -208,17 +208,17 @@ } else if (parser.isSet(QStringLiteral("extruder temperature"))) { QStringList args = parser.positionalArguments().at(0).split(QLatin1Char(',')); bool wait = !QString::compare(args.at(2).simplified(), QStringLiteral("true"), Qt::CaseInsensitive); - d->core->setExtruderTemp(args.at(0).toInt(), args.at(1).toInt(), wait); + d->core->setExtruderTemp(args.at(0).toUInt(), args.at(1).toUInt(), wait); } else if (parser.isSet(QStringLiteral("bed temperature"))) { QStringList args = parser.positionalArguments().at(0).split(QLatin1Char(',')); bool wait = !QString::compare(args.at(1).simplified(), QStringLiteral("true"), Qt::CaseInsensitive); - d->core->setBedTemp(args.at(0).toInt(), wait); + d->core->setBedTemp(args.at(0).toUInt(), wait); } else if (parser.isSet(QStringLiteral("print speed"))) { - d->core->setPrinterSpeed(parser.positionalArguments().at(0).toInt()); + d->core->setPrinterSpeed(parser.positionalArguments().at(0).toUInt()); } else if (parser.isSet(QStringLiteral("fan speed"))) { - d->core->setFanSpeed(parser.positionalArguments().at(0).toInt(), parser.positionalArguments().at(1).toInt()); + d->core->setFanSpeed(parser.positionalArguments().at(0).toUInt(), parser.positionalArguments().at(1).toUInt()); } else if (parser.isSet(QStringLiteral("flow rate"))) { - d->core->setFlowRate(parser.positionalArguments().at(0).toInt()); + d->core->setFlowRate(parser.positionalArguments().at(0).toUInt()); } else if (parser.isSet(QStringLiteral("message"))) { d->core->showMessage(parser.positionalArguments().at(0)); } else if (parser.isSet(QStringLiteral("command"))) { diff --git a/src/widgets/printwidget.cpp b/src/widgets/printwidget.cpp --- a/src/widgets/printwidget.cpp +++ b/src/widgets/printwidget.cpp @@ -121,6 +121,7 @@ void PrintWidget::updateFanCount(const int count) { + comboFanSelect->clear(); for (int i = 0; i < count; i++) { comboFanSelect->insertItem(i, tr("Fan %1 speed").arg(i)); } diff --git a/src/widgets/temperaturewidget.cpp b/src/widgets/temperaturewidget.cpp --- a/src/widgets/temperaturewidget.cpp +++ b/src/widgets/temperaturewidget.cpp @@ -66,6 +66,7 @@ void TemperatureWidget::updateExtruderCount(const int count) { + comboExtruderSelect->clear(); for (int i = 0; i < count; i++) { comboExtruderSelect->insertItem(i, tr("Extruder %1").arg(i)); } diff --git a/unittests/atcoretests.cpp b/unittests/atcoretests.cpp --- a/unittests/atcoretests.cpp +++ b/unittests/atcoretests.cpp @@ -144,7 +144,7 @@ void AtCoreTests::testSerialTimerIntervalChanged() { - QSignalSpy sSpy(core, SIGNAL(serialTimerIntervalChanged(quint16))); + QSignalSpy sSpy(core, SIGNAL(serialTimerIntervalChanged(int))); QVERIFY(sSpy.isValid()); core->setSerialTimerInterval(1000); core->setSerialTimerInterval(1000);