Skip to content

Commit e0c8ee1

Browse files
committed
DM: update docs
1 parent 4a84ebc commit e0c8ee1

File tree

2 files changed

+185
-70
lines changed

2 files changed

+185
-70
lines changed

Adafruit_BME280.cpp

Lines changed: 107 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,65 @@
1-
/***************************************************************************
2-
This is a library for the BME280 humidity, temperature & pressure sensor
3-
4-
Designed specifically to work with the Adafruit BME280 Breakout
5-
----> http://www.adafruit.com/products/2650
6-
7-
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
8-
to interface.
9-
10-
Adafruit invests time and resources providing this open source code,
11-
please support Adafruit andopen-source hardware by purchasing products
12-
from Adafruit!
1+
/*!
2+
* @file Adafruit_BME280.cpp
3+
*
4+
* @mainpage Adafruit BME280 humidity, temperature & pressure sensor
5+
*
6+
* @section intro_sec Introduction
7+
*
8+
* Driver for the BME280 humidity, temperature & pressure sensor
9+
*
10+
* These sensors use I2C or SPI to communicate, 2 or 4 pins are required
11+
* to interface.
12+
*
13+
* Designed specifically to work with the Adafruit BME280 Breakout
14+
* ----> http://www.adafruit.com/products/2650
15+
*
16+
* Adafruit invests time and resources providing this open source code,
17+
* please support Adafruit and open-source hardware by purchasing
18+
* products from Adafruit!
19+
*
20+
* @section author Author
21+
*
22+
* Written by Kevin "KTOWN" Townsend for Adafruit Industries.
23+
*
24+
* @section license License
25+
*
26+
* BSD license, all text here must be included in any redistribution.
27+
*
28+
*/
1329

14-
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
15-
BSD license, all text above must be included in any redistribution
16-
***************************************************************************/
1730
#include "Arduino.h"
1831
#include <Wire.h>
1932
#include <SPI.h>
2033
#include "Adafruit_BME280.h"
2134

22-
/***************************************************************************
23-
PRIVATE FUNCTIONS
24-
***************************************************************************/
35+
/**************************************************************************/
36+
/*!
37+
@brief class constructor
38+
*/
39+
/**************************************************************************/
2540
Adafruit_BME280::Adafruit_BME280()
2641
: _cs(-1), _mosi(-1), _miso(-1), _sck(-1)
2742
{ }
2843

44+
/**************************************************************************/
45+
/*!
46+
@brief class constructor if using hardware SPI
47+
@param cspin the chip select pin to use
48+
*/
49+
/**************************************************************************/
2950
Adafruit_BME280::Adafruit_BME280(int8_t cspin)
3051
: _cs(cspin), _mosi(-1), _miso(-1), _sck(-1)
3152
{ }
3253

54+
/**************************************************************************/
55+
/*!
56+
@brief class constructor if using software SPI
57+
@param cspin the chip select pin to use
58+
@param mosipin the MOSI pin to use
59+
@param misopin the MISO pin to use
60+
@param sckpin the SCK pin to use
61+
*/
62+
/**************************************************************************/
3363
Adafruit_BME280::Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
3464
: _cs(cspin), _mosi(mosipin), _miso(misopin), _sck(sckpin)
3565
{ }
@@ -38,6 +68,8 @@ Adafruit_BME280::Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin, i
3868
/**************************************************************************/
3969
/*!
4070
@brief Initialise sensor with given parameters / settings
71+
@param theWire the I2C object to use
72+
@returns true on success, false otherwise
4173
*/
4274
/**************************************************************************/
4375
bool Adafruit_BME280::begin(TwoWire *theWire)
@@ -47,27 +79,54 @@ bool Adafruit_BME280::begin(TwoWire *theWire)
4779
return init();
4880
}
4981

