diff --git a/src/core/temperature.cpp b/src/core/temperature.cpp index 886383a..dc45303 100644 --- a/src/core/temperature.cpp +++ b/src/core/temperature.cpp @@ -1,126 +1,126 @@ /* AtCore Copyright (C) <2016> Authors: Tomaz Canabrava Patrick José Pereira Chris Rizzitello This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "temperature.h" /** * @brief The TemperaturePrivate class * * Private Data of Temperature */ class Temperature::TemperaturePrivate { public: - float extruderTemp; //!< @param extruderTemp: Extruder current temperature - float extruderTargetTemp; //!< @param extruderTargetTemp: Extruder target temperature - float bedTemp; //!< @param bedTemp: Bed current temperature - float bedTargetTemp; //!< @param bedTargetTemp: Bed target temperature + float extruderTemp = 0.0; //!< @param extruderTemp: Extruder current temperature + float extruderTargetTemp = 0.0; //!< @param extruderTargetTemp: Extruder target temperature + float bedTemp = 0.0; //!< @param bedTemp: Bed current temperature + float bedTargetTemp = 0.0; //!< @param bedTargetTemp: Bed target temperature }; Temperature::Temperature(QObject *parent) : QObject(parent) , d(new TemperaturePrivate) { } float Temperature::bedTargetTemperature() const { return d->bedTargetTemp; } float Temperature::bedTemperature() const { return d->bedTemp; } float Temperature::extruderTargetTemperature() const { return d->extruderTargetTemp; } float Temperature::extruderTemperature() const { return d->extruderTemp; } void Temperature::setBedTargetTemperature(float temp) { d->bedTargetTemp = temp; emit bedTargetTemperatureChanged(temp); } void Temperature::setBedTemperature(float temp) { d->bedTemp = temp; emit bedTemperatureChanged(temp); } void Temperature::setExtruderTargetTemperature(float temp) { d->extruderTargetTemp = temp; emit extruderTargetTemperatureChanged(temp); } void Temperature::setExtruderTemperature(float temp) { d->extruderTemp = temp; emit extruderTemperatureChanged(temp); } void Temperature::decodeTemp(const QByteArray &msg) { //Capture after T: until next space - static QRegularExpression tempRegEx(QStringLiteral("T:(?\\d+\\.?\\d*)")); + static const QRegularExpression tempRegEx(QStringLiteral(R"(T:(?\d+\.\d*))")); QRegularExpressionMatch tempCheck = tempRegEx.match(QString::fromLatin1(msg)); //Find T:## /## and store the second set of numbers - static QRegularExpression targetTempRegEx(QStringLiteral("T:[^\\/]*\\/(?\\d+\\.?\\d*)")); + static const QRegularExpression targetTempRegEx(QStringLiteral(R"(T:[^\/]*\/(?\d+\.?\d*))")); QRegularExpressionMatch targetTempCheck = targetTempRegEx.match(QString::fromLatin1(msg)); if (tempCheck.hasMatch()) { setExtruderTemperature(tempCheck.captured(QStringLiteral("extruder")).toFloat()); } if (targetTempCheck.hasMatch()) { setExtruderTargetTemperature(targetTempCheck.captured(QStringLiteral("extruderTarget")).toFloat()); } if (msg.indexOf(QStringLiteral("B:")) != -1) { //Capture after B: until next space - static QRegularExpression bedRegEx(QStringLiteral("B:(?\\d+\\.?\\d*)")); + static const QRegularExpression bedRegEx(QStringLiteral(R"(B:(?\d+\.\d*))")); QRegularExpressionMatch bedCheck = bedRegEx.match(QString::fromLatin1(msg)); //Find B:## /## and store the second set of numbers - static QRegularExpression targetBedRegEx(QStringLiteral("B:[^\\/]*\\/(?\\d+\\.?\\d*)")); + static QRegularExpression targetBedRegEx(QStringLiteral(R"(B:[^\/]*\/(?\d+\.?\d*))")); QRegularExpressionMatch targetBedCheck = targetBedRegEx.match(QString::fromLatin1(msg)); if (bedCheck.hasMatch()) { setBedTemperature(bedCheck.captured(QStringLiteral("bed")).toFloat()); } if (targetBedCheck.hasMatch()) { setBedTargetTemperature(targetBedCheck.captured(QStringLiteral("bedTarget")).toFloat()); } } }