Skip to content

Commit

Permalink
Allows to bypass preheating and response time check
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarseguerra authored and tobiasschuerg committed Oct 25, 2023
1 parent 59c6412 commit c83ba47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion MHZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions MHZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c83ba47

Please sign in to comment.