Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::CurrentSensor Class Reference

Common class for current sensors. More...

#include <CurrentSensor.h>

Inheritance diagram for Boardcore::CurrentSensor:
Collaboration diagram for Boardcore::CurrentSensor:

Public Member Functions

 CurrentSensor (std::function< ADCData()> getVoltage, std::function< float(float)> voltageToCurrent)
 
bool init () override
 Initialize the sensor.
 
bool selfTest () override
 Check if the sensor is working.
 
- Public Member Functions inherited from Boardcore::Sensor< CurrentData >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual CurrentData getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 

Static Public Attributes

static constexpr int MOVING_AVERAGE_N = 20
 

Protected Member Functions

CurrentData sampleImpl () override
 < Converts the voltage value to pressure
 

Additional Inherited Members

- Public Types inherited from Boardcore::Sensor< CurrentData >
using DataType
 
- Protected Attributes inherited from Boardcore::Sensor< CurrentData >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Detailed Description

Common class for current sensors.

It needs a transfer function to convert the read voltage into current.

Definition at line 37 of file CurrentSensor.h.

Constructor & Destructor Documentation

◆ CurrentSensor()

Boardcore::CurrentSensor::CurrentSensor ( std::function< ADCData()> getVoltage,
std::function< float(float)> voltageToCurrent )
inline

Definition at line 42 of file CurrentSensor.h.

Member Function Documentation

◆ init()

bool Boardcore::CurrentSensor::init ( )
inlineoverridevirtual

Initialize the sensor.

Returns
boolean value indicating whether the operation succeded or not

Implements Boardcore::AbstractSensor.

Definition at line 49 of file CurrentSensor.h.

◆ sampleImpl()

CurrentData Boardcore::CurrentSensor::sampleImpl ( )
inlineoverrideprotectedvirtual

< Converts the voltage value to pressure

Implements Boardcore::Sensor< CurrentData >.

Definition at line 55 of file CurrentSensor.h.

◆ selfTest()

bool Boardcore::CurrentSensor::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 51 of file CurrentSensor.h.

Member Data Documentation

◆ MOVING_AVERAGE_N

constexpr int Boardcore::CurrentSensor::MOVING_AVERAGE_N = 20
staticconstexpr

Definition at line 40 of file CurrentSensor.h.


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