49 float shuntResistance,
float maxPressure,
50 float minCurrent = 4,
float maxCurrent = 20)
51 : getVoltage{
std::move(getVoltage)}, shuntResistance{shuntResistance},
52 maxPressure{maxPressure}, minCurrent{minCurrent},
53 maxCurrent{maxCurrent}
57 bool init()
override {
return true; }
68 auto voltage = getVoltage();
69 return {voltage.voltageTimestamp, voltageToPressure(voltage.voltage)};
73 float voltageToPressure(
float voltage)
76 float current = (voltage / shuntResistance) * 1000.0f;
79 float value = (current - minCurrent) / (maxCurrent - minCurrent);
82 return value * maxPressure;
85 std::function<VoltageData()> getVoltage;
87 float shuntResistance;
88 const float maxPressure;
89 const float minCurrent;
90 const float maxCurrent;
Base sensor class with has to be extended by any sensor driver.
Sensor class for a Trafag pressure sensor.
TrafagPressureSensor(std::function< VoltageData()> getVoltage, float shuntResistance, float maxPressure, float minCurrent=4, float maxCurrent=20)
Construct a TrafagPressureSensor.
bool init() override
Initialize the sensor.
float getShuntResistance() const
void setShuntResistance(float resistance)
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...
Driver for the VN100S IMU.
Structure to handle voltage data.