49 float shuntResistance,
float maxPressure,
50 float minCurrent = 4,
float maxCurrent = 20)
51 : getVoltage{getVoltage}, shuntResistance{shuntResistance},
52 maxPressure{maxPressure}, minCurrent{minCurrent},
53 maxCurrent{maxCurrent}
57 bool init()
override {
return true; }
64 auto voltage = getVoltage();
65 return {voltage.voltageTimestamp, voltageToPressure(voltage.voltage)};
69 float voltageToPressure(
float voltage)
72 float current = (voltage / shuntResistance) * 1000.0f;
75 float value = (current - minCurrent) / (maxCurrent - minCurrent);
78 return value * maxPressure;
81 std::function<ADCData()> getVoltage;
83 const float shuntResistance;
84 const float maxPressure;
85 const float minCurrent;
86 const float maxCurrent;
Base sensor class with has to be extended by any sensor driver.
Sensor class for a Trafag pressure sensor.
bool init() override
Initialize the sensor.
bool selfTest() override
Check if the sensor is working.
PressureData sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
TrafagPressureSensor(std::function< ADCData()> getVoltage, float shuntResistance, float maxPressure, float minCurrent=4, float maxCurrent=20)
Construct a TrafagPressureSensor.
This file includes all the types the logdecoder script will decode.
Structure to handle ADC data.