Skip to content

Commit 61c4d0a

Browse files
authored
Merge pull request #25 from adafruit/actionci
Moved library to actions, fully documented with doxygen
2 parents 7b69aed + ac5f294 commit 61c4d0a

5 files changed

Lines changed: 243 additions & 137 deletions

File tree

.github/workflows/githubci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Arduino Library CI
2+
3+
on: [pull_request, push, repository_dispatch]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/setup-python@v1
11+
with:
12+
python-version: '3.x'
13+
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v2
15+
with:
16+
repository: adafruit/ci-arduino
17+
path: ci
18+
19+
- name: pre-install
20+
run: bash ci/actions_install.sh
21+
22+
- name: test platforms
23+
run: python3 ci/build_platform.py main_platforms
24+
25+
- name: clang
26+
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
27+
28+
- name: doxygen
29+
env:
30+
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
31+
PRETTYNAME : "Adafruit BMP085 Library"
32+
run: bash ci/doxy_gen_and_deploy.sh

Adafruit_BMP085.cpp

Lines changed: 126 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1-
/***************************************************
2-
This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor
3-
4-
Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout
5-
----> http://www.adafruit.com/products/391
6-
----> http://www.adafruit.com/products/1603
7-
8-
These displays use I2C to communicate, 2 pins are required to
9-
interface
10-
Adafruit invests time and resources providing this open source code,
11-
please support Adafruit and open-source hardware by purchasing
12-
products from Adafruit!
13-
14-
Written by Limor Fried/Ladyada for Adafruit Industries.
15-
BSD license, all text above must be included in any redistribution
16-
****************************************************/
1+
/*!
2+
* @file Adafruit_BMP085.cpp
3+
*
4+
* @mainpage Adafruit BMP085 Library
5+
*
6+
* @section intro_sec Introduction
7+
*
8+
* This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp
9+
* sensor
10+
*
11+
* Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout
12+
* ----> http://www.adafruit.com/products/391
13+
* ----> http://www.adafruit.com/products/1603
14+
*
15+
* These displays use I2C to communicate, 2 pins are required to
16+
* interface
17+
* Adafruit invests time and resources providing this open source code,
18+
* please support Adafruit and open-source hardware by purchasing
19+
* products from Adafruit!
20+
*
21+
* @section author Author
22+
*
23+
* Written by Limor Fried/Ladyada for Adafruit Industries.
24+
*
25+
* @section license License
26+
*
27+
* BSD license, all text above must be included in any redistribution
28+
*/
1729

1830
#include "Adafruit_BMP085.h"
1931

20-
Adafruit_BMP085::Adafruit_BMP085() {
21-
}
22-
32+
Adafruit_BMP085::Adafruit_BMP085() {}
2333

