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

LinearAnalogSensor.h « Sensors « Heating « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 046dd6aa042b6098aebd582f1e2cd7f6f2aba84d (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
/*
 * LinearAnalogSensor.h
 *
 *  Created on: 16 Apr 2019
 *      Author: David
 */

#ifndef SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_
#define SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_

#include "SensorWithPort.h"

class LinearAnalogSensor : public SensorWithPort
{
public:
	LinearAnalogSensor(unsigned int sensorNum);

	GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) override;

	static constexpr const char *TypeName = "linearanalog";

	void Poll() override;

private:
	void CalcDerivedParameters();

	// Configurable parameters
	float lowTemp, highTemp;
	bool filtered;

	// Derived parameters
	int adcFilterChannel;
	float linearIncreasePerCount;

	static constexpr float DefaultLowTemp = 0.0;
	static constexpr float DefaultHighTemp = 100.0;

	// ADC resolution
	static constexpr unsigned int AdcBits = 12;										// the ADCs in the SAM processors are 12-bit
	static constexpr int32_t UnfilteredAdcRange = 1 << AdcBits;						// The readings we pass in should be in range 0..(AdcRange - 1)
	static constexpr unsigned int AdcOversampleBits = 2;							// we use 2-bit oversampling
	static constexpr int32_t FilteredAdcRange = 1 << (AdcBits + AdcOversampleBits);	// The readings we pass in should be in range 0..(AdcRange - 1)
};

#endif /* SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_ */