Skip to content
Snippets Groups Projects
Commit 5cead188 authored by chris007's avatar chris007
Browse files

Refactoring get_data()

parent 5bf43827
Branches
No related tags found
No related merge requests found
...@@ -104,38 +104,31 @@ int epic_bme680_deinit() ...@@ -104,38 +104,31 @@ int epic_bme680_deinit()
int epic_bme680_read_sensors(struct bme680_sensor_data *data) int epic_bme680_read_sensors(struct bme680_sensor_data *data)
{ {
int8_t result = BME680_OK;
if (!initialized) { if (!initialized) {
LOG_ERR("bme680", "bme680 sensor not initialized"); LOG_ERR("bme680", "bme680 sensor not initialized");
return -1; return -1;
} }
int8_t result = BME680_OK;
struct bme680_field_data raw_data;
uint16_t profile_dur = 0; uint16_t profile_dur = 0;
bme680_get_profile_dur(&profile_dur, &bme); bme680_get_profile_dur(&profile_dur, &bme);
if (result == BME680_OK) { result = bme680_set_sensor_mode(&bme); /* Trigger a measurement */
result = bme680_set_sensor_mode(
&bme); /* Trigger a measurement */
if (result != BME680_OK) { if (result != BME680_OK) {
LOG_ERR("bme680", LOG_ERR("bme680", "bme680_set_sensor_mode error: %d\n", result);
"bme680_set_sensor_mode error: %d\n",
result);
return -convert_error(result); return -convert_error(result);
} }
vTaskDelay(pdMS_TO_TICKS( vTaskDelay(pdMS_TO_TICKS(
profile_dur)); /* Wait for the measurement to complete */ profile_dur)); /* Wait for the measurement to complete */
struct bme680_field_data raw_data;
result = bme680_get_sensor_data(&raw_data, &bme); result = bme680_get_sensor_data(&raw_data, &bme);
if (result != BME680_OK) { if (result != BME680_OK) {
LOG_ERR("bme680", LOG_ERR("bme680", "bme680_get_sensor_data error: %d\n", result);
"bme680_get_sensor_data error: %d\n",
result);
return -convert_error(result); return -convert_error(result);
} }
}
data->temperature = raw_data.temperature / 100.0l; data->temperature = raw_data.temperature / 100.0l;
data->humidity = raw_data.humidity / 1000.0l; data->humidity = raw_data.humidity / 1000.0l;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment