Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
ISensor Class Referenceabstract

Abstract interface for all sensors. More...

#include <ISensor.h>

Inheritance diagram for ISensor:
PIRSensor

Public Member Functions

virtual SensorData getData () const =0
 Get the latest sensor data.
virtual const char * getSensorType () const =0
 Get sensor type identifier.
virtual bool initializeHardware ()
 Initialize underlying hardware after power-on.
virtual bool isHealthy () const
 Health check for the sensor.
virtual bool isReady () const =0
 Check if sensor is initialized and ready.
virtual int lastErrorCode () const
 Last sensor-specific error code (if any).
virtual bool loop ()=0
 Poll the sensor for new data.
virtual void onSleep ()
 Notification that the device is entering deep sleep.
virtual bool onWake ()
 Notification that the device is waking from deep sleep.
virtual void reset ()=0
 Reset sensor state and clear any cached data.
virtual bool setup ()=0
 Initialize the sensor hardware.
virtual bool usesInterrupt () const
 Whether this sensor uses a hardware interrupt for events.
virtual ~ISensor ()

Detailed Description

Abstract interface for all sensors.

This allows the main code to work with any sensor type without knowing the implementation details. All sensors must implement this interface.

Definition at line 75 of file ISensor.h.

Constructor & Destructor Documentation

◆ ~ISensor()

virtual ISensor::~ISensor ( )
inlinevirtual

Definition at line 77 of file ISensor.h.

Member Function Documentation

◆ getData()

virtual SensorData ISensor::getData ( ) const
pure virtual

Get the latest sensor data.

Returns
SensorData structure with current readings

Implemented in PIRSensor.

◆ getSensorType()

virtual const char * ISensor::getSensorType ( ) const
pure virtual

Get sensor type identifier.

Returns
Pointer to const char identifying the sensor type (must remain valid)

Implemented in PIRSensor.

Referenced by SensorManager::setSensor().

◆ initializeHardware()

virtual bool ISensor::initializeHardware ( )
inlinevirtual

Initialize underlying hardware after power-on.

Default implementation just calls setup(); sensors with more complex power sequencing can override this.

Definition at line 120 of file ISensor.h.

References setup().

◆ isHealthy()

virtual bool ISensor::isHealthy ( ) const
inlinevirtual

Health check for the sensor.

Return false if a fault has been detected (e.g. stuck interrupt line, repeated I2C errors, etc.).

Definition at line 147 of file ISensor.h.

◆ isReady()

virtual bool ISensor::isReady ( ) const
pure virtual

Check if sensor is initialized and ready.

Returns
true if ready, false otherwise

Implemented in PIRSensor.

◆ lastErrorCode()

virtual int ISensor::lastErrorCode ( ) const
inlinevirtual

Last sensor-specific error code (if any).

Definition at line 152 of file ISensor.h.

◆ loop()

virtual bool ISensor::loop ( )
pure virtual

Poll the sensor for new data.

Returns
true if new data is available and stored, false otherwise

Implemented in PIRSensor.

◆ onSleep()

virtual void ISensor::onSleep ( )
inlinevirtual

Notification that the device is entering deep sleep.

Sensors can override to detach interrupts and power down.

Reimplemented in PIRSensor.

Definition at line 127 of file ISensor.h.

◆ onWake()

virtual bool ISensor::onWake ( )
inlinevirtual

Notification that the device is waking from deep sleep.

Return false if the sensor failed to reinitialize correctly.

Reimplemented in PIRSensor.

Definition at line 134 of file ISensor.h.

◆ reset()

virtual void ISensor::reset ( )
pure virtual

Reset sensor state and clear any cached data.

Implemented in PIRSensor.

◆ setup()

virtual bool ISensor::setup ( )
pure virtual

Initialize the sensor hardware.

Returns
true if successful, false otherwise

Implemented in PIRSensor.

Referenced by initializeHardware().

◆ usesInterrupt()

virtual bool ISensor::usesInterrupt ( ) const
inlinevirtual

Whether this sensor uses a hardware interrupt for events.

Reimplemented in PIRSensor.

Definition at line 139 of file ISensor.h.


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