BME680 driver trailing whitespaces removed

This commit is contained in:
Gunar Schorcht 2017-10-28 17:17:54 +02:00
parent 1af3f2e033
commit f431f831f6
8 changed files with 318 additions and 325 deletions

View file

@ -6,7 +6,7 @@ These examples demonstrate the usage of the BME680 driver with only one and mult
There are examples that are using either I2C or SPI with one or two sensors.
For examples using BME680 sensor as I2C slave, just use GPIO5 (SCL) and GPIO4 (SDA) to connect to the BME680 sensor's I2C interface.
For examples using BME680 sensor as I2C slave, just use GPIO5 (SCL) and GPIO4 (SDA) to connect to the BME680 sensor's I2C interface.
```
+-------------------------+ +--------+

View file

@ -10,7 +10,7 @@
* | GPIO 4 (SDA) ------- SDA |
* +-------------------------+ +----------+
*/
#include "espressif/esp_common.h"
#include "esp/uart.h"
@ -31,7 +31,7 @@
static bme680_sensor_t* sensor;
/*
* User task that triggers measurements of sensor every seconds. It uses
* User task that triggers measurements of sensor every seconds. It uses
* function *vTaskDelay* to wait for measurement results and changes the
* heating profile in each cycle.
*/
@ -40,10 +40,10 @@ void user_task(void *pvParameters)
bme680_values_float_t values;
TickType_t last_wakeup = xTaskGetTickCount();
uint32_t count = 0;
while (1)
while (1)
{
if (count++ < 60)
// disable gas measurement for cycle counter < 60
@ -62,7 +62,7 @@ void user_task(void *pvParameters)
// measurement duration changes in each cycle
uint32_t duration = bme680_get_measurement_duration(sensor);
// trigger the sensor to start one TPHG measurement cycle
// trigger the sensor to start one TPHG measurement cycle
if (bme680_force_measurement (sensor))
{
// passive waiting until measurement results are available
@ -70,9 +70,9 @@ void user_task(void *pvParameters)
// get the results and do something with them
if (bme680_get_results_float (sensor, &values))
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
(double)sdk_system_get_time()*1e-3,
values.temperature, values.humidity,
values.temperature, values.humidity,
values.pressure, values.gas_resistance);
}
// passive waiting until 1 second is over
@ -87,9 +87,9 @@ void user_init(void)
uart_set_baud(0, 115200);
// Give the UART some time to settle
sdk_os_delay_us(500);
/** -- MANDATORY PART -- */
#ifdef SPI_USED
// Init the sensor connected either to SPI.
sensor = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO);
@ -107,11 +107,11 @@ void user_init(void)
xTaskCreate(user_task, "user_task", 256, NULL, 2, NULL);
/** -- OPTIONAL PART -- */
// Changes the oversampling rates to 4x oversampling for temperature
// and 2x oversampling for humidity. Pressure measurement is skipped.
bme680_set_oversampling_rates(sensor, osr_4x, osr_none, osr_2x);
// Change the IIR filter size for temperature and pressure to 7.
bme680_set_filter_size(sensor, iir_size_7);
@ -123,4 +123,3 @@ void user_init(void)
bme680_set_heater_profile (sensor, 4, 400, 180);
}
}

View file

@ -9,7 +9,7 @@
* | GPIO 5 (SCL) ------> SCL |
* | GPIO 4 (SDA) ------- SDA |
* +-------------------------+ +----------+
*
*
* SPI +-------------------------+ +----------+
* | ESP8266 Bus 1 | | BME680 |
* | GPIO 12 (MISO) <-----< SDO |
@ -18,10 +18,10 @@
* | GPIO 2 (CS) >-----> CS |
* +-------------------------+ +----------+
*/
// Uncomment to use SPI
// #define SPI_USED
#include "espressif/esp_common.h"
#include "esp/uart.h"
@ -49,7 +49,7 @@
static bme680_sensor_t* sensor;
/*
* User task that triggers measurements of sensor every seconds. It uses
* User task that triggers measurements of sensor every seconds. It uses
* function *vTaskDelay* to wait for measurement results. Busy wating
* alternative is shown in comments
*/
@ -58,26 +58,26 @@ void user_task(void *pvParameters)
bme680_values_float_t values;
TickType_t last_wakeup = xTaskGetTickCount();
// as long as sensor configuration isn't changed, duration is constant
uint32_t duration = bme680_get_measurement_duration(sensor);
while (1)
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
// trigger the sensor to start one TPHG measurement cycle
if (bme680_force_measurement (sensor))
{
// passive waiting until measurement results are available
vTaskDelay (duration);
// alternatively: busy waiting until measurement results are available
// while (bme680_is_measuring (sensor)) ;
// get the results and do something with them
if (bme680_get_results_float (sensor, &values))
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
(double)sdk_system_get_time()*1e-3,
values.temperature, values.humidity,
values.temperature, values.humidity,
values.pressure, values.gas_resistance);
}
// passive waiting until 1 second is over
@ -92,9 +92,9 @@ void user_init(void)
uart_set_baud(0, 115200);
// Give the UART some time to settle
sdk_os_delay_us(500);
/** -- MANDATORY PART -- */
#ifdef SPI_USED
// Init the sensor connected either to SPI.
sensor = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO);
@ -112,11 +112,11 @@ void user_init(void)
xTaskCreate(user_task, "user_task", 256, NULL, 2, NULL);
/** -- OPTIONAL PART -- */
// Changes the oversampling rates to 4x oversampling for temperature
// and 2x oversampling for humidity. Pressure measurement is skipped.
bme680_set_oversampling_rates(sensor, osr_4x, osr_none, osr_2x);
// Change the IIR filter size for temperature and pressure to 7.
bme680_set_filter_size(sensor, iir_size_7);
@ -128,4 +128,3 @@ void user_init(void)
bme680_set_ambient_temperature (sensor, 10);
}
}

View file

@ -19,7 +19,7 @@
* | GPIO 2 (CS) >-----> CS |
* +-------------------------+ +----------+
*/
#include "espressif/esp_common.h"
#include "esp/uart.h"
@ -36,7 +36,7 @@
// define I2C interface for BME680 sensor 1
#define SPI_BUS 1
#define SPI_CS_GPIO 2 // GPIO 15, the default CS of SPI bus 1, can't be used
// define SPI interface for BME680 sensor 2
// define SPI interface for BME680 sensor 2
#define I2C_BUS 0
#define I2C_SCL_PIN 5
#define I2C_SDA_PIN 4
@ -45,7 +45,7 @@ static bme680_sensor_t* sensor1;
static bme680_sensor_t* sensor2;
/*
* User task that triggers measurements of sensor1 every 5 seconds and
* User task that triggers measurements of sensor1 every 5 seconds and
* uses *vTaskDelay* to wait for measurement results.
*/
void user_task_sensor1(void *pvParameters)
@ -53,26 +53,26 @@ void user_task_sensor1(void *pvParameters)
bme680_values_float_t values;
TickType_t last_wakeup = xTaskGetTickCount();
uint32_t duration = bme680_get_measurement_duration (sensor1);
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
if (bme680_force_measurement (sensor1))
{
// passive waiting until measurement results are available
vTaskDelay (duration);
// get the results and so something with them
if (bme680_get_results_float (sensor1, &values))
printf("%.3f BME680 Sensor1: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
(double)sdk_system_get_time()*1e-3,
values.temperature, values.humidity,
values.temperature, values.humidity,
values.pressure, values.gas_resistance);
}
// passive waiting until 5 seconds are over
vTaskDelayUntil(&last_wakeup, 5000 / portTICK_PERIOD_MS);
}
@ -87,10 +87,10 @@ void user_task_sensor2(void *pvParameters)
bme680_values_float_t values;
TickType_t last_wakeup = xTaskGetTickCount();
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
if (bme680_force_measurement (sensor2))
{
// busy waiting until measurement results are available
@ -100,10 +100,10 @@ void user_task_sensor2(void *pvParameters)
if (bme680_get_results_float (sensor2, &values))
printf("%.3f BME680 Sensor2: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
(double)sdk_system_get_time()*1e-3,
values.temperature, values.humidity,
values.temperature, values.humidity,
values.pressure, values.gas_resistance);
}
// passive waiting until 2 seconds are over
vTaskDelayUntil(&last_wakeup, 2000 / portTICK_PERIOD_MS);
}
@ -116,9 +116,9 @@ void user_init(void)
uart_set_baud(0, 115200);
// Give the UART some time to settle
sdk_os_delay_us(500);
/** -- MANDATORY PART -- */
// Init all I2C bus interfaces at which BME680 sensors are connected
i2c_init(I2C_BUS, I2C_SCL_PIN, I2C_SDA_PIN, I2C_FREQ_100K);
@ -131,15 +131,15 @@ void user_init(void)
// Create the tasks that use the sensors
xTaskCreate(user_task_sensor1, "user_task_sensor1", 256, NULL, 2, 0);
xTaskCreate(user_task_sensor2, "user_task_sensor2", 256, NULL, 2, 0);
// That's it.
/** -- OPTIONAL PART -- */
// Changes the oversampling rates for both sensor to different values
bme680_set_oversampling_rates(sensor1, osr_4x, osr_2x, osr_1x);
bme680_set_oversampling_rates(sensor2, osr_8x, osr_8x, osr_8x);
// Change the IIR filter size for temperature and and pressure to 7.
bme680_set_filter_size(sensor1, iir_size_7);
bme680_set_filter_size(sensor2, iir_size_7);
@ -147,10 +147,9 @@ void user_init(void)
// Change the heater profile 0 to 200 degree Celcius for 150 ms.
bme680_set_heater_profile (sensor1, 0, 200, 150);
bme680_set_heater_profile (sensor2, 0, 200, 150);
// Activate the heater profile 0
bme680_use_heater_profile (sensor1, 0);
bme680_use_heater_profile (sensor2, 0);
}
}