Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::AnalogPressureSensor< AnalogPressureData > Class Template Referenceabstract

Common class for all analog pressure sensors. More...

#include <AnalogPressureSensor.h>

Inheritance diagram for Boardcore::AnalogPressureSensor< AnalogPressureData >:
Collaboration diagram for Boardcore::AnalogPressureSensor< AnalogPressureData >:

Public Member Functions

 AnalogPressureSensor (std::function< ADCData()> getVoltage, const float supplyVoltage=5.0, const float maxPressure=0, const float minPressure=0)
 
 AnalogPressureSensor (AnalogPressureSensor &&other)
 
bool init () override
 Initialize the sensor.
 
bool selfTest () override
 Check if the sensor is working.
 
void setOffset (float value)
 Set the current analog pressure sensor offset. Ignores any previous offsets.
 
void updateOffset (float value)
 Update the current analog pressure sensor offset. Adds the new value to the old offset.
 
float getOffset ()
 Retrieve the current offset.
 
- Public Member Functions inherited from Boardcore::Sensor< AnalogPressureData >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual AnalogPressureData getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 

Protected Member Functions

AnalogPressureData sampleImpl () override
 Conversion function from volts to pascals.
 
virtual float voltageToPressure (float voltage)=0
 Function that returns the sensor voltage.
 

Protected Attributes

std::function< ADCData()> getVoltage
 
miosix::FastMutex offsetMutex
 
float offset = 0
 
const float supplyVoltage
 
const float maxPressure
 
const float minPressure
 
- Protected Attributes inherited from Boardcore::Sensor< AnalogPressureData >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Additional Inherited Members

- Public Types inherited from Boardcore::Sensor< AnalogPressureData >
using DataType
 

Detailed Description

template<typename AnalogPressureData>
class Boardcore::AnalogPressureSensor< AnalogPressureData >

Common class for all analog pressure sensors.

All analog pressure sensors have a transfer function to convert the read voltage into pressure and a range within which they operate.

Definition at line 39 of file AnalogPressureSensor.h.

Constructor & Destructor Documentation

◆ AnalogPressureSensor() [1/2]

template<typename AnalogPressureData >
Boardcore::AnalogPressureSensor< AnalogPressureData >::AnalogPressureSensor ( std::function< ADCData()> getVoltage,
const float supplyVoltage = 5.0,
const float maxPressure = 0,
const float minPressure = 0 )
inline

Definition at line 42 of file AnalogPressureSensor.h.

◆ AnalogPressureSensor() [2/2]

template<typename AnalogPressureData >
Boardcore::AnalogPressureSensor< AnalogPressureData >::AnalogPressureSensor ( AnalogPressureSensor< AnalogPressureData > && other)
inline

Definition at line 51 of file AnalogPressureSensor.h.

Member Function Documentation

◆ getOffset()

template<typename AnalogPressureData >
float Boardcore::AnalogPressureSensor< AnalogPressureData >::getOffset ( )
inline

Retrieve the current offset.

Definition at line 85 of file AnalogPressureSensor.h.

◆ init()

template<typename AnalogPressureData >
bool Boardcore::AnalogPressureSensor< AnalogPressureData >::init ( )
inlineoverridevirtual

Initialize the sensor.

Returns
boolean value indicating whether the operation succeded or not

Implements Boardcore::AbstractSensor.

Definition at line 58 of file AnalogPressureSensor.h.

◆ sampleImpl()

template<typename AnalogPressureData >
AnalogPressureData Boardcore::AnalogPressureSensor< AnalogPressureData >::sampleImpl ( )
inlineoverrideprotectedvirtual

Conversion function from volts to pascals.

Implements Boardcore::Sensor< AnalogPressureData >.

Definition at line 92 of file AnalogPressureSensor.h.

◆ selfTest()

template<typename AnalogPressureData >
bool Boardcore::AnalogPressureSensor< AnalogPressureData >::selfTest ( )
inlineoverridevirtual

Check if the sensor is working.

Returns
boolean indicating whether the sensor is correctly working or not

Implements Boardcore::AbstractSensor.

Definition at line 60 of file AnalogPressureSensor.h.

◆ setOffset()

template<typename AnalogPressureData >
void Boardcore::AnalogPressureSensor< AnalogPressureData >::setOffset ( float value)
inline

Set the current analog pressure sensor offset. Ignores any previous offsets.

Definition at line 66 of file AnalogPressureSensor.h.

◆ updateOffset()

template<typename AnalogPressureData >
void Boardcore::AnalogPressureSensor< AnalogPressureData >::updateOffset ( float value)
inline

Update the current analog pressure sensor offset. Adds the new value to the old offset.

Definition at line 76 of file AnalogPressureSensor.h.

◆ voltageToPressure()

Member Data Documentation

◆ getVoltage

template<typename AnalogPressureData >
std::function<ADCData()> Boardcore::AnalogPressureSensor< AnalogPressureData >::getVoltage
protected

Definition at line 122 of file AnalogPressureSensor.h.

◆ maxPressure

template<typename AnalogPressureData >
const float Boardcore::AnalogPressureSensor< AnalogPressureData >::maxPressure
protected

Definition at line 129 of file AnalogPressureSensor.h.

◆ minPressure

template<typename AnalogPressureData >
const float Boardcore::AnalogPressureSensor< AnalogPressureData >::minPressure
protected

Definition at line 130 of file AnalogPressureSensor.h.

◆ offset

template<typename AnalogPressureData >
float Boardcore::AnalogPressureSensor< AnalogPressureData >::offset = 0
protected

Definition at line 126 of file AnalogPressureSensor.h.

◆ offsetMutex

template<typename AnalogPressureData >
miosix::FastMutex Boardcore::AnalogPressureSensor< AnalogPressureData >::offsetMutex
protected

Definition at line 125 of file AnalogPressureSensor.h.

◆ supplyVoltage

template<typename AnalogPressureData >
const float Boardcore::AnalogPressureSensor< AnalogPressureData >::supplyVoltage
protected

Definition at line 128 of file AnalogPressureSensor.h.


The documentation for this class was generated from the following file: