|
Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
|
#include <SensorManager.h>
Public Member Functions | |
| SensorData | getSensorData () const |
| Get the latest sensor data from the active sensor. | |
| void | initializeFromConfig () |
| Create and initialize the active sensor based on configuration. | |
| bool | isSensorReady () const |
| Check whether the active sensor is initialized and ready. | |
| bool | loop () |
| Poll the active sensor; call from the main loop. | |
| void | onEnterSleep () |
| Notify the sensor that the device is entering deep sleep. | |
| void | onExitSleep () |
| Notify the sensor that the device has woken from deep sleep. | |
| void | setSensor (ISensor *sensor) |
| Set the concrete ISensor implementation to use. | |
| void | setup () |
| Initialize the active sensor and any manager state. | |
Utility functions | |
Helpers for temperature, battery, radio signal, and delays. | |
| float | tmp36TemperatureC (int adcValue) |
| Convert TMP36 ADC reading to degrees Celsius. | |
| bool | readTmp112TemperatureC (float &tempC) |
| Read TMP112A temperature (I2C) in degrees Celsius. | |
| bool | batteryState () |
| Determine whether the battery is present and not critically low. | |
| bool | isItSafeToCharge () |
| Determine whether it is safe to charge the battery. | |
| void | getSignalStrength () |
| Update global signal strength strings for logging/telemetry. | |
Static Public Member Functions | |
| static SensorManager & | instance () |
| Get the SensorManager singleton instance. | |
Protected Member Functions | |
| SensorManager & | operator= (const SensorManager &)=delete |
| SensorManager () | |
| SensorManager (const SensorManager &)=delete | |
| virtual | ~SensorManager () |
Protected Attributes | |
| unsigned long | _lastPollTime |
| Timestamp of the last sensor poll (millis). | |
| ISensor * | _sensor |
| Currently active sensor implementation (not owned). | |
Static Protected Attributes | |
| static SensorManager * | _instance |
| Pointer to the singleton instance. | |
Definition at line 35 of file SensorManager.h.
|
protected |
Definition at line 28 of file SensorManager.cpp.
References _lastPollTime, and _sensor.
Referenced by instance(), operator=(), and SensorManager().
|
protectedvirtual |
Definition at line 30 of file SensorManager.cpp.
|
protecteddelete |
References SensorManager().
| bool SensorManager::batteryState | ( | ) |
Determine whether the battery is present and not critically low.
Definition at line 225 of file SensorManager.cpp.
References batteryContext, current, isItSafeToCharge(), readTmp112TemperatureC(), sysStatus, TMP36_SENSE_PIN, and tmp36TemperatureC().
| SensorData SensorManager::getSensorData | ( | ) | const |
Get the latest sensor data from the active sensor.
Definition at line 105 of file SensorManager.cpp.
References _sensor.
| void SensorManager::getSignalStrength | ( | ) |
Update global signal strength strings for logging/telemetry.
Definition at line 652 of file SensorManager.cpp.
References signalStr.
| void SensorManager::initializeFromConfig | ( | ) |
Create and initialize the active sensor based on configuration.
Uses sysStatus.get_sensorType() and SensorFactory to select the concrete implementation, then calls the sensor's initializeHardware().
Definition at line 56 of file SensorManager.cpp.
References _sensor, SensorFactory::createSensor(), setSensor(), and sysStatus.
Referenced by ensureSensorEnabled(), handleSleepingState(), and setup().
|
static |
Get the SensorManager singleton instance.
Definition at line 22 of file SensorManager.cpp.
References _instance, and SensorManager().
Referenced by ensureSensorEnabled(), handleCountingMode(), handleIdleState(), handleOccupancyMode(), handleSleepingState(), and setup().
| bool SensorManager::isItSafeToCharge | ( | ) |
Determine whether it is safe to charge the battery.
Definition at line 600 of file SensorManager.cpp.
References current, and sysStatus.
Referenced by batteryState().
| bool SensorManager::isSensorReady | ( | ) | const |
Check whether the active sensor is initialized and ready.
Definition at line 112 of file SensorManager.cpp.
References _sensor.
| bool SensorManager::loop | ( | ) |
Poll the active sensor; call from the main loop.
Definition at line 78 of file SensorManager.cpp.
References _lastPollTime, _sensor, sensorConfig, and sysStatus.
| void SensorManager::onEnterSleep | ( | ) |
Notify the sensor that the device is entering deep sleep.
Definition at line 116 of file SensorManager.cpp.
References _sensor, disableModule, and ledPower.
Referenced by handleSleepingState(), and setup().
| void SensorManager::onExitSleep | ( | ) |
Notify the sensor that the device has woken from deep sleep.
Definition at line 132 of file SensorManager.cpp.
References _sensor.
Referenced by ensureSensorEnabled(), and handleSleepingState().
|
protecteddelete |
References SensorManager().
| bool SensorManager::readTmp112TemperatureC | ( | float & | tempC | ) |
Read TMP112A temperature (I2C) in degrees Celsius.
Intended for platforms/carriers (like Muon) that include an onboard TMP112A temperature sensor.
| [out] | tempC | Filled with temperature in degrees Celsius on success. |
Definition at line 165 of file SensorManager.cpp.
Referenced by batteryState().
| void SensorManager::setSensor | ( | ISensor * | sensor | ) |
Set the concrete ISensor implementation to use.
| sensor | Pointer to a concrete ISensor (not owned). |
Definition at line 47 of file SensorManager.cpp.
References _sensor, and ISensor::getSensorType().
Referenced by initializeFromConfig().
| void SensorManager::setup | ( | ) |
Initialize the active sensor and any manager state.
Definition at line 32 of file SensorManager.cpp.
References _sensor.
| float SensorManager::tmp36TemperatureC | ( | int | adcValue | ) |
Convert TMP36 ADC reading to degrees Celsius.
| adcValue | Raw ADC value from the TMP36 input. |
Definition at line 144 of file SensorManager.cpp.
Referenced by batteryState().
|
staticprotected |
Pointer to the singleton instance.
Definition at line 136 of file SensorManager.h.
Referenced by instance().
|
protected |
Timestamp of the last sensor poll (millis).
Definition at line 142 of file SensorManager.h.
Referenced by loop(), and SensorManager().
|
protected |
Currently active sensor implementation (not owned).
Definition at line 139 of file SensorManager.h.
Referenced by getSensorData(), initializeFromConfig(), isSensorReady(), loop(), onEnterSleep(), onExitSleep(), SensorManager(), setSensor(), and setup().