2434
boolean Adafruit_BMP085::begin(uint8_t mode) {
25-
if (mode > BMP085_ULTRAHIGHRES)
35+
if (mode > BMP085_ULTRAHIGHRES)
2636
mode = BMP085_ULTRAHIGHRES;
2737
oversampling = mode;
2838

2939
Wire.begin();
3040

31-
if (read8(0xD0) != 0x55) return false;
41+
if (read8(0xD0) != 0x55)
42+
return false;
3243

3344
/* read calibration data */
3445
ac1 = read16(BMP085_CAL_AC1);
@@ -45,35 +56,47 @@ boolean Adafruit_BMP085::begin(uint8_t mode) {
4556
mc = read16(BMP085_CAL_MC);
4657
md = read16(BMP085_CAL_MD);
4758
#if (BMP085_DEBUG == 1)
48-
Serial.print("ac1 = "); Serial.println(ac1, DEC);
49-
Serial.print("ac2 = "); Serial.println(ac2, DEC);
50-
Serial.print("ac3 = "); Serial.println(ac3, DEC);
51-
Serial.print("ac4 = "); Serial.println(ac4, DEC);
52-
Serial.print("ac5 = "); Serial.println(ac5, DEC);
53-
Serial.print("ac6 = "); Serial.println(ac6, DEC);
54-
55-
Serial.print("b1 = "); Serial.println(b1, DEC);
56-
Serial.print("b2 = "); Serial.println(b2, DEC);
57-
58-
Serial.print("mb = "); Serial.println(mb, DEC);
59-
Serial.print("mc = "); Serial.println(mc, DEC);
60-
Serial.print("md = "); Serial.println(md, DEC);
59+
Serial.print("ac1 = ");
60+
Serial.println(ac1, DEC);
61+
Serial.print("ac2 = ");
62+
Serial.println(ac2, DEC);
63+
Serial.print("ac3 = ");
64+
Serial.println(ac3, DEC);
65+
Serial.print("ac4 = ");
66+
Serial.println(ac4, DEC);
67+
Serial.print("ac5 = ");
68+
Serial.println(ac5, DEC);
69+
Serial.print("ac6 = ");
70+
Serial.println(ac6, DEC);
71+
72+
Serial.print("b1 = ");
73+
Serial.println(b1, DEC);
74+
Serial.print("b2 = ");
75+
Serial.println(b2, DEC);
76+
77+
Serial.print("mb = ");
78+
Serial.println(mb, DEC);
79+
Serial.print("mc = ");
80+
Serial.println(mc, DEC);
81+
Serial.print("md = ");
82+
Serial.println(md, DEC);
6183
#endif
6284

6385
return true;
6486
}
6587

6688
int32_t Adafruit_BMP085::computeB5(int32_t UT) {
6789
int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15;
68-
int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md);
90+
int32_t X2 = ((int32_t)mc << 11) / (X1 + (int32_t)md);
6991
return X1 + X2;
7092
}
7193

7294
uint16_t Adafruit_BMP085::readRawTemperature(void) {
7395
write8(BMP085_CONTROL, BMP085_READTEMPCMD);
7496
delay(5);
7597
#if BMP085_DEBUG == 1
76-
Serial.print("Raw temp: "); Serial.println(read16(BMP085_TEMPDATA));
98+
Serial.print("Raw temp: ");
99+
Serial.println(read16(BMP085_TEMPDATA));
77100
#endif
78101
return read16(BMP085_TEMPDATA);
79102
}
@@ -83,36 +106,36 @@ uint32_t Adafruit_BMP085::readRawPressure(void) {
83106

84107
write8(BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6));
85108

86-
if (oversampling == BMP085_ULTRALOWPOWER)
109+
if (oversampling == BMP085_ULTRALOWPOWER)
87110
delay(5);
88-
else if (oversampling == BMP085_STANDARD)
111+
else if (oversampling == BMP085_STANDARD)
89112
delay(8);
90-
else if (oversampling == BMP085_HIGHRES)
113+
else if (oversampling == BMP085_HIGHRES)
91114
delay(14);
92-
else
115+
else
93116
delay(26);
94117

95118
raw = read16(BMP085_PRESSUREDATA);
96119

97120
raw <<= 8;
98-
raw |= read8(BMP085_PRESSUREDATA+2);
121+
raw |= read8(BMP085_PRESSUREDATA + 2);
99122
raw >>= (8 - oversampling);
100123

101-
/* this pull broke stuff, look at it later?
102-
if (oversampling==0) {
103-
raw <<= 8;
104-
raw |= read8(BMP085_PRESSUREDATA+2);
105-
raw >>= (8 - oversampling);
106-
}
107-
*/
124+
/* this pull broke stuff, look at it later?
125+
if (oversampling==0) {
126+
raw <<= 8;
127+
raw |= read8(BMP085_PRESSUREDATA+2);
128+
raw >>= (8 - oversampling);
129+
}
130+
*/
108131

109132
#if BMP085_DEBUG == 1
110-
Serial.print("Raw pressure: "); Serial.println(raw);
133+
Serial.print("Raw pressure: ");
134+
Serial.println(raw);
111135
#endif
112136
return raw;
113137
}
114138

