Skip to content

Commit

Permalink
Wire/TinyWireM.begin() doesn't have to be called anymore
Browse files Browse the repository at this point in the history
From now on, ForcedClimate::begin() also begins the i2c bus.
  • Loading branch information
JVKran committed Aug 21, 2020
1 parent fedb7fc commit 02804d9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
5 changes: 0 additions & 5 deletions examples/Test/Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ ForcedClimate climateSensor = ForcedClimate();

void setup(){
Serial.begin(9600);
#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__)
TinyWireM.begin();
#else
Wire.begin();
#endif
climateSensor.begin();
}

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Forced-BME280
version=2.4
version=3.0
author=Jochem van Kranenburg
maintainer=Jochem van Kranenburg <[email protected]>
sentence=A library that makes using a BME280 easy and lightweight.
Expand Down
7 changes: 4 additions & 3 deletions src/forcedClimate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ForcedClimate::ForcedClimate(TwoWire & bus, const uint8_t address, const bool au
/// data from the register. This function has been implementted to comply
/// with the Arduino 1.5 Format; it's also called from the constructor (as it should be).
void ForcedClimate::begin(){
bus.begin();
applyOversamplingControls();
readCalibrationData();
}
Expand Down Expand Up @@ -150,7 +151,7 @@ float ForcedClimate::getTemperatureCelcius(const bool performMeasurement)
/// This function retrieves the compensated pressure as described
/// on page 50 of the BME280 Datasheet.
#ifdef FORCED_CLIMATE_ATTINY
int32_t ForcedClimate::getPressure(const bool performMeasurement)
uint32_t ForcedClimate::getPressure(const bool performMeasurement)
#else
float ForcedClimate::getPressure(const bool performMeasurement)
#endif
Expand Down Expand Up @@ -198,7 +199,7 @@ float ForcedClimate::getPressure(const bool performMeasurement)
/// This function retrieves the compensated humidity as described
/// on page 50 of the BME280 Datasheet.
#ifdef FORCED_CLIMATE_ATTINY
int32_t ForcedClimate::getRelativeHumidity(const bool performMeasurement)
uint32_t ForcedClimate::getRelativeHumidity(const bool performMeasurement)
#else
float ForcedClimate::getRelativeHumidity(const bool performMeasurement)
#endif
Expand All @@ -222,7 +223,7 @@ float ForcedClimate::getRelativeHumidity(const bool performMeasurement)
var1 = (var1 - (((((var1 >> 15) * (var1 >> 15)) >> 7) * ((int32_t)humidity[1])) >> 4));
var1 = (var1 < 0 ? 0 : var1);
var1 = (var1 > 419430400 ? 419430400 : var1);
int32_t humidity = (uint32_t)((var1>>12)*25)>>8;
uint32_t humidity = (uint32_t)((var1>>12)*25)>>8;
#ifdef FORCED_CLIMATE_ATTINY
return humidity;
#else
Expand Down
4 changes: 2 additions & 2 deletions src/forcedClimate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class ForcedClimate {
#endif

#ifdef FORCED_CLIMATE_ATTINY
int32_t getPressure(const bool performMeasurement = false);
uint32_t getPressure(const bool performMeasurement = false);
#else
float getPressure(const bool performMeasurement = false);
#endif

#ifdef FORCED_CLIMATE_ATTINY
int32_t getRelativeHumidity(const bool performMeasurement = false);
uint32_t getRelativeHumidity(const bool performMeasurement = false);
#else
float getRelativeHumidity(const bool performMeasurement = false);
#endif
Expand Down

0 comments on commit 02804d9

Please sign in to comment.