/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter

« back to all changes in this revision

Viewing changes to test/barometric-pressure/libs/BMP085/BMP085.h

  • Committer: Tim Marston
  • Date: 2013-01-16 21:42:06 UTC
  • Revision ID: tim@ed.am-20130116214206-5mw4cgsya1h0yiyq
updated arduino.mk

Show diffs side-by-side

added added

removed removed

1
 
/*************************************************** 
2
 
  This is a library for the BMP085 Barometric Pressure & Temp Sensor
3
 
 
4
 
  Designed specifically to work with the Adafruit BMP085 Breakout 
5
 
  ----> https://www.adafruit.com/products/391
6
 
 
7
 
  These displays use I2C to communicate, 2 pins are required to  
8
 
  interface
9
 
  Adafruit invests time and resources providing this open source code, 
10
 
  please support Adafruit and open-source hardware by purchasing 
11
 
  products from Adafruit!
12
 
 
13
 
  Written by Limor Fried/Ladyada for Adafruit Industries.  
14
 
  BSD license, all text above must be included in any redistribution
15
 
 ****************************************************/
16
 
 
17
 
#if (ARDUINO >= 100)
18
 
 #include "Arduino.h"
19
 
#else
20
 
 #include "WProgram.h"
21
 
#endif
22
 
#include "Wire.h"
23
 
 
24
 
#define BMP085_DEBUG 0
25
 
 
26
 
#define BMP085_I2CADDR 0x77
27
 
 
28
 
#define BMP085_ULTRALOWPOWER 0
29
 
#define BMP085_STANDARD      1
30
 
#define BMP085_HIGHRES       2
31
 
#define BMP085_ULTRAHIGHRES  3
32
 
#define BMP085_CAL_AC1           0xAA  // R   Calibration data (16 bits)
33
 
#define BMP085_CAL_AC2           0xAC  // R   Calibration data (16 bits)
34
 
#define BMP085_CAL_AC3           0xAE  // R   Calibration data (16 bits)    
35
 
#define BMP085_CAL_AC4           0xB0  // R   Calibration data (16 bits)
36
 
#define BMP085_CAL_AC5           0xB2  // R   Calibration data (16 bits)
37
 
#define BMP085_CAL_AC6           0xB4  // R   Calibration data (16 bits)
38
 
#define BMP085_CAL_B1            0xB6  // R   Calibration data (16 bits)
39
 
#define BMP085_CAL_B2            0xB8  // R   Calibration data (16 bits)
40
 
#define BMP085_CAL_MB            0xBA  // R   Calibration data (16 bits)
41
 
#define BMP085_CAL_MC            0xBC  // R   Calibration data (16 bits)
42
 
#define BMP085_CAL_MD            0xBE  // R   Calibration data (16 bits)
43
 
 
44
 
#define BMP085_CONTROL           0xF4 
45
 
#define BMP085_TEMPDATA          0xF6
46
 
#define BMP085_PRESSUREDATA      0xF6
47
 
#define BMP085_READTEMPCMD          0x2E
48
 
#define BMP085_READPRESSURECMD            0x34
49
 
 
50
 
 
51
 
class BMP085 {
52
 
 public:
53
 
  BMP085();
54
 
  boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES);  // by default go highres
55
 
  float readTemperature(void);
56
 
  int32_t readPressure(void);
57
 
  float readAltitude(float sealevelPressure = 101325); // std atmosphere
58
 
  uint16_t readRawTemperature(void);
59
 
  uint32_t readRawPressure(void);
60
 
  
61
 
 private:
62
 
  uint8_t read8(uint8_t addr);
63
 
  uint16_t read16(uint8_t addr);
64
 
  void write8(uint8_t addr, uint8_t data);
65
 
 
66
 
  uint8_t oversampling;
67
 
 
68
 
  int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
69
 
  uint16_t ac4, ac5, ac6;
70
 
};
71