From 2a23df09f35986d1fb06a40f107051907ee53fcc Mon Sep 17 00:00:00 2001 From: Lady Ada Date: Sun, 29 Dec 2019 02:31:52 -0500 Subject: [PATCH] remove extra begin options. just one now. also looked at https://github.com/adafruit/Adafruit_BME280_Library/issues/64 and reduced some delays --- Adafruit_BME280.cpp | 32 +++--------------------------- Adafruit_BME280.h | 7 ++----- examples/bme280test/bme280test.ino | 7 ++++--- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/Adafruit_BME280.cpp b/Adafruit_BME280.cpp index b30770a..09c84d5 100644 --- a/Adafruit_BME280.cpp +++ b/Adafruit_BME280.cpp @@ -64,7 +64,7 @@ Adafruit_BME280::Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin, /*! * @brief Initialise sensor with given parameters / settings * @param addr the I2C address the device can be found on - * @param theWire the I2C object to use + * @param theWire the I2C object to use, defaults to &Wire * @returns true on success, false otherwise */ bool Adafruit_BME280::begin(uint8_t addr, TwoWire *theWire) { @@ -76,32 +76,6 @@ bool Adafruit_BME280::begin(uint8_t addr, TwoWire *theWire) { return status; } -/*! - * @brief Initialise sensor with given parameters / settings - * @param theWire the I2C object to use - * @returns true on success, false otherwise - */ -bool Adafruit_BME280::begin(TwoWire *theWire) { - return begin(BME280_ADDRESS, theWire); -} - -/*! - * @brief Initialise sensor with given parameters / settings - * @param addr the I2C address the device can be found on - * @returns true on success, false otherwise - */ -bool Adafruit_BME280::begin(uint8_t addr) { - return begin(addr, &Wire); -} - -/*! - * @brief Initialise sensor with given parameters / settings - * @returns true on success, false otherwise - */ -bool Adafruit_BME280::begin(void) { - return begin(BME280_ADDRESS, &Wire); -} - /*! * @brief Initialise sensor with given parameters / settings * @returns true on success, false otherwise @@ -135,11 +109,11 @@ bool Adafruit_BME280::init() { write8(BME280_REGISTER_SOFTRESET, 0xB6); // wait for chip to wake up. - delay(300); + delay(10); // if chip is still reading calibration, delay while (isReadingCalibration()) - delay(100); + delay(10); readCoefficients(); // read trimming parameters, see DS 4.2.2 diff --git a/Adafruit_BME280.h b/Adafruit_BME280.h index 930afc1..db1cdda 100644 --- a/Adafruit_BME280.h +++ b/Adafruit_BME280.h @@ -190,13 +190,10 @@ public: // constructors Adafruit_BME280(); Adafruit_BME280(int8_t cspin, SPIClass *theSPI = &SPI); - Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin, + Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin); - bool begin(); - bool begin(TwoWire *theWire); - bool begin(uint8_t addr); - bool begin(uint8_t addr, TwoWire *theWire); + bool begin(uint8_t addr=BME280_ADDRESS, TwoWire *theWire=&Wire); bool init(); void setSampling(sensor_mode mode = MODE_NORMAL, diff --git a/examples/bme280test/bme280test.ino b/examples/bme280test/bme280test.ino index 9fb8c43..45a8c4d 100644 --- a/examples/bme280test/bme280test.ino +++ b/examples/bme280test/bme280test.ino @@ -42,8 +42,9 @@ void setup() { unsigned status; // default settings - // (you can also pass in a Wire library object like &Wire2) status = bme.begin(); + // You can also pass in a Wire library object like &Wire2 + // status = bme.begin(0x76, &Wire2) if (!status) { Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"); Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16); @@ -51,7 +52,7 @@ void setup() { Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n"); Serial.print(" ID of 0x60 represents a BME 280.\n"); Serial.print(" ID of 0x61 represents a BME 680.\n"); - while (1); + while (1) delay(10); } Serial.println("-- Default Test --"); @@ -86,4 +87,4 @@ void printValues() { Serial.println(" %"); Serial.println(); -} +} \ No newline at end of file