mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-31 02:45:41 +00:00
Fixes on PMS class
This commit is contained in:
parent
a1c6fdb5a0
commit
a10e316893
@ -74,7 +74,7 @@ int32_t AirQualityTelemetryModule::runOnce()
|
|||||||
|
|
||||||
// Wake up the sensors that need it
|
// Wake up the sensors that need it
|
||||||
#ifdef PMSA003I_ENABLE_PIN
|
#ifdef PMSA003I_ENABLE_PIN
|
||||||
if (pmsa003iSensor.hasSensor() && pmsa003iSensor.state == pmsa003iSensor::State::IDLE)
|
if (pmsa003iSensor.hasSensor() && !pmsa003iSensor.isActive())
|
||||||
return pmsa003iSensor.wakeUp();
|
return pmsa003iSensor.wakeUp();
|
||||||
#endif /* PMSA003I_ENABLE_PIN */
|
#endif /* PMSA003I_ENABLE_PIN */
|
||||||
|
|
||||||
|
@ -48,24 +48,31 @@ int32_t PMSA003ISensor::runOnce()
|
|||||||
|
|
||||||
void PMSA003ISensor::setup()
|
void PMSA003ISensor::setup()
|
||||||
{
|
{
|
||||||
|
#ifdef PMSA003I_ENABLE_PIN
|
||||||
|
pinMode(PMSA003I_ENABLE_PIN, OUTPUT);
|
||||||
|
#endif /* PMSA003I_ENABLE_PIN */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PMSA003I_ENABLE_PIN
|
#ifdef PMSA003I_ENABLE_PIN
|
||||||
void sleep() {
|
void PMSA003ISensor::sleep() {
|
||||||
digitalWrite(PMSA003I_ENABLE_PIN, LOW);
|
digitalWrite(PMSA003I_ENABLE_PIN, LOW);
|
||||||
state = State::IDLE;
|
state = State::IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t wakeUp() {
|
uint32_t PMSA003ISensor::wakeUp() {
|
||||||
digitalWrite(PMSA003I_ENABLE_PIN, HIGH);
|
digitalWrite(PMSA003I_ENABLE_PIN, HIGH);
|
||||||
state = State::ACTIVE;
|
state = State::ACTIVE;
|
||||||
}
|
}
|
||||||
#endif /* PMSA003I_ENABLE_PIN */
|
#endif /* PMSA003I_ENABLE_PIN */
|
||||||
|
|
||||||
|
bool PMSA003ISensor::isActive() {
|
||||||
|
return state == State::ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
bool PMSA003ISensor::getMetrics(meshtastic_Telemetry *measurement)
|
bool PMSA003ISensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||||
{
|
{
|
||||||
if (!pmsa003i.read(&pmsa003iData)) {
|
if (!pmsa003i.read(&pmsa003iData)) {
|
||||||
LOG_WARN("Skip send measurements. Could not read AQIn");
|
LOG_WARN("Skip send measurements. Could not read AQI");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ class PMSA003ISensor : public TelemetrySensor
|
|||||||
// the PMSA003I sensor uses about 300mW on its own; support powering it off when it's not actively taking
|
// the PMSA003I sensor uses about 300mW on its own; support powering it off when it's not actively taking
|
||||||
// a reading
|
// a reading
|
||||||
// put the sensor to sleep on startup
|
// put the sensor to sleep on startup
|
||||||
pinMode(PMSA003I_ENABLE_PIN, OUTPUT);
|
|
||||||
State state = State::IDLE;
|
State state = State::IDLE;
|
||||||
#else
|
#else
|
||||||
State state = State::ACTIVE;
|
State state = State::ACTIVE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PMSA003ISensor();
|
PMSA003ISensor();
|
||||||
|
bool isActive();
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user