blob: 43c7f61b51303209168d52ff11301a813de63aa5 (
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) noexcept;
GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) override;
static constexpr const char *TypeName = "linearanalog";
void Poll() noexcept override;
private:
void CalcDerivedParameters() noexcept;
// 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_ */
|