diff --git a/src/core/atcore.h b/src/core/atcore.h
--- a/src/core/atcore.h
+++ b/src/core/atcore.h
@@ -24,7 +24,7 @@
License along with this library. If not, see .
*/
#pragma once
-
+#include
#include
#include
#include
@@ -199,7 +199,7 @@
/**
* @brief The temperature of the current hotend as told by the Firmware.
*/
- Temperature &temperature() const;
+ std::shared_ptr temperature();
/**
* @brief Return the amount of miliseconds the serialTimer is set to. 0 = Disabled
diff --git a/src/core/atcore.cpp b/src/core/atcore.cpp
--- a/src/core/atcore.cpp
+++ b/src/core/atcore.cpp
@@ -63,7 +63,7 @@
/** extruderCount: extruder count */
int extruderCount = 1;
/** temperature: Temperature object */
- Temperature temperature;
+ std::shared_ptr temperature = nullptr;
/** commandQueue: the list of commands to send to the printer */
QStringList commandQueue;
/** ready: True if printer is ready for a command */
@@ -98,6 +98,7 @@
QObject(parent),
d(new AtCorePrivate)
{
+ d->temperature.reset(new Temperature);
//Register MetaTypes
qRegisterMetaType("AtCore::STATES");
setState(AtCore::STATES::DISCONNECTED);
@@ -144,7 +145,7 @@
exit(0);
}
-Temperature &AtCore::temperature() const
+std::shared_ptr AtCore::temperature()
{
return d->temperature;
}
@@ -360,7 +361,7 @@
//Check if have temperature info and decode it
if (d->lastMessage.contains("T:") || d->lastMessage.contains("B:")) {
- temperature().decodeTemp(d->lastMessage);
+ temperature().get()->decodeTemp(d->lastMessage);
}
emit receivedMessage(d->lastMessage);
}
diff --git a/testclient/mainwindow.cpp b/testclient/mainwindow.cpp
--- a/testclient/mainwindow.cpp
+++ b/testclient/mainwindow.cpp
@@ -174,25 +174,25 @@
plotWidget = new PlotWidget;
//make and connect our plots in the widget.
plotWidget->addPlot(tr("Actual Bed"));
- connect(&core->temperature(), &Temperature::bedTemperatureChanged, this, [this](float temp) {
+ connect(core->temperature().get(), &Temperature::bedTemperatureChanged, this, [this](float temp) {
checkTemperature(0x00, 0, temp);
plotWidget->appendPoint(tr("Actual Bed"), temp);
});
plotWidget->addPlot(tr("Target Bed"));
- connect(&core->temperature(), &Temperature::bedTargetTemperatureChanged, this, [this](float temp) {
+ connect(core->temperature().get(), &Temperature::bedTargetTemperatureChanged, this, [this](float temp) {
checkTemperature(0x01, 0, temp);
plotWidget->appendPoint(tr("Target Bed"), temp);
});
plotWidget->addPlot(tr("Actual Ext.1"));
- connect(&core->temperature(), &Temperature::extruderTemperatureChanged, this, [this](float temp) {
+ connect(core->temperature().get(), &Temperature::extruderTemperatureChanged, this, [this](float temp) {
checkTemperature(0x02, 0, temp);
plotWidget->appendPoint(tr("Actual Ext.1"), temp);
});
plotWidget->addPlot(tr("Target Ext.1"));
- connect(&core->temperature(), &Temperature::extruderTargetTemperatureChanged, this, [this](float temp) {
+ connect(core->temperature().get(), &Temperature::extruderTargetTemperatureChanged, this, [this](float temp) {
checkTemperature(0x03, 0, temp);
plotWidget->appendPoint(tr("Target Ext.1"), temp);
});