A compilation of some hardware sensors and their shared programming interfaces.

Embed: (wiki syntax)

« Back to documentation index

PeriodicSensor Class Reference

PeriodicSensor Class Reference

Abstract class from which most sensor classes can be derived. More...

#include <PeriodicSensor.h>

Inherited by ADCSensor, INA219, MAG3110, MAX17043, MMA8451Q, and TouchSensor.

Public Member Functions

 PeriodicSensor ()
 Constructs a PeriodicSensor object.
 PeriodicSensor (float min_sampling_period)
 Constructs a PeriodicSensor object with a custom minimum sampling period (must be positive).
 ~PeriodicSensor ()
 Destroys the object.
bool isDataReady ()
void enableBackgroundSampling (bool enable, float sample_period)
 Control the background sampling of the device via interrupts.
bool isBackgroundSamplingEnabled ()
float getSamplePeriod ()
float getMinSamplePeriod ()

Detailed Description

Abstract class from which most sensor classes can be derived.

This class implements interrupt-driven periodic sampling

Definition at line 16 of file PeriodicSensor.h.


Constructor & Destructor Documentation

Constructs a PeriodicSensor object.

Default minimum sampling period is set to 0.05 sec.

Definition at line 10 of file PeriodicSensor.cpp.

PeriodicSensor ( float  min_sampling_period )

Constructs a PeriodicSensor object with a custom minimum sampling period (must be positive).

Definition at line 19 of file PeriodicSensor.cpp.

Destroys the object.

Definition at line 30 of file PeriodicSensor.cpp.


Member Function Documentation

void enableBackgroundSampling ( bool  enable,
float  sample_period 
)

Control the background sampling of the device via interrupts.

If disabled, the device can still be sampled using the getter methods directly.

Parameters:
enableif true, enables background sampling with the given sample period.
sample_periodsampling period in seconds. Must be at least 0.005 sec unless enable is false, in which case it is don't care.

Definition at line 36 of file PeriodicSensor.cpp.

float getMinSamplePeriod (  )
Returns:
the minimum sample period in seconds

Definition at line 57 of file PeriodicSensor.cpp.

float getSamplePeriod (  )
Returns:
the sample period in seconds, if background sampling is enabled. Else, non-positive return.

Definition at line 53 of file PeriodicSensor.cpp.

bool isBackgroundSamplingEnabled (  )
Returns:
true if background sampling is enabled.

Definition at line 49 of file PeriodicSensor.cpp.

bool isDataReady (  )
Returns:
true if there is new data ready to be retrieved.

Definition at line 32 of file PeriodicSensor.cpp.