Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking Operation of Single Shot Measurement Now Optional #36

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/SensirionI2CScd4x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ uint16_t SensirionI2CScd4x::reinit() {
return error;
}

uint16_t SensirionI2CScd4x::measureSingleShot() {
uint16_t SensirionI2CScd4x::measureSingleShot(bool blocking) {
uint16_t error;
uint8_t buffer[2];
SensirionI2CTxFrame txFrame(buffer, 2);
Expand All @@ -600,7 +600,11 @@ uint16_t SensirionI2CScd4x::measureSingleShot() {

error = SensirionI2CCommunication::sendFrame(SCD4X_I2C_ADDRESS, txFrame,
*_i2cBus);
delay(5000);

if (blocking) {
delay(5000);
}

return error;
}

Expand Down
4 changes: 3 additions & 1 deletion src/SensirionI2CScd4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,13 @@ class SensirionI2CScd4x {
* relative humidity and temperature. The sensor output is read with the
* read_measurement command.
*
* @param blocking Delay for 5 seconds till on-demand measurement is available
*
* @note Only available in idle mode.
*
* @return 0 on success, an error code otherwise
*/
uint16_t measureSingleShot(void);
uint16_t measureSingleShot(bool blocking = true);

/**
* measureSingleShotRhtOnly() - On-demand measurement of relative humidity
Expand Down
Loading