82+
/**************************************************************************/
83+
/*!
84+
@brief Initialise sensor with given parameters / settings
85+
@param addr the I2C address the device can be found on
86+
@returns true on success, false otherwise
87+
*/
88+
/**************************************************************************/
5089
bool Adafruit_BME280::begin(uint8_t addr)
5190
{
5291
_i2caddr = addr;
5392
_wire = &Wire;
5493
return init();
5594
}
5695

96+
/**************************************************************************/
97+
/*!
98+
@brief Initialise sensor with given parameters / settings
99+
@param addr the I2C address the device can be found on
100+
@param theWire the I2C object to use
101+
@returns true on success, false otherwise
102+
*/
103+
/**************************************************************************/
57104
bool Adafruit_BME280::begin(uint8_t addr, TwoWire *theWire)
58105
{
59106
_i2caddr = addr;
60107
_wire = theWire;
61108
return init();
62109
}
63110

111+
/**************************************************************************/
112+
/*!
113+
@brief Initialise sensor with given parameters / settings
114+
@returns true on success, false otherwise
115+
*/
116+
/**************************************************************************/
64117
bool Adafruit_BME280::begin(void)
65118
{
66119
_i2caddr = BME280_ADDRESS;
67120
_wire = &Wire;
68121
return init();
69122
}
70123

