Skip to content
Open
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
11 changes: 6 additions & 5 deletions mbed_bme680.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "mbed_bme680.h"

BME680::BME680() {
BME680(BME680_DEFAULT_ADDRESS);
BME680::BME680(PinName sda, PinName scl) {
BME680(BME680_DEFAULT_ADDRESS, sda, scl);
}

BME680::BME680(uint8_t adr) {
BME680::BME680(uint8_t adr, PinName sda, PinName scl) {
i2c(sda, scl);
_filterEnabled = _tempEnabled = _humEnabled = _presEnabled = _gasEnabled = false;
_adr = adr;
}
Expand Down Expand Up @@ -333,7 +334,7 @@ int8_t BME680::i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, ui

void BME680::delay_msec(uint32_t ms) {
log(" * wait %d ms ... \r\n", ms);
wait_ms(ms);
ThisThread::sleep_for(std::chrono::milliseconds(ms));
}

void BME680::log(const char *format, ...) {
Expand All @@ -343,4 +344,4 @@ void BME680::log(const char *format, ...) {
vfprintf(stderr, format, args);
va_end(args);
#endif
}
}
8 changes: 4 additions & 4 deletions mbed_bme680.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
#define BME680_DEFAULT_ADDRESS (0x77 << 1) // The default I2C address (shifted for MBed 8 bit address)
//#define BME680_DEBUG_MODE // Use this for enhance debug logs for I2C and more.

extern I2C i2c;

/**
* BME680 Class for I2C usage.
* Wraps the Bosch library for MBed usage.
*/
class BME680 {
public:
BME680();
BME680(PinName sda, PinName scl);

BME680(uint8_t adr);
BME680(uint8_t adr, PinName sda, PinName scl);

bool begin();

Expand Down Expand Up @@ -49,6 +48,7 @@ class BME680 {
float getGasResistance();

private:
I2C i2c;
bool _filterEnabled, _tempEnabled, _humEnabled, _presEnabled, _gasEnabled;
int32_t _sensorID;
struct bme680_dev gas_sensor;
Expand All @@ -65,4 +65,4 @@ class BME680 {
static void delay_msec(uint32_t ms);
};

#endif
#endif