forked from airgradienthq/arduino
SGP41 add method to pause and resume task handle
This commit is contained in:
@@ -131,6 +131,22 @@ void Sgp41::handle(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
void Sgp41::pauseHandle() {
|
||||||
|
onPause = true;
|
||||||
|
Serial.println("Pausing SGP41 handler task");
|
||||||
|
// Set latest value to invalid
|
||||||
|
tvocRaw = utils::getInvalidVOC();
|
||||||
|
tvoc = utils::getInvalidVOC();
|
||||||
|
noxRaw = utils::getInvalidNOx();
|
||||||
|
nox = utils::getInvalidNOx();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sgp41::resumeHandle() {
|
||||||
|
onPause = false;
|
||||||
|
Serial.println("Resume SGP41 handler task");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle the sensor conditioning and run time udpate value, This method
|
* @brief Handle the sensor conditioning and run time udpate value, This method
|
||||||
* must not call, it's called on private task
|
* must not call, it's called on private task
|
||||||
@@ -152,6 +168,11 @@ void Sgp41::_handle(void) {
|
|||||||
uint16_t srawVoc, srawNox;
|
uint16_t srawVoc, srawNox;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
|
|
||||||
|
if (onPause) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (getRawSignal(srawVoc, srawNox)) {
|
if (getRawSignal(srawVoc, srawNox)) {
|
||||||
tvocRaw = srawVoc;
|
tvocRaw = srawVoc;
|
||||||
noxRaw = srawNox;
|
noxRaw = srawNox;
|
||||||
|
@@ -18,6 +18,10 @@ public:
|
|||||||
bool begin(TwoWire &wire, Stream &stream);
|
bool begin(TwoWire &wire, Stream &stream);
|
||||||
void handle(void);
|
void handle(void);
|
||||||
#else
|
#else
|
||||||
|
/* pause _handle task to read sensor */
|
||||||
|
void pauseHandle();
|
||||||
|
/* resume _handle task to read sensor */
|
||||||
|
void resumeHandle();
|
||||||
void _handle(void);
|
void _handle(void);
|
||||||
#endif
|
#endif
|
||||||
void end(void);
|
void end(void);
|
||||||
@@ -32,6 +36,7 @@ public:
|
|||||||
int getTvocLearningOffset(void);
|
int getTvocLearningOffset(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool onPause = false;
|
||||||
bool onConditioning = true;
|
bool onConditioning = true;
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
bool _isBegin = false;
|
bool _isBegin = false;
|
||||||
|
Reference in New Issue
Block a user