diff --git a/src/core/atcore.h b/src/core/atcore.h --- a/src/core/atcore.h +++ b/src/core/atcore.h @@ -65,7 +65,7 @@ Q_PROPERTY(int extruderCount READ extruderCount WRITE setExtruderCount NOTIFY extruderCountChanged) Q_PROPERTY(int serialTimerInterval READ serialTimerInterval WRITE setSerialTimerInterval NOTIFY serialTimerIntervalChanged) Q_PROPERTY(QStringList serialPorts READ serialPorts NOTIFY portsChanged) - Q_PROPERTY(float percentagePrinted READ percentagePrinted NOTIFY printProgressChanged) + Q_PROPERTY(double percentagePrinted READ percentagePrinted NOTIFY printProgressChanged) Q_PROPERTY(QStringList portSpeeds READ portSpeeds) Q_PROPERTY(QString connectedPort READ connectedPort) Q_PROPERTY(AtCore::STATES state READ state WRITE setState NOTIFY stateChanged) @@ -206,7 +206,7 @@ * @brief Return printed percentage * @sa printProgressChanged() */ - float percentagePrinted() const; + double percentagePrinted() const; /** * @brief The temperature of the current hotend as told by the Firmware. @@ -267,7 +267,7 @@ * @param newProgress : Message * @sa percentagePrinted() */ - void printProgressChanged(const float &newProgress); + void printProgressChanged(const double 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 @@ -58,7 +58,7 @@ QStringList commandQueue; //!< @param commandQueue: the list of commands to send to the printer bool ready = false; //!< @param ready: True if printer is ready for a command QTimer *tempTimer = nullptr; //!< @param tempTimer: timer connected to the checkTemperature function - float percentage; //!< @param percentage: print job percent + double percentage; //!< @param percentage: print job percent QByteArray posString; //!< @param posString: stored string from last M114 return AtCore::STATES printerState; //!< @param printerState: State of the Printer QStringList serialPorts; //!< @param seralPorts: Detected serial Ports @@ -332,7 +332,7 @@ pushCommand(GCode::toCommand(GCode::G90)); } -float AtCore::percentagePrinted() const +double AtCore::percentagePrinted() const { return d->percentage; } 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 double); /** * @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 @@ -37,7 +37,7 @@ public: AtCore *core = nullptr; //!<@param core: Pointer to AtCore QTextStream *gcodestream = nullptr; //!<@param gcodestream: Steam the job is read from - float printProgress = 0; //!<@param printProgress: Progress of the print job + double printProgress = 0; //!<@param printProgress: Progress of the print job qint64 totalSize = 0; //!<@param totalSize: total file size qint64 stillSize = 0; //!<@param stillSize: remaining file QString cline; //!<@param cline: current line @@ -138,7 +138,7 @@ 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); + d->printProgress = (d->totalSize - d->stillSize) * 100 / d->totalSize; qCDebug(PRINT_THREAD) << "progress:" << QString::number(d->printProgress); emit printProgressChanged(d->printProgress); @@ -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/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);