124+
/**************************************************************************/
125+
/*!
126+
@brief Initialise sensor with given parameters / settings
127+
@returns true on success, false otherwise
128+
*/
129+
/**************************************************************************/
71130
bool Adafruit_BME280::init()
72131
{
73132
// init I2C or SPI sensor interface
@@ -118,10 +177,14 @@ bool Adafruit_BME280::init()
118177
119178
This is simply a overload to the normal begin()-function, so SPI users
120179
don't get confused about the library requiring an address.
180+
@param mode the power mode to use for the sensor
181+
@param tempSampling the temp samping rate to use
182+
@param pressSampling the pressure sampling rate to use
183+
@param humSampling the humidity sampling rate to use
184+
@param filter the filter mode to use
185+
@param duration the standby duration to use
121186
*/
122187
/**************************************************************************/
123-
124-
125188
void Adafruit_BME280::setSampling(sensor_mode mode,
126189
sensor_sampling tempSampling,
127190
sensor_sampling pressSampling,
@@ -149,6 +212,8 @@ void Adafruit_BME280::setSampling(sensor_mode mode,
149212
/**************************************************************************/
150213
/*!
151214
@brief Encapsulate hardware and software SPI transfer into one function
215+
@param x the data byte to transfer
216+
@returns the data byte read from the device
152217
*/
153218
/**************************************************************************/
154219
uint8_t Adafruit_BME280::spixfer(uint8_t x) {
@@ -173,6 +238,8 @@ uint8_t Adafruit_BME280::spixfer(uint8_t x) {
173238
/**************************************************************************/
174239
/*!
175240
@brief Writes an 8 bit value over I2C or SPI
241+
@param reg the register address to write to
242+
@param value the value to write to the register
176243
*/
177244
/**************************************************************************/
178245
void Adafruit_BME280::write8(byte reg, byte value) {
@@ -197,6 +264,8 @@ void Adafruit_BME280::write8(byte reg, byte value) {
197264
/**************************************************************************/
198265
/*!
199266
@brief Reads an 8 bit value over I2C or SPI
267+
@param reg the register address to read from
268+
@returns the data byte read from the device
200269
*/
201270
/**************************************************************************/
202271
uint8_t Adafruit_BME280::read8(byte reg) {
@@ -225,6 +294,8 @@ uint8_t Adafruit_BME280::read8(byte reg) {
225294
/**************************************************************************/
226295
/*!
227296
@brief Reads a 16 bit value over I2C or SPI
297+
@param reg the register address to read from
298+
@returns the 16 bit data value read from the device
228299
*/
229300
/**************************************************************************/
230301
uint16_t Adafruit_BME280::read16(byte reg)
@@ -254,7 +325,9 @@ uint16_t Adafruit_BME280::read16(byte reg)
254325

255326
/**************************************************************************/
256327
/*!
257-
328+
@brief Reads a signed 16 bit little endian value over I2C or SPI
329+
@param reg the register address to read from
330+
@returns the 16 bit data value read from the device
258331
*/
259332
/**************************************************************************/
260333
uint16_t Adafruit_BME280::read16_LE(byte reg) {
@@ -266,6 +339,8 @@ uint16_t Adafruit_BME280::read16_LE(byte reg) {
266339
/**************************************************************************/
267340
/*!
268341
@brief Reads a signed 16 bit value over I2C or SPI
342+
@param reg the register address to read from
343+
@returns the 16 bit data value read from the device
269344
*/
270345
/**************************************************************************/
271346
int16_t Adafruit_BME280::readS16(byte reg)
@@ -276,7 +351,9 @@ int16_t Adafruit_BME280::readS16(byte reg)
276351

277352
/**************************************************************************/
278353
/*!
279-
354+
@brief Reads a signed little endian 16 bit value over I2C or SPI
355+
@param reg the register address to read from
356+
@returns the 16 bit data value read from the device
280357
*/
281358
/**************************************************************************/
282359
int16_t Adafruit_BME280::readS16_LE(byte reg)
@@ -288,6 +365,8 @@ int16_t Adafruit_BME280::readS16_LE(byte reg)
288365
/**************************************************************************/
289366
/*!
290367
@brief Reads a 24 bit value over I2C
368+
@param reg the register address to read from
369+
@returns the 24 bit data value read from the device
291370
*/
292371
/**************************************************************************/
293372
uint32_t Adafruit_BME280::read24(byte reg)
@@ -380,6 +459,7 @@ void Adafruit_BME280::readCoefficients(void)
380459
/**************************************************************************/
381460
/*!
382461
@brief return true if chip is busy reading cal data
462+
@returns true if reading calibration, false otherwise
383463
*/
384464
/**************************************************************************/
385465
bool Adafruit_BME280::isReadingCalibration(void)
@@ -393,6 +473,7 @@ bool Adafruit_BME280::isReadingCalibration(void)
393473
/**************************************************************************/
394474
/*!
395475
@brief Returns the temperature from the sensor
476+
@returns the temperature read from the device
396477
*/
397478
/**************************************************************************/
398479
float Adafruit_BME280::readTemperature(void)
@@ -421,6 +502,7 @@ float Adafruit_BME280::readTemperature(void)
421502
/**************************************************************************/
422503
/*!
423504
@brief Returns the temperature from the sensor
505+
@returns the pressure value read from the device
424506
*/
425507
/**************************************************************************/
426508
float Adafruit_BME280::readPressure(void) {
@@ -457,6 +539,7 @@ float Adafruit_BME280::readPressure(void) {
457539
/**************************************************************************/
458540
/*!
459541
@brief Returns the humidity from the sensor
542+
@returns the humidity value read from the device
460543
*/
461544
/**************************************************************************/
462545
float Adafruit_BME280::readHumidity(void) {
@@ -492,7 +575,7 @@ float Adafruit_BME280::readHumidity(void) {
492575
pressure (in hPa), and sea-level pressure (in hPa).
493576
494577
@param seaLevel Sea-level pressure in hPa
495-
@param atmospheric Atmospheric pressure in hPa
578+
@returns the altitude value read from the device
496579
*/
497580
/**************************************************************************/
498581
float Adafruit_BME280::readAltitude(float seaLevel)
@@ -515,6 +598,7 @@ float Adafruit_BME280::readAltitude(float seaLevel)
515598
(in meters), and atmospheric pressure (in hPa).
516599
@param altitude Altitude in meters
517600
@param atmospheric Atmospheric pressure in hPa
601+
@returns the pressure at sea level (in hPa) from the specified altitude
518602
*/
519603
/**************************************************************************/
520604
float Adafruit_BME280::seaLevelForAltitude(float altitude, float atmospheric)

0 commit comments

Comments
 (0)