File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,22 @@ void Sgp41::handle(void) {
131
131
}
132
132
133
133
#else
134
+
135
+ void Sgp41::pauseHandle () {
136
+ onPause = true ;
137
+ Serial.println (" Pausing SGP41 handler task" );
138
+ // Set latest value to invalid
139
+ tvocRaw = utils::getInvalidVOC ();
140
+ tvoc = utils::getInvalidVOC ();
141
+ noxRaw = utils::getInvalidNOx ();
142
+ nox = utils::getInvalidNOx ();
143
+ }
144
+
145
+ void Sgp41::resumeHandle () {
146
+ onPause = false ;
147
+ Serial.println (" Resume SGP41 handler task" );
148
+ }
149
+
134
150
/* *
135
151
* @brief Handle the sensor conditioning and run time udpate value, This method
136
152
* must not call, it's called on private task
@@ -152,6 +168,11 @@ void Sgp41::_handle(void) {
152
168
uint16_t srawVoc, srawNox;
153
169
for (;;) {
154
170
vTaskDelay (pdMS_TO_TICKS (1000 ));
171
+
172
+ if (onPause) {
173
+ continue ;
174
+ }
175
+
155
176
if (getRawSignal (srawVoc, srawNox)) {
156
177
tvocRaw = srawVoc;
157
178
noxRaw = srawNox;
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ class Sgp41 {
18
18
bool begin (TwoWire &wire, Stream &stream);
19
19
void handle (void );
20
20
#else
21
+ /* pause _handle task to read sensor */
22
+ void pauseHandle ();
23
+ /* resume _handle task to read sensor */
24
+ void resumeHandle ();
21
25
void _handle (void );
22
26
#endif
23
27
void end (void );
@@ -32,6 +36,7 @@ class Sgp41 {
32
36
int getTvocLearningOffset (void );
33
37
34
38
private:
39
+ bool onPause = false ;
35
40
bool onConditioning = true ;
36
41
bool ready = false ;
37
42
bool _isBegin = false ;
You can’t perform that action at this time.
0 commit comments