Added a function to the pressure sensor API to be able to know if a measurement is currently being made

This commit is contained in:
Th3maz1ng 2023-04-10 21:12:01 +02:00
parent f4ffc96d5a
commit efae9a917e
2 changed files with 19 additions and 0 deletions

View File

@ -113,6 +113,16 @@ bool BMP280_trigger_measurement(void)
return i2c_write_reg(BMP280_I2C_ADDR, BMP280_CTRL_MEAS, data);
}
bool BMP280_is_measuring(void)
{
uint8_t data;
if(!i2c_read_reg(BMP280_I2C_ADDR, BMP280_STATUS, &data)) return false;
/* If bit 3 of the status register is 1, then a measurement is ongoing */
return (data >> 3) & 0x01;
}
float BMP280_get_temperature(void)
{
int32_t var1, var2;

View File

@ -110,6 +110,15 @@ bool BMP280_configure(BMP280_Mode_e mode, BMP280_Oversampling_e temperature_over
*/
bool BMP280_trigger_measurement(void);
/**
* @brief Checks if the sensor is currently performing a measurement or not.
* This can be useful to check if the measurement is ready after calling @ref BMP280_trigger_measurement.
*
* @return true if the sensor is currently performing a measurement.
* @return false if the sensor is not, this means that the data is ready to be read.
*/
bool BMP280_is_measuring(void);
/**
* @brief Returns the previously sampled temperature in °C.
*