Skip to content

Commit 7c3a958

Browse files
committed
Cal Fix
1 parent 083ae01 commit 7c3a958

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/MHZ19.cpp

+12-15
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,11 @@ void MHZ19::autoCalibration(bool isON, byte ABCPeriod)
437437
}
438438
/* If no period was defined (for safety, even though default argument is given)*/
439439
else
440-
ABCPeriod = 160; // Default bytes
440+
ABCPeriod = MHZ19_ABC_PERIOD_DEF; // Default bytes
441441
}
442442
/* If ABC is OFF */
443443
else
444-
ABCPeriod = 0x00; // Set command byte to Zero to match command format.
444+
ABCPeriod = MHZ19_ABC_PERIOD_OFF; // Set command byte to Zero to match command format.
445445

446446
/* Update storage */
447447
this->storage.settings.ABCRepeat = !isON; // Set to opposite, as repeat command is sent only when ABC is OFF.
@@ -756,19 +756,16 @@ byte MHZ19::getCRC(byte inBytes[])
756756
}
757757

758758
void MHZ19::ABCCheck()
759-
{
760-
/* check timer interval if dynamic hours have passed and if ABC_OFF was set to true */
761-
if (((millis() - ABCRepeatTimer) >= 4.32e7) && (this->storage.settings.ABCRepeat == true))
762-
{
763-
/* update timer inerval */
764-
ABCRepeatTimer = millis();
765-
766-
/* construct ABC_OFF command */
767-
constructCommand(ABC);
768-
769-
/* write to serial */
770-
write(this->storage.constructedCommand);
771-
}
759+
{
760+
/* check timer interval if dynamic hours have passed and if ABC_OFF was set to true */
761+
if (((millis() - ABCRepeatTimer) >= 4.32e7) && (this->storage.settings.ABCRepeat == true))
762+
{
763+
/* update timer inerval */
764+
ABCRepeatTimer = millis();
765+
766+
/* construct command to skip next ABC cycle */
767+
provisioning(ABC, MHZ19_ABC_PERIOD_OFF);
768+
}
772769
}
773770

774771
void MHZ19::makeByte(int inInt, byte *high, byte *low)

src/MHZ19.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
#define MHZ19_DATA_LEN 9 // Data protocl length
2929

30+
// Command bytes -------------------------- //
31+
#define MHZ19_ABC_PERIOD_OFF 0x00
32+
#define MHZ19_ABC_PERIOD_DEF 0xA0
33+
3034
/* enum alias for error code defintions */
3135
enum ERRORCODE
3236
{

0 commit comments

Comments
 (0)