Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
SensorManager.h
Go to the documentation of this file.
1
12
13#ifndef SENSORMANAGER_H
14#define SENSORMANAGER_H
15
16#include "Particle.h"
17#include "ISensor.h"
18
19extern char internalTempStr[16];
20extern char signalStr[64];
21
33#define measure SensorManager::instance()
34
36public:
40 static SensorManager &instance();
41
45 void setup();
46
52 bool loop();
53
59 void setSensor(ISensor* sensor);
60
65
69 bool isSensorReady() const;
70
78
82 void onEnterSleep();
83
87 void onExitSleep();
88
93
99 float tmp36TemperatureC(int adcValue);
100
110 bool readTmp112TemperatureC(float &tempC);
111
115 bool batteryState();
116
120 bool isItSafeToCharge();
121
125 void getSignalStrength();
126
128
129protected:
131 virtual ~SensorManager();
132 SensorManager(const SensorManager &) = delete;
134
137
140
142 unsigned long _lastPollTime;
143};
144
145#endif /* SENSORMANAGER_H */
char internalTempStr[16]
char signalStr[64]
Abstract interface for all sensors.
Definition ISensor.h:75
float tmp36TemperatureC(int adcValue)
Convert TMP36 ADC reading to degrees Celsius.
void setup()
Initialize the active sensor and any manager state.
SensorManager & operator=(const SensorManager &)=delete
virtual ~SensorManager()
SensorManager(const SensorManager &)=delete
void onExitSleep()
Notify the sensor that the device has woken from deep sleep.
unsigned long _lastPollTime
Timestamp of the last sensor poll (millis).
static SensorManager & instance()
Get the SensorManager singleton instance.
bool isSensorReady() const
Check whether the active sensor is initialized and ready.
bool readTmp112TemperatureC(float &tempC)
Read TMP112A temperature (I2C) in degrees Celsius.
ISensor * _sensor
Currently active sensor implementation (not owned).
SensorData getSensorData() const
Get the latest sensor data from the active sensor.
void initializeFromConfig()
Create and initialize the active sensor based on configuration.
void setSensor(ISensor *sensor)
Set the concrete ISensor implementation to use.
void onEnterSleep()
Notify the sensor that the device is entering deep sleep.
bool isItSafeToCharge()
Determine whether it is safe to charge the battery.
bool batteryState()
Determine whether the battery is present and not critically low.
bool loop()
Poll the active sensor; call from the main loop.
void getSignalStrength()
Update global signal strength strings for logging/telemetry.
static SensorManager * _instance
Pointer to the singleton instance.
Generic sensor data structure.
Definition ISensor.h:23