From e9681d0c568b9faa02d551adb3005e6694034882 Mon Sep 17 00:00:00 2001 From: Eduard Malokhvii Date: Wed, 8 Jun 2022 00:36:09 +0300 Subject: [PATCH] fix(api): optional build without global instances --- src/Bme280.cpp | 8 ++++++++ src/Bme280.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/Bme280.cpp b/src/Bme280.cpp index 92dae08..4fe538c 100755 --- a/src/Bme280.cpp +++ b/src/Bme280.cpp @@ -241,12 +241,16 @@ Bme280TwoWire::Bme280TwoWire() : wire_(nullptr) {} Bme280TwoWire::~Bme280TwoWire() {} +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE) + void Bme280TwoWire::begin() { begin(Bme280TwoWireAddress::Primary); } void Bme280TwoWire::begin(const Bme280TwoWireAddress address) { begin(address, &Wire); } +#endif + void Bme280TwoWire::begin(const Bme280TwoWireAddress address, TwoWire *wire) { address_ = static_cast(address); wire_ = wire; @@ -310,8 +314,12 @@ Bme280FourWire::~Bme280FourWire() {} const SPISettings Bme280FourWire::spiSettings_ = SPISettings(SPISettings(500000, MSBFIRST, SPI_MODE0)); +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI) + void Bme280FourWire::begin(const uint8_t csPin) { begin(csPin, &SPI); } +#endif + void Bme280FourWire::begin(const uint8_t csPin, SPIClass *spi) { spi_ = spi; csPin_ = csPin; diff --git a/src/Bme280.h b/src/Bme280.h index b2644df..18840b7 100755 --- a/src/Bme280.h +++ b/src/Bme280.h @@ -272,8 +272,10 @@ class Bme280TwoWire final : public ::internal::AbstractBme280 { Bme280TwoWire(); virtual ~Bme280TwoWire(); +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE) void begin(); void begin(const Bme280TwoWireAddress address); +#endif void begin(const Bme280TwoWireAddress address, TwoWire *wire); uint8_t getAddress() const; @@ -293,7 +295,9 @@ class Bme280FourWire final : public ::internal::AbstractBme280 { Bme280FourWire(); virtual ~Bme280FourWire(); +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI) void begin(const uint8_t csPin); +#endif void begin(const uint8_t csPin, SPIClass *spi); uint8_t getCsPin() const;