Skip to content

Commit 0725be4

Browse files
committed
turn off debug and added some comments
1 parent e2a7920 commit 0725be4

File tree

5 files changed

+84
-7
lines changed

5 files changed

+84
-7
lines changed

bmp180/bmp180.cpp

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
/*
2+
Author: Mike White ([email protected]; @mikewhite808)
3+
4+
Implementation for reading data from BMP180 breakout board from Adafruit.
5+
https://www.adafruit.com/product/1603
6+
7+
Code below heavily used the Adafruit Python implementation of BMP085 found here:
8+
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_BMP085/Adafruit_BMP085.py
9+
*/
10+
11+
#include <unistd.h>
12+
#include <math.h>
113
#include "bmp180.h"
214
#include "i2c.h"
15+
#ifdef DEBUG
316
#include <iostream>
4-
#include <unistd.h>
5-
#include <math.h>
17+
#endif
618

719
using namespace std;
820

21+
/************************************************************
22+
* Constructor
23+
*
24+
* Parameters:
25+
* mode - the mode to run in (default is BMP085_STANDARD)
26+
***********************************************************/
927
BMP180::BMP180(int mode)
1028
: _i2c(0), _cal_AC1(0), _cal_AC2(0), _cal_AC3(0), _cal_B1(0), _cal_B2(0), _cal_MB(0),
1129
_cal_MC(0), _cal_MD(0), _mode(mode), _cal_AC4(0), _cal_AC5(0), _cal_AC6(0)
@@ -14,12 +32,19 @@ BMP180::BMP180(int mode)
1432
_init();
1533
}
1634

35+
/************************************************************
36+
* Destructor
37+
***********************************************************/
1738
BMP180::~BMP180()
1839
{
1940
delete _i2c;
2041
_i2c = 0;
2142
}
2243

44+
/************************************************************
45+
* Reads the calibrated values that will be used for
46+
* calculations
47+
***********************************************************/
2348
void BMP180::_init()
2449
{
2550
UINT8 data[2];
@@ -61,17 +86,41 @@ void BMP180::_init()
6186
#endif
6287
}
6388

64-
int BMP180::_readU16(UINT8 *data)
89+
/************************************************************
90+
* Reads an unsigned 16-bit value
91+
*
92+
* Parameters:
93+
* data - the data to read the values from
94+
*
95+
* Returns a unsigned 16-bit value
96+
***********************************************************/
97+
UINT16 BMP180::_readU16(UINT8 *data)
6598
{
6699
return ((data[0] << 8) | data[1]);
67100
}
68101

102+
/************************************************************
103+
* Reads a signed 16-bit value
104+
*
105+
* Parameters:
106+
* data - the data to read the values from
107+
*
108+
* Returns a signed 16-bit value
109+
***********************************************************/
69110
int BMP180::_readS16(UINT8 *data)
70111
{
71112
int hi = _readS8(&data[0]);
72113
return ((hi << 8) | data[1]);
73114
}
74115

116+
/************************************************************
117+
* Reads a signed 8-bit value
118+
*
119+
* Parameters:
120+
* data - the data to read the values from
121+
*
122+
* Returns a signed 8-bit value
123+
***********************************************************/
75124
int BMP180::_readS8(UINT8 *data)
76125
{
77126
if (data[0] > 127)
@@ -80,6 +129,11 @@ int BMP180::_readS8(UINT8 *data)
80129
return (int)data[0];
81130
}
82131

132+
/************************************************************
133+
* Reads the temperature in degrees celsius
134+
*
135+
* Returns the temperature in pascal
136+
***********************************************************/
83137
double BMP180::readTemperature()
84138
{
85139
UINT16 rawTemp = _readRawTemperature();
@@ -93,6 +147,11 @@ double BMP180::readTemperature()
93147
return temp;
94148
}
95149

150+
/************************************************************
151+
* Reads the pressure in pascal
152+
*
153+
* Returns the pressure in pascal
154+
***********************************************************/
96155
UINT32 BMP180::readPressure()
97156
{
98157
UINT16 UT = _readRawTemperature();
@@ -145,6 +204,14 @@ UINT32 BMP180::readPressure()
145204
return p;
146205
}
147206

207+
/************************************************************
208+
* Reads the altitude in meters
209+
*
210+
* Parameters:
211+
* seaLevelPressure - the pressure at sea level default
212+
* value is 101325
213+
* Returns the altitude in meters
214+
***********************************************************/
148215
double BMP180::readAltitude(UINT32 seaLevelPressure)
149216
{
150217
double altitude = 0;
@@ -161,6 +228,11 @@ double BMP180::readSeaLevelPressure()
161228
return 0;
162229
}
163230

231+
/************************************************************
232+
* Reads the raw temperature
233+
*
234+
* Returns the raw temperature reading
235+
***********************************************************/
164236
UINT16 BMP180::_readRawTemperature()
165237
{
166238
UINT8 data[2];
@@ -175,6 +247,11 @@ UINT16 BMP180::_readRawTemperature()
175247
return retval;
176248
}
177249

250+
/************************************************************
251+
* Reads the raw pressure
252+
*
253+
* Returns the raw pressure reading
254+
***********************************************************/
178255
UINT32 BMP180::_readRawPressure()
179256
{
180257
_i2c->writeCommand(1, BMP085_READPRESSURECMD);

bmp180/bmp180.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class BMP180
4242

4343
private:
4444
void _init();
45-
int _readU16(UINT8 *data);
45+
UINT16 _readU16(UINT8 *data);
4646
int _readS16(UINT8 *data);
4747
int _readS8(UINT8 *data);
4848
UINT16 _readRawTemperature();

bmp180/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OBJDIR = obj
33
BINDIR = bin
44
$(shell mkdir -p $(OBJDIR) $(BINDIR))
55

6-
DEBUG = 1
6+
DEBUG = 0
77
CC = g++
88
CFLAGS = -Wall -I../i2c
99
LINC = -L../i2c/bin

i2c/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OBJDIR = obj
55
BINDIR = bin
66
$(shell mkdir -p $(OBJDIR) $(BINDIR))
77

8-
DEBUG = 1
8+
DEBUG = 0
99
CC = g++
1010
CFLAGS = -Wall
1111
LINC =

oled/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OBJDIR = obj
44
BINDIR = bin
55
$(shell mkdir -p $(OBJDIR) $(BINDIR))
66

7-
DEBUG = 1
7+
DEBUG = 0
88
CC = g++
99
CFLAGS = -Wall -I../i2c
1010
LINC = -L../i2c/bin

0 commit comments

Comments
 (0)