115-
116139
int32_t Adafruit_BMP085::readPressure(void) {
117140
int32_t UT, UP, B3, B5, B6, X1, X2, X3, p;
118141
uint32_t B4, B7;
@@ -140,36 +163,47 @@ int32_t Adafruit_BMP085::readPressure(void) {
140163
B5 = computeB5(UT);
141164

142165
#if BMP085_DEBUG == 1
143-
Serial.print("X1 = "); Serial.println(X1);
144-
Serial.print("X2 = "); Serial.println(X2);
145-
Serial.print("B5 = "); Serial.println(B5);
166+
Serial.print("X1 = ");
167+
Serial.println(X1);
168+
Serial.print("X2 = ");
169+
Serial.println(X2);
170+
Serial.print("B5 = ");
171+
Serial.println(B5);
146172
#endif
147173

148174
// do pressure calcs
149175
B6 = B5 - 4000;
150-
X1 = ((int32_t)b2 * ( (B6 * B6)>>12 )) >> 11;
176+
X1 = ((int32_t)b2 * ((B6 * B6) >> 12)) >> 11;
151177
X2 = ((int32_t)ac2 * B6) >> 11;
152178
X3 = X1 + X2;
153-
B3 = ((((int32_t)ac1*4 + X3) << oversampling) + 2) / 4;
179+
B3 = ((((int32_t)ac1 * 4 + X3) << oversampling) + 2) / 4;
154180

155181
#if BMP085_DEBUG == 1
156-
Serial.print("B6 = "); Serial.println(B6);
157-
Serial.print("X1 = "); Serial.println(X1);
158-
Serial.print("X2 = "); Serial.println(X2);
159-
Serial.print("B3 = "); Serial.println(B3);
182+
Serial.print("B6 = ");
183+
Serial.println(B6);
184+
Serial.print("X1 = ");
185+
Serial.println(X1);
186+
Serial.print("X2 = ");
187+
Serial.println(X2);
188+
Serial.print("B3 = ");
189+
Serial.println(B3);
160190
#endif
161191

162192
X1 = ((int32_t)ac3 * B6) >> 13;
163193
X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16;
164194
X3 = ((X1 + X2) + 2) >> 2;
165195
B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15;
166-
B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling );
196+
B7 = ((uint32_t)UP - B3) * (uint32_t)(50000UL >> oversampling);
167197

168198
#if BMP085_DEBUG == 1
169-
Serial.print("X1 = "); Serial.println(X1);
170-
Serial.print("X2 = "); Serial.println(X2);
171-
Serial.print("B4 = "); Serial.println(B4);
172-
Serial.print("B7 = "); Serial.println(B7);
199+
Serial.print("X1 = ");
200+
Serial.println(X1);
201+
Serial.print("X2 = ");
202+
Serial.println(X2);
203+
Serial.print("B4 = ");
204+
Serial.println(B4);
205+
Serial.print("B7 = ");
206+
Serial.println(B7);
173207
#endif
174208

175209
if (B7 < 0x80000000) {
@@ -182,25 +216,29 @@ int32_t Adafruit_BMP085::readPressure(void) {
182216
X2 = (-7357 * p) >> 16;
183217

184218
#if BMP085_DEBUG == 1
185-
Serial.print("p = "); Serial.println(p);
186-
Serial.print("X1 = "); Serial.println(X1);
187-
Serial.print("X2 = "); Serial.println(X2);
219+
Serial.print("p = ");
220+
Serial.println(p);
221+
Serial.print("X1 = ");
222+
Serial.println(X1);
223+
Serial.print("X2 = ");
224+
Serial.println(X2);
188225
#endif
189226

190-
p = p + ((X1 + X2 + (int32_t)3791)>>4);
227+
p = p + ((X1 + X2 + (int32_t)3791) >> 4);
191228
#if BMP085_DEBUG == 1
192-
Serial.print("p = "); Serial.println(p);
229+
Serial.print("p = ");
230+
Serial.println(p);
193231
#endif
194232
return p;
195233
}
196234

197235
int32_t Adafruit_BMP085::readSealevelPressure(float altitude_meters) {
198236
float pressure = readPressure();
199-
return (int32_t)(pressure / pow(1.0-altitude_meters/44330, 5.255));
237+
return (int32_t)(pressure / pow(1.0 - altitude_meters / 44330, 5.255));
200238
}
201239

202240
float Adafruit_BMP085::readTemperature(void) {
203-
int32_t UT, B5; // following ds convention
241+
int32_t UT, B5; // following ds convention
204242
float temp;
205243

206244
UT = readRawTemperature();
@@ -215,9 +253,9 @@ float Adafruit_BMP085::readTemperature(void) {
215253
#endif
216254

217255
B5 = computeB5(UT);
218-
temp = (B5+8) >> 4;
256+
temp = (B5 + 8) >> 4;
219257
temp /= 10;
220-
258+
221259
return temp;
222260
}
223261

@@ -226,27 +264,26 @@ float Adafruit_BMP085::readAltitude(float sealevelPressure) {
226264

227265
float pressure = readPressure();
228266

229-
altitude = 44330 * (1.0 - pow(pressure /sealevelPressure,0.1903));
267+
altitude = 44330 * (1.0 - pow(pressure / sealevelPressure, 0.1903));
230268

231269
return altitude;
232270
}
233271

234-
235272
/*********************************************************************/
236273

237274
uint8_t Adafruit_BMP085::read8(uint8_t a) {
238275
uint8_t ret;
239276

240-
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
277+
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
241278
#if (ARDUINO >= 100)
242279
Wire.write(a); // sends register address to read from
243280
#else
244-
Wire.send(a); // sends register address to read from
281+
Wire.send(a); // sends register address to read from
245282
#endif
246283
Wire.endTransmission(); // end transmission
247-
248-
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
249-
Wire.requestFrom(BMP085_I2CADDR, 1);// send data n-bytes read
284+
285+
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
286+
Wire.requestFrom(BMP085_I2CADDR, 1); // send data n-bytes read
250287
#if (ARDUINO >= 100)
251288
ret = Wire.read(); // receive DATA
252289
#else
@@ -260,16 +297,16 @@ uint8_t Adafruit_BMP085::read8(uint8_t a) {
260297
uint16_t Adafruit_BMP085::read16(uint8_t a) {
261298
uint16_t ret;
262299

263-
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
300+
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
264301
#if (ARDUINO >= 100)
265302
Wire.write(a); // sends register address to read from
266303
#else
267-
Wire.send(a); // sends register address to read from
304+
Wire.send(a); // sends register address to read from
268305
#endif
269306
Wire.endTransmission(); // end transmission
270-
271-
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
272-
Wire.requestFrom(BMP085_I2CADDR, 2);// send data n-bytes read
307+
308+
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
309+
Wire.requestFrom(BMP085_I2CADDR, 2); // send data n-bytes read
273310
#if (ARDUINO >= 100)
274311
ret = Wire.read(); // receive DATA
275312
ret <<= 8;
@@ -285,13 +322,13 @@ uint16_t Adafruit_BMP085::read16(uint8_t a) {
285322
}
286323

287324
void Adafruit_BMP085::write8(uint8_t a, uint8_t d) {
288-
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
325+
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
289326
#if (ARDUINO >= 100)
290327
Wire.write(a); // sends register address to read from
291-
Wire.write(d); // write data
328+
Wire.write(d); // write data
292329
#else
293-
Wire.send(a); // sends register address to read from
294-
Wire.send(d); // write data
330+
Wire.send(a); // sends register address to read from
331+
Wire.send(d); // write data
295332
#endif
296333
Wire.endTransmission(); // end transmission
297334
}

0 commit comments

Comments
 (0)