Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SensorWithPort.cpp « Sensors « Heating « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7609ad81282923f1938776538e90c6cf72d158f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * SensorWithPort.cpp
 *
 *  Created on: 18 Jul 2019
 *      Author: David
 */

#include "SensorWithPort.h"
#include "GCodes/GCodeBuffer/GCodeBuffer.h"

SensorWithPort::SensorWithPort(unsigned int sensorNum, const char *type)
	: TemperatureSensor(sensorNum, type)
{
}

SensorWithPort::~SensorWithPort()
{
	port.Release();
}

// Try to configure the port. Return true if the port is valid at the end, else return false and set the error message in 'reply'. Set 'seen' if we saw the P parameter.
bool SensorWithPort::ConfigurePort(GCodeBuffer& gb, const StringRef& reply, PinAccess access, bool& seen)
{
	if (gb.Seen('P'))
	{
		seen = true;
		return port.AssignPort(gb, reply, PinUsedBy::sensor, access);
	}
	if (port.IsValid())
	{
		return true;
	}
	reply.copy("Missing port name parameter");
	return false;
}

// Copy the basic details to the reply buffer. This hides the version in the base class.
void SensorWithPort::CopyBasicDetails(const StringRef& reply) const
{
	reply.printf("Sensor %u", GetSensorNumber());
	if (GetSensorName() != nullptr)
	{
		reply.catf(" (%s)", GetSensorName());
	}
	reply.catf(" type %s using pin ", GetSensorType());
	port.AppendPinName(reply);
	reply.catf(", reading %.1f, last error: %s", (double)GetStoredReading(), TemperatureErrorString(GetLastError()));
}

// End