Skip to content

Commit 905db7a

Browse files
committed
fix(bmp581): Correct to hPa + clang format
1 parent 4b65a34 commit 905db7a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_BMP5XX.h

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
#ifndef WipperSnapper_I2C_Driver_BMP5XX_H
1717
#define WipperSnapper_I2C_Driver_BMP5XX_H
1818

19-
#include "WipperSnapper_I2C_Driver.h"
2019
#include <Adafruit_BMP5XX.h>
2120

22-
#define SEALEVELPRESSURE_HPA (1013.25) ///< Default sea level pressure, in hPa
21+
#include "WipperSnapper_I2C_Driver.h"
22+
23+
#define SEALEVELPRESSURE_HPA (1013.25) ///< Default sea level pressure, in hPa
2324

2425
/**************************************************************************/
2526
/*!
@@ -28,8 +29,7 @@
2829
*/
2930
/**************************************************************************/
3031
class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
31-
32-
public:
32+
public:
3333
/*******************************************************************************/
3434
/*!
3535
@brief Constructor for an BMP5XX sensor.
@@ -49,9 +49,9 @@ class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
4949
@brief Destructor for an BMP5XX sensor.
5050
*/
5151
/*******************************************************************************/
52-
~WipperSnapper_I2C_Driver_BMP5XX() {
52+
~WipperSnapper_I2C_Driver_BMP5XX() {
5353
if (_bmp5xx) {
54-
delete _bmp5xx;
54+
delete _bmp5xx;
5555
_bmp5xx = nullptr;
5656
}
5757
}
@@ -64,8 +64,11 @@ class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
6464
/*******************************************************************************/
6565
bool begin() {
6666
_bmp5xx = new Adafruit_BMP5xx();
67-
if (!_bmp5xx->begin(_sensorAddress, _i2c))
67+
if (!_bmp5xx->begin(_sensorAddress, _i2c)) {
68+
delete _bmp5xx;
69+
_bmp5xx = nullptr;
6870
return false;
71+
}
6972

7073
// Set up oversampling and filter initialization
7174
_bmp5xx->setTemperatureOversampling(BMP5XX_OVERSAMPLING_8X);
@@ -86,8 +89,9 @@ class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
8689
*/
8790
/*******************************************************************************/
8891
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
89-
if (!_bmp5xx->performReading())
92+
if (!_bmp5xx->performReading()) {
9093
return false;
94+
}
9195
tempEvent->temperature = _bmp5xx->temperature;
9296
return true;
9397
}
@@ -103,9 +107,10 @@ class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
103107
*/
104108
/*******************************************************************************/
105109
bool getEventPressure(sensors_event_t *pressureEvent) {
106-
if (!_bmp5xx->performReading())
110+
if (!_bmp5xx->performReading()) {
107111
return false;
108-
pressureEvent->pressure = _bmp5xx->pressure / 10.0F;
112+
}
113+
pressureEvent->pressure = _bmp5xx->pressure;
109114
return true;
110115
}
111116

@@ -119,14 +124,15 @@ class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
119124
*/
120125
/*******************************************************************************/
121126
bool getEventAltitude(sensors_event_t *altitudeEvent) {
122-
if (!_bmp5xx->performReading())
127+
if (!_bmp5xx->performReading()) {
123128
return false;
129+
}
124130
altitudeEvent->altitude = _bmp5xx->readAltitude(SEALEVELPRESSURE_HPA);
125131
return true;
126132
}
127133

128-
protected:
129-
Adafruit_BMP5xx *_bmp5xx; ///< BMP5xx object
134+
protected:
135+
Adafruit_BMP5xx *_bmp5xx; ///< BMP5xx object
130136
};
131137

132-
#endif // WipperSnapper_I2C_Driver_BMP5XX
138+
#endif // WipperSnapper_I2C_Driver_BMP5XX

0 commit comments

Comments
 (0)