diff --git a/MHZ.cpp b/MHZ.cpp index e6290d4..39b09b0 100644 --- a/MHZ.cpp +++ b/MHZ.cpp @@ -116,7 +116,9 @@ void MHZ::setDebug(boolean enable, Stream* console) { } boolean MHZ::isPreHeating() { - if (_type == MHZ14A) { + if (_isBypassPreheatingCheck) { + return false; + } else if (_type == MHZ14A) { return millis() < (MHZ14A_PREHEATING_TIME); } else if (_type == MHZ14B) { return millis() < (MHZ14B_PREHEATING_TIME); @@ -133,6 +135,8 @@ boolean MHZ::isPreHeating() { boolean MHZ::isReady() { if (isPreHeating()) { return false; + } else if (_isBypassResponseTimeCheck) { + return true; } else if (_type == MHZ14A) { return getTimeDiff(lastRequest, millis()) > MHZ14A_RESPONSE_TIME; } else if (_type == MHZ14B) { @@ -278,6 +282,11 @@ int MHZ::getLastTemperature() { void MHZ::setTemperatureOffset(uint8_t offset) { _temperatureOffset = offset; } +void MHZ::setBypassCheck(boolean isBypassPreheatingCheck, boolean isBypassResponseTimeCheck) { + _isBypassPreheatingCheck = isBypassPreheatingCheck; + _isBypassResponseTimeCheck = isBypassResponseTimeCheck; +} + int MHZ::getLastCO2() { return sLastPwmPpm; } byte MHZ::getCheckSum(byte* packet) { diff --git a/MHZ.h b/MHZ.h index cc255c1..5e901f7 100644 --- a/MHZ.h +++ b/MHZ.h @@ -51,6 +51,7 @@ class MHZ { void setTemperatureOffset(uint8_t offset); int getLastCO2(); void activateAsyncUARTReading(); + void setBypassCheck(boolean isBypassPreheatingCheck, boolean isBypassResponseTimeCheck); private: static const unsigned long MHZ14A_PREHEATING_TIME = 3L * 60L * 1000L; @@ -68,6 +69,8 @@ class MHZ { uint8_t _temperatureOffset = 44; MeasuringRange _range = RANGE_5K; boolean debug = false; + boolean _isBypassPreheatingCheck = false; + boolean _isBypassResponseTimeCheck = false; Stream *_serial; Stream *_console;