bmpx8x: rename gy65 to bmpx8x to more properly reflect supported chips

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-02-24 16:41:37 -07:00 committed by Mihai Tudor Panu
parent f0dd5f9530
commit 23e47fa3b9
10 changed files with 63 additions and 65 deletions

View File

@ -23,7 +23,7 @@ add_executable (max44000-example max44000.cxx)
add_executable (mma7455-example mma7455.cxx) add_executable (mma7455-example mma7455.cxx)
add_executable (st7735-example st7735.cxx) add_executable (st7735-example st7735.cxx)
add_executable (max31855-example max31855.cxx) add_executable (max31855-example max31855.cxx)
add_executable (gy65-example gy65.cxx) add_executable (bmpx8x-example bmpx8x.cxx)
add_executable (stepmotor-example stepmotor.cxx) add_executable (stepmotor-example stepmotor.cxx)
add_executable (pulsensor-example pulsensor.cxx) add_executable (pulsensor-example pulsensor.cxx)
add_executable (mic-example mic.cxx) add_executable (mic-example mic.cxx)
@ -102,7 +102,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/max44000)
include_directories (${PROJECT_SOURCE_DIR}/src/mma7455) include_directories (${PROJECT_SOURCE_DIR}/src/mma7455)
include_directories (${PROJECT_SOURCE_DIR}/src/st7735) include_directories (${PROJECT_SOURCE_DIR}/src/st7735)
include_directories (${PROJECT_SOURCE_DIR}/src/max31855) include_directories (${PROJECT_SOURCE_DIR}/src/max31855)
include_directories (${PROJECT_SOURCE_DIR}/src/gy65) include_directories (${PROJECT_SOURCE_DIR}/src/bmpx8x)
include_directories (${PROJECT_SOURCE_DIR}/src/stepmotor) include_directories (${PROJECT_SOURCE_DIR}/src/stepmotor)
include_directories (${PROJECT_SOURCE_DIR}/src/pulsensor) include_directories (${PROJECT_SOURCE_DIR}/src/pulsensor)
include_directories (${PROJECT_SOURCE_DIR}/src/mic) include_directories (${PROJECT_SOURCE_DIR}/src/mic)
@ -183,7 +183,7 @@ target_link_libraries (max44000-example max44000 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mma7455-example mma7455 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (mma7455-example mma7455 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (st7735-example st7735 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (st7735-example st7735 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (max31855-example max31855 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (max31855-example max31855 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (gy65-example gy65 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (bmpx8x-example bmpx8x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (stepmotor-example stepmotor ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (stepmotor-example stepmotor ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pulsensor-example pulsensor ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (pulsensor-example pulsensor ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mic-example mic ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (mic-example mic ${CMAKE_THREAD_LIBS_INIT})

View File

@ -24,11 +24,11 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include "gy65.h" #include "bmpx8x.h"
#include <signal.h> #include <signal.h>
int doWork = 0; int doWork = 0;
upm::GY65 *sensor = NULL; upm::BMPX8X *sensor = NULL;
void void
sig_handler(int signo) sig_handler(int signo)
@ -49,8 +49,8 @@ main(int argc, char **argv)
float altitude = 0; float altitude = 0;
uint32_t sealevel = 0; uint32_t sealevel = 0;
// Instantiate a GY65 sensor on I2C // Instantiate a BMPX8X sensor on I2C
sensor = new upm::GY65(0, ADDR); sensor = new upm::BMPX8X(0, ADDR);
// Print the pressure, altitude, sea level, and // Print the pressure, altitude, sea level, and
// temperature values every 0.1 seconds // temperature values every 0.1 seconds

View File

@ -26,9 +26,9 @@
*/ */
//Load Barometer module //Load Barometer module
var gy65 = require('jsupm_gy65'); var bmpx8x = require('jsupm_bmpx8x');
// load this on i2c // load this on i2c
var myBarometerObj = new gy65.GY65(0, gy65.ADDR); var myBarometerObj = new bmpx8x.BMPX8X(0, bmpx8x.ADDR);
var pressure, temperature, altitude, sealevel; var pressure, temperature, altitude, sealevel;
// Print the pressure, altitude, sea level, and // Print the pressure, altitude, sea level, and
@ -40,11 +40,11 @@ setInterval(function()
var altitude = myBarometerObj.getAltitude(); var altitude = myBarometerObj.getAltitude();
var sealevel = myBarometerObj.getSealevelPressure(); var sealevel = myBarometerObj.getSealevelPressure();
var GY65results = "pressure value = " + pressure; var BMPX8Xresults = "pressure value = " + pressure;
GY65results += ", altitude value = " + altitude; BMPX8Xresults += ", altitude value = " + altitude;
GY65results += ", sealevel value = " + sealevel; BMPX8Xresults += ", sealevel value = " + sealevel;
GY65results += ", temperature = " + temperature; BMPX8Xresults += ", temperature = " + temperature;
console.log(GY65results); console.log(BMPX8Xresults);
}, 100); }, 100);
// Print message when exiting // Print message when exiting

View File

@ -1,5 +1,5 @@
set (libname "gy65") set (libname "bmpx8x")
set (libdescription "upm GY65") set (libdescription "upm BMPX8X")
set (module_src ${libname}.cxx) set (module_src ${libname}.cxx)
set (module_h ${libname}.h) set (module_h ${libname}.h)
upm_module_init() upm_module_init()

View File

@ -26,12 +26,12 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include "gy65.h" #include "bmpx8x.h"
using namespace upm; using namespace upm;
GY65::GY65 (int bus, int devAddr, uint8_t mode) { BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) {
m_name = "GY65"; m_name = "BMPX8X";
m_controlAddr = devAddr; m_controlAddr = devAddr;
m_bus = bus; m_bus = bus;
@ -69,12 +69,12 @@ GY65::GY65 (int bus, int devAddr, uint8_t mode) {
md = i2cReadReg_16 (BMP085_CAL_MD); md = i2cReadReg_16 (BMP085_CAL_MD);
} }
GY65::~GY65() { BMPX8X::~BMPX8X() {
mraa_i2c_stop(m_i2ControlCtx); mraa_i2c_stop(m_i2ControlCtx);
} }
int32_t int32_t
GY65::getPressure () { BMPX8X::getPressure () {
int32_t UT, UP, B3, B5, B6, X1, X2, X3, p; int32_t UT, UP, B3, B5, B6, X1, X2, X3, p;
uint32_t B4, B7; uint32_t B4, B7;
@ -110,7 +110,7 @@ GY65::getPressure () {
} }
int32_t int32_t
GY65::getPressureRaw () { BMPX8X::getPressureRaw () {
uint32_t raw; uint32_t raw;
i2cWriteReg (BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6)); i2cWriteReg (BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6));
@ -135,14 +135,14 @@ GY65::getPressureRaw () {
} }
int16_t int16_t
GY65::getTemperatureRaw () { BMPX8X::getTemperatureRaw () {
i2cWriteReg (BMP085_CONTROL, BMP085_READTEMPCMD); i2cWriteReg (BMP085_CONTROL, BMP085_READTEMPCMD);
usleep(5000); usleep(5000);
return i2cReadReg_16 (BMP085_TEMPDATA); return i2cReadReg_16 (BMP085_TEMPDATA);
} }
float float
GY65::getTemperature () { BMPX8X::getTemperature () {
int32_t UT, B5; // following ds convention int32_t UT, B5; // following ds convention
float temp; float temp;
@ -156,13 +156,13 @@ GY65::getTemperature () {
} }
int32_t int32_t
GY65::getSealevelPressure(float altitudeMeters) { BMPX8X::getSealevelPressure(float altitudeMeters) {
float pressure = getPressure (); float pressure = getPressure ();
return (int32_t)(pressure / pow(1.0-altitudeMeters/44330, 5.255)); return (int32_t)(pressure / pow(1.0-altitudeMeters/44330, 5.255));
} }
float float
GY65::getAltitude (float sealevelPressure) { BMPX8X::getAltitude (float sealevelPressure) {
float altitude; float altitude;
float pressure = getPressure (); float pressure = getPressure ();
@ -173,7 +173,7 @@ GY65::getAltitude (float sealevelPressure) {
} }
int32_t int32_t
GY65::computeB5(int32_t UT) { BMPX8X::computeB5(int32_t UT) {
int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15;
int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md); int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md);
@ -181,7 +181,7 @@ GY65::computeB5(int32_t UT) {
} }
mraa_result_t mraa_result_t
GY65::i2cWriteReg (uint8_t reg, uint8_t value) { BMPX8X::i2cWriteReg (uint8_t reg, uint8_t value) {
mraa_result_t error = MRAA_SUCCESS; mraa_result_t error = MRAA_SUCCESS;
uint8_t data[2] = { reg, value }; uint8_t data[2] = { reg, value };
@ -192,7 +192,7 @@ GY65::i2cWriteReg (uint8_t reg, uint8_t value) {
} }
uint16_t uint16_t
GY65::i2cReadReg_16 (int reg) { BMPX8X::i2cReadReg_16 (int reg) {
uint16_t data; uint16_t data;
mraa_i2c_address(m_i2ControlCtx, m_controlAddr); mraa_i2c_address(m_i2ControlCtx, m_controlAddr);
@ -209,7 +209,7 @@ GY65::i2cReadReg_16 (int reg) {
} }
uint8_t uint8_t
GY65::i2cReadReg_8 (int reg) { BMPX8X::i2cReadReg_8 (int reg) {
uint8_t data; uint8_t data;
mraa_i2c_address(m_i2ControlCtx, m_controlAddr); mraa_i2c_address(m_i2ControlCtx, m_controlAddr);

View File

@ -1,5 +1,6 @@
/* /*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Contributions: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation. * Copyright (c) 2014 Intel Corporation.
* *
* Credits to Adafruit. * Credits to Adafruit.
@ -61,37 +62,34 @@
namespace upm { namespace upm {
/** /**
* @brief GY65 & BPM085 atmospheric pressure sensor library * @brief C++ API for GY65/BMP085 and BMP180 chips (Atmospheric Pressure Sensor)
* @defgroup gy65 libupm-gy65
*/
/**
* @brief C++ API for GY65/BMP085 chip (Atmospheric Pressure Sensor)
* *
* The Bosch [BMP085] * The Bosch GY65/BMP085 and BMP180 are high precision, ultra-low
* (https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf) * power consumption pressure sensors. They have a range of between
* is a high precision, ultra-low power consumption pressure sensor. It has a * 30,000 and 110,000 Pa.
* range of between 30,000 and 110,000 Pa.
* *
* @ingroup gy65 i2c * This module has been tested on the GY65/BMP085 and BMP180 sensors.
* @snippet gy65.cxx Interesting *
* @ingroup bmpx8x i2c
* @defgroup bmpx8x libupm-bmpx8x
* @snippet bmpx8x.cxx Interesting
* @image html bmp085.jpeg * @image html bmp085.jpeg
*/ */
class GY65 { class BMPX8X {
public: public:
/** /**
* Instanciates a GY65 object * Instanciates a BMPX8X object
* *
* @param bus number of used bus * @param bus number of used bus
* @param devAddr address of used i2c device * @param devAddr address of used i2c device
* @param mode BMP085 mode * @param mode BMP085 mode
*/ */
GY65 (int bus, int devAddr=0x77, uint8_t mode=BMP085_ULTRAHIGHRES); BMPX8X (int bus, int devAddr=0x77, uint8_t mode=BMP085_ULTRAHIGHRES);
/** /**
* GY65 object destructor, basicaly it close i2c connection. * BMPX8X object destructor, basicaly it close i2c connection.
*/ */
~GY65 (); ~BMPX8X ();
/** /**
* Return calculated pressure * Return calculated pressure

View File

@ -0,0 +1,8 @@
%module jsupm_bmpx8x
%include "../upm.i"
%{
#include "bmpx8x.h"
%}
%include "bmpx8x.h"

10
src/bmpx8x/pyupm_bmpx8x.i Normal file
View File

@ -0,0 +1,10 @@
%module pyupm_bmpx8x
%include "../upm.i"
%include "stdint.i"
%include "bmpx8x.h"
%{
#include "bmpx8x.h"
%}

View File

@ -1,8 +0,0 @@
%module jsupm_gy65
%include "../upm.i"
%{
#include "gy65.h"
%}
%include "gy65.h"

View File

@ -1,10 +0,0 @@
%module pyupm_gy65
%include "../upm.i"
%include "stdint.i"
%include "gy65.h"
%{
#include "gy65.h"
%}