From 23e47fa3b99406f279c92ec02b0896cdfe7c025c Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 24 Feb 2015 16:41:37 -0700 Subject: [PATCH] bmpx8x: rename gy65 to bmpx8x to more properly reflect supported chips Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- examples/c++/CMakeLists.txt | 6 ++-- examples/c++/{gy65.cxx => bmpx8x.cxx} | 8 +++--- examples/javascript/{gy65.js => bmpx8x.js} | 14 +++++----- src/{gy65 => bmpx8x}/CMakeLists.txt | 4 +-- src/{gy65/gy65.cxx => bmpx8x/bmpx8x.cxx} | 28 +++++++++---------- src/{gy65/gy65.h => bmpx8x/bmpx8x.h} | 32 ++++++++++------------ src/bmpx8x/jsupm_bmpx8x.i | 8 ++++++ src/bmpx8x/pyupm_bmpx8x.i | 10 +++++++ src/gy65/jsupm_gy65.i | 8 ------ src/gy65/pyupm_gy65.i | 10 ------- 10 files changed, 63 insertions(+), 65 deletions(-) rename examples/c++/{gy65.cxx => bmpx8x.cxx} (94%) rename examples/javascript/{gy65.js => bmpx8x.js} (84%) rename src/{gy65 => bmpx8x}/CMakeLists.txt (57%) rename src/{gy65/gy65.cxx => bmpx8x/bmpx8x.cxx} (91%) rename src/{gy65/gy65.h => bmpx8x/bmpx8x.h} (87%) create mode 100644 src/bmpx8x/jsupm_bmpx8x.i create mode 100644 src/bmpx8x/pyupm_bmpx8x.i delete mode 100644 src/gy65/jsupm_gy65.i delete mode 100644 src/gy65/pyupm_gy65.i diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index d430fc8f..8f46e923 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -23,7 +23,7 @@ add_executable (max44000-example max44000.cxx) add_executable (mma7455-example mma7455.cxx) add_executable (st7735-example st7735.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 (pulsensor-example pulsensor.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/st7735) 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/pulsensor) 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 (st7735-example st7735 ${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 (pulsensor-example pulsensor ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (mic-example mic ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/c++/gy65.cxx b/examples/c++/bmpx8x.cxx similarity index 94% rename from examples/c++/gy65.cxx rename to examples/c++/bmpx8x.cxx index 6d1b322d..28e5be88 100644 --- a/examples/c++/gy65.cxx +++ b/examples/c++/bmpx8x.cxx @@ -24,11 +24,11 @@ #include #include -#include "gy65.h" +#include "bmpx8x.h" #include int doWork = 0; -upm::GY65 *sensor = NULL; +upm::BMPX8X *sensor = NULL; void sig_handler(int signo) @@ -49,8 +49,8 @@ main(int argc, char **argv) float altitude = 0; uint32_t sealevel = 0; - // Instantiate a GY65 sensor on I2C - sensor = new upm::GY65(0, ADDR); + // Instantiate a BMPX8X sensor on I2C + sensor = new upm::BMPX8X(0, ADDR); // Print the pressure, altitude, sea level, and // temperature values every 0.1 seconds diff --git a/examples/javascript/gy65.js b/examples/javascript/bmpx8x.js similarity index 84% rename from examples/javascript/gy65.js rename to examples/javascript/bmpx8x.js index b5abe0e3..3da0514f 100644 --- a/examples/javascript/gy65.js +++ b/examples/javascript/bmpx8x.js @@ -26,9 +26,9 @@ */ //Load Barometer module -var gy65 = require('jsupm_gy65'); +var bmpx8x = require('jsupm_bmpx8x'); // 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; // Print the pressure, altitude, sea level, and @@ -40,11 +40,11 @@ setInterval(function() var altitude = myBarometerObj.getAltitude(); var sealevel = myBarometerObj.getSealevelPressure(); - var GY65results = "pressure value = " + pressure; - GY65results += ", altitude value = " + altitude; - GY65results += ", sealevel value = " + sealevel; - GY65results += ", temperature = " + temperature; - console.log(GY65results); + var BMPX8Xresults = "pressure value = " + pressure; + BMPX8Xresults += ", altitude value = " + altitude; + BMPX8Xresults += ", sealevel value = " + sealevel; + BMPX8Xresults += ", temperature = " + temperature; + console.log(BMPX8Xresults); }, 100); // Print message when exiting diff --git a/src/gy65/CMakeLists.txt b/src/bmpx8x/CMakeLists.txt similarity index 57% rename from src/gy65/CMakeLists.txt rename to src/bmpx8x/CMakeLists.txt index 3607be32..5960e124 100644 --- a/src/gy65/CMakeLists.txt +++ b/src/bmpx8x/CMakeLists.txt @@ -1,5 +1,5 @@ -set (libname "gy65") -set (libdescription "upm GY65") +set (libname "bmpx8x") +set (libdescription "upm BMPX8X") set (module_src ${libname}.cxx) set (module_h ${libname}.h) upm_module_init() diff --git a/src/gy65/gy65.cxx b/src/bmpx8x/bmpx8x.cxx similarity index 91% rename from src/gy65/gy65.cxx rename to src/bmpx8x/bmpx8x.cxx index ec7a4d8f..2bb2aef2 100644 --- a/src/gy65/gy65.cxx +++ b/src/bmpx8x/bmpx8x.cxx @@ -26,12 +26,12 @@ #include #include -#include "gy65.h" +#include "bmpx8x.h" using namespace upm; -GY65::GY65 (int bus, int devAddr, uint8_t mode) { - m_name = "GY65"; +BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) { + m_name = "BMPX8X"; m_controlAddr = devAddr; m_bus = bus; @@ -69,12 +69,12 @@ GY65::GY65 (int bus, int devAddr, uint8_t mode) { md = i2cReadReg_16 (BMP085_CAL_MD); } -GY65::~GY65() { +BMPX8X::~BMPX8X() { mraa_i2c_stop(m_i2ControlCtx); } int32_t -GY65::getPressure () { +BMPX8X::getPressure () { int32_t UT, UP, B3, B5, B6, X1, X2, X3, p; uint32_t B4, B7; @@ -110,7 +110,7 @@ GY65::getPressure () { } int32_t -GY65::getPressureRaw () { +BMPX8X::getPressureRaw () { uint32_t raw; i2cWriteReg (BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6)); @@ -135,14 +135,14 @@ GY65::getPressureRaw () { } int16_t -GY65::getTemperatureRaw () { +BMPX8X::getTemperatureRaw () { i2cWriteReg (BMP085_CONTROL, BMP085_READTEMPCMD); usleep(5000); return i2cReadReg_16 (BMP085_TEMPDATA); } float -GY65::getTemperature () { +BMPX8X::getTemperature () { int32_t UT, B5; // following ds convention float temp; @@ -156,13 +156,13 @@ GY65::getTemperature () { } int32_t -GY65::getSealevelPressure(float altitudeMeters) { +BMPX8X::getSealevelPressure(float altitudeMeters) { float pressure = getPressure (); return (int32_t)(pressure / pow(1.0-altitudeMeters/44330, 5.255)); } float -GY65::getAltitude (float sealevelPressure) { +BMPX8X::getAltitude (float sealevelPressure) { float altitude; float pressure = getPressure (); @@ -173,7 +173,7 @@ GY65::getAltitude (float sealevelPressure) { } 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 X2 = ((int32_t)mc << 11) / (X1+(int32_t)md); @@ -181,7 +181,7 @@ GY65::computeB5(int32_t UT) { } 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; uint8_t data[2] = { reg, value }; @@ -192,7 +192,7 @@ GY65::i2cWriteReg (uint8_t reg, uint8_t value) { } uint16_t -GY65::i2cReadReg_16 (int reg) { +BMPX8X::i2cReadReg_16 (int reg) { uint16_t data; mraa_i2c_address(m_i2ControlCtx, m_controlAddr); @@ -209,7 +209,7 @@ GY65::i2cReadReg_16 (int reg) { } uint8_t -GY65::i2cReadReg_8 (int reg) { +BMPX8X::i2cReadReg_8 (int reg) { uint8_t data; mraa_i2c_address(m_i2ControlCtx, m_controlAddr); diff --git a/src/gy65/gy65.h b/src/bmpx8x/bmpx8x.h similarity index 87% rename from src/gy65/gy65.h rename to src/bmpx8x/bmpx8x.h index f5fcffff..9f5f49d3 100644 --- a/src/gy65/gy65.h +++ b/src/bmpx8x/bmpx8x.h @@ -1,5 +1,6 @@ /* * Author: Yevgeniy Kiveisha + * Contributions: Jon Trulson * Copyright (c) 2014 Intel Corporation. * * Credits to Adafruit. @@ -61,37 +62,34 @@ namespace upm { /** - * @brief GY65 & BPM085 atmospheric pressure sensor library - * @defgroup gy65 libupm-gy65 - */ - -/** - * @brief C++ API for GY65/BMP085 chip (Atmospheric Pressure Sensor) + * @brief C++ API for GY65/BMP085 and BMP180 chips (Atmospheric Pressure Sensor) * - * The Bosch [BMP085] - * (https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf) - * is a high precision, ultra-low power consumption pressure sensor. It has a - * range of between 30,000 and 110,000 Pa. + * The Bosch GY65/BMP085 and BMP180 are high precision, ultra-low + * power consumption pressure sensors. They have a range of between + * 30,000 and 110,000 Pa. * - * @ingroup gy65 i2c - * @snippet gy65.cxx Interesting + * This module has been tested on the GY65/BMP085 and BMP180 sensors. + * + * @ingroup bmpx8x i2c + * @defgroup bmpx8x libupm-bmpx8x + * @snippet bmpx8x.cxx Interesting * @image html bmp085.jpeg */ -class GY65 { +class BMPX8X { public: /** - * Instanciates a GY65 object + * Instanciates a BMPX8X object * * @param bus number of used bus * @param devAddr address of used i2c device * @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 diff --git a/src/bmpx8x/jsupm_bmpx8x.i b/src/bmpx8x/jsupm_bmpx8x.i new file mode 100644 index 00000000..419f75c5 --- /dev/null +++ b/src/bmpx8x/jsupm_bmpx8x.i @@ -0,0 +1,8 @@ +%module jsupm_bmpx8x +%include "../upm.i" + +%{ + #include "bmpx8x.h" +%} + +%include "bmpx8x.h" diff --git a/src/bmpx8x/pyupm_bmpx8x.i b/src/bmpx8x/pyupm_bmpx8x.i new file mode 100644 index 00000000..d3f48f33 --- /dev/null +++ b/src/bmpx8x/pyupm_bmpx8x.i @@ -0,0 +1,10 @@ +%module pyupm_bmpx8x +%include "../upm.i" + +%include "stdint.i" + +%include "bmpx8x.h" +%{ + #include "bmpx8x.h" +%} + diff --git a/src/gy65/jsupm_gy65.i b/src/gy65/jsupm_gy65.i deleted file mode 100644 index a3deba3a..00000000 --- a/src/gy65/jsupm_gy65.i +++ /dev/null @@ -1,8 +0,0 @@ -%module jsupm_gy65 -%include "../upm.i" - -%{ - #include "gy65.h" -%} - -%include "gy65.h" diff --git a/src/gy65/pyupm_gy65.i b/src/gy65/pyupm_gy65.i deleted file mode 100644 index 1e3e2df1..00000000 --- a/src/gy65/pyupm_gy65.i +++ /dev/null @@ -1,10 +0,0 @@ -%module pyupm_gy65 -%include "../upm.i" - -%include "stdint.i" - -%include "gy65.h" -%{ - #include "gy65.h" -%} -