forked from meshtastic/firmware
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSCD30Sensor.h
More file actions
55 lines (44 loc) · 1.77 KB
/
Copy pathSCD30Sensor.h
File metadata and controls
55 lines (44 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR && __has_include(<SensirionI2cScd30.h>)
#include "../detect/ReClockI2C.h"
#include "../mesh/generated/meshtastic/telemetry.pb.h"
#include "TelemetrySensor.h"
#include <SensirionI2cScd30.h>
#define SCD30_I2C_CLOCK_SPEED 100000
class SCD30Sensor : public TelemetrySensor
{
private:
SensirionI2cScd30 scd30;
#ifdef SCD30_I2C_CLOCK_SPEED
ReClockI2C reClockI2C;
#endif
bool performFRC(uint16_t targetCO2);
bool setASC(bool ascEnabled);
bool getASC(uint16_t &ascEnabled);
bool setTemperature(float tempReference);
bool getAltitude(uint16_t &altitude);
bool setAltitude(uint16_t altitude);
bool softReset(); //
bool setMeasurementInterval(uint16_t measInterval);
bool getMeasurementInterval(uint16_t &measInterval);
bool startMeasurement();
bool stopMeasurement();
// Parameters
uint16_t ascActive = 1;
uint16_t measurementInterval = 2;
public:
SCD30Sensor();
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
enum SCD30State { SCD30_OFF, SCD30_IDLE, SCD30_MEASUREMENT };
SCD30State state = SCD30_OFF;
virtual bool isActive() override;
virtual void sleep() override; // Stops measurement (measurement -> idle)
virtual uint32_t wakeUp() override; // Starts measurement (idle -> measurement)
virtual bool canSleep() override;
virtual int32_t wakeUpTimeMs() override;
virtual int32_t pendingForReadyMs() override;
AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
meshtastic_AdminMessage *response) override;
};
#endif