diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index bb255b18..499f63e8 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -331,6 +331,7 @@ add_example (mcp2515) add_example (max30100) add_example (sensortemplate) add_example (p9813) +add_example (abpdrrt005pg2a5) # These are special cases where you specify example binary, source file and module(s) include_directories (${PROJECT_SOURCE_DIR}/src) diff --git a/examples/c++/abpdrrt005pg2a5.cxx b/examples/c++/abpdrrt005pg2a5.cxx new file mode 100644 index 00000000..22229971 --- /dev/null +++ b/examples/c++/abpdrrt005pg2a5.cxx @@ -0,0 +1,66 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "abpdrrt005pg2a5.hpp" + +using namespace std; + +int shouldRun = true; + +void sig_handler(int signo) +{ + if (signo == SIGINT) + shouldRun = false; +} + + +int main () +{ + signal(SIGINT, sig_handler); + +//! [Interesting] + // Instantiate an A110X sensor on digital pin D2 + upm::ABPDRRT005PG2A5* abp = new upm::ABPDRRT005PG2A5(0, ABPDRRT005PG2A5_ADDRESS); + + // check every second for the presence of a magnetic field (south + // polarity) + while (shouldRun) + { + float x = abp->get_pressure_psi(); + cout << "psi pressure: " << x << endl; + float y = abp->get_pressure_pascal(); + cout << "pascal pressure: " << y << endl; + + sleep(1); + } +//! [Interesting] + + cout << "Exiting..." << endl; + + delete abp; + return 0; +} diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index ba09e492..a0adf47a 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -151,6 +151,7 @@ add_example (enc03r) add_example (nunchuck) add_example (bno055) add_example (bmp280) +add_example (abpdrrt005pg2a5) # Custom examples add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps) diff --git a/examples/c/abpdrrt005pg2a5.c b/examples/c/abpdrrt005pg2a5.c new file mode 100644 index 00000000..14095aa6 --- /dev/null +++ b/examples/c/abpdrrt005pg2a5.c @@ -0,0 +1,55 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2017 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "abpdrrt005pg2a5.h" + +#include "upm_utilities.h" + +int main() +{ + abpdrrt005pg2a5_context dev = abpdrrt005pg2a5_init(0, ABPDRRT005PG2A5_ADDRESS); + if(dev == NULL) { + printf("Unable to initialize sensor\n"); + return 0; + } + float psi = 0; + float pascal = 0; + while(1){ + if(abpdrrt005pg2a5_get_pressure_psi(dev, &psi) != UPM_SUCCESS){ + printf("error in retrieving the psi value\n"); + } + if(abpdrrt005pg2a5_get_pressure_pascal(dev, &pascal) != UPM_SUCCESS){ + printf("error in retrieving the pascal value\n"); + } + upm_delay(1); + printf("PSI Value: %f and Pascal Value: %f\n", psi, pascal); + } + + return 0; +} \ No newline at end of file diff --git a/examples/javascript/abpdrrt005pg2a5.js b/examples/javascript/abpdrrt005pg2a5.js new file mode 100644 index 00000000..d7cbd56e --- /dev/null +++ b/examples/javascript/abpdrrt005pg2a5.js @@ -0,0 +1,41 @@ +/* +* Author: Abhishek Malik +* Copyright (c) 2017 Intel Corporation. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +var abpdrrt005pg2a5 = require("jsupm_abpdrrt005pg2a5"); + +// Instantiate a Honeywell ABP Pressure Sensor at bus 0 +var abp_sensor = new abpdrrt005pg2a5.ABPDRRT005PG2A5(0, 0x28); + +var myInterval = setInterval(function() +{ + console.log("Pressure Pascal: " + abp_sensor.get_pressure_pascal()); +}, 100); + +// When exiting: clear interval and print message +process.on('SIGINT', function() +{ + clearInterval(myInterval); + console.log("Exiting..."); + process.exit(0); +}); \ No newline at end of file diff --git a/examples/python/abpdrrt005pg2a5.py b/examples/python/abpdrrt005pg2a5.py new file mode 100644 index 00000000..33f9056f --- /dev/null +++ b/examples/python/abpdrrt005pg2a5.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# Author: Abhishek Malik +# Copyright (c) 2017 Intel Corporation. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +from __future__ import print_function +import time, sys, signal, atexit +from upm import pyupm_abpdrrt005pg2a5 as abpdrrt005pg2a5 + +def main(): + # Instantiate a Honeywell ABP Pressure sensor on the I2C bus 0 + abp_sensor = abpdrrt005pg2a5.ABPDRRT005PG2A5(0, 0x28); + + ## Exit handlers ## + # This function stops python from printing a stacktrace when you hit control-C + def SIGINTHandler(signum, frame): + raise SystemExit + + # This function lets you run code on exit, including functions from abpdrrt005pg2a5 + def exitHandler(): + print("Exiting") + sys.exit(0) + + # Register exit handlers + atexit.register(exitHandler) + signal.signal(signal.SIGINT, SIGINTHandler) + + # Read the value every second and detect the pressure + while(1): + print("Pressure PSI: {0}".format(abp_sensor.get_pressure_psi())) + print("Pressure Pascal: {0}".format(abp_sensor.get_pressure_pascal())) + time.sleep(.1) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/src/abpdrrt005pg2a5/CMakeLists.txt b/src/abpdrrt005pg2a5/CMakeLists.txt new file mode 100644 index 00000000..60a26588 --- /dev/null +++ b/src/abpdrrt005pg2a5/CMakeLists.txt @@ -0,0 +1,8 @@ +upm_mixed_module_init (NAME abpdrrt005pg2a5 + DESCRIPTION "Honeywell ABP Pressure Sensor" + C_HDR abpdrrt005pg2a5.h + C_SRC abpdrrt005pg2a5.c + CPP_HDR abpdrrt005pg2a5.hpp + CPP_SRC abpdrrt005pg2a5.cxx + CPP_WRAPS_C + REQUIRES mraa) diff --git a/src/abpdrrt005pg2a5/abpdrrt005pg2a5.c b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.c new file mode 100644 index 00000000..64b44e96 --- /dev/null +++ b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.c @@ -0,0 +1,102 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2016 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "abpdrrt005pg2a5.h" + +abpdrrt005pg2a5_context abpdrrt005pg2a5_init(uint8_t bus, uint8_t dev_address){ + // make sure MRAA is initialized + int mraa_rv; + if ((mraa_rv = mraa_init()) != MRAA_SUCCESS) + { + printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv); + return NULL; + } + + abpdrrt005pg2a5_context dev = + (abpdrrt005pg2a5_context) malloc(sizeof(struct _abpdrrt005pg2a5_context)); + + if (!dev) + { + return NULL; + } + + dev->i2c_bus_number = bus; + dev->address = dev_address; + + dev->i2c = mraa_i2c_init(dev->i2c_bus_number); + if (dev->i2c == NULL){ + free(dev); + return NULL; + } + + if (mraa_i2c_address(dev->i2c, dev->address) != MRAA_SUCCESS) + { + mraa_i2c_stop(dev->i2c); + free(dev); + return NULL; + } + + return dev; +} + +void abpdrrt005pg2a5_close(abpdrrt005pg2a5_context dev){ + free(dev); +} + +upm_result_t abpdrrt005pg2a5_get_pressure_psi(abpdrrt005pg2a5_context dev, float* pressure_psi){ + uint8_t temp[2]; + int output; + + int16_t ret = mraa_i2c_read_word_data(dev->i2c, ABPDRRT005PG2A5_ADDRESS); + if(ret == -1) + return UPM_ERROR_OPERATION_FAILED; + + temp[0] = (uint8_t) ret; // msb + temp[1] = (uint8_t)(ret >> 8); // lsb + // Status bits should be 0 and 0, other values might mean a different mode or a wrong value + uint8_t status = (temp[0] >> 6) & 0x03; + if(status != 0) + return UPM_ERROR_UNSPECIFIED; + output = temp[0]*256 + temp[1]; + + // Formula as per the data sheet + // output(% of 2^14 counts) = (((output(90% counts) - output(10% counts))/Pmax - Pmin)*(Papplied - Pmin)) + output(10% count) + // based on the formula we can calculate the pressure + // Papplied = ((output(counts) - output(10% count))*(Pmax - Pmin))/(output(90% counts) - output(10% counts)) + Pmin + *pressure_psi = ((((float)output - OUTPUT_10_PERCENT_COUNT)*(ABPDRRT005PG2A5_PRESSURE_MAX - ABPDRRT005PG2A5_PRESSURE_MIN))/(OUTPUT_90_PERCENT_COUNT - OUTPUT_10_PERCENT_COUNT)) + ABPDRRT005PG2A5_PRESSURE_MIN; + + return UPM_SUCCESS; +} + +upm_result_t abpdrrt005pg2a5_get_pressure_pascal(abpdrrt005pg2a5_context dev, float* pressure_pascal){ + float int_pressure; + + if(abpdrrt005pg2a5_get_pressure_psi(dev, &int_pressure) != UPM_SUCCESS){ + return UPM_ERROR_OPERATION_FAILED; + } + + // Conversion obtained from google + *pressure_pascal = 6894.75729*int_pressure; + + return UPM_SUCCESS; +} \ No newline at end of file diff --git a/src/abpdrrt005pg2a5/abpdrrt005pg2a5.cxx b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.cxx new file mode 100644 index 00000000..6d186449 --- /dev/null +++ b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.cxx @@ -0,0 +1,68 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2017 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +#include "abpdrrt005pg2a5.hpp" + +using namespace upm; + +ABPDRRT005PG2A5::ABPDRRT005PG2A5(int bus, int devAddress) : + m_abpdrrt005pg2a5(abpdrrt005pg2a5_init(bus, devAddress)) +{ + if(!m_abpdrrt005pg2a5) + throw std::runtime_error(std::string(__FUNCTION__) + + ": abpdrrt005pg2a5_init failed"); +} + +ABPDRRT005PG2A5::~ABPDRRT005PG2A5() +{ + abpdrrt005pg2a5_close(m_abpdrrt005pg2a5); +} + +float ABPDRRT005PG2A5::get_pressure_psi() +{ + float psi_pressure; + if(abpdrrt005pg2a5_get_pressure_psi(m_abpdrrt005pg2a5, &psi_pressure) != UPM_SUCCESS) { + throw std::runtime_error(std::string(__FUNCTION__) + + ": abpdrrt005pg2a5_get_pressure_psi unable to get " + + "pressure from sensor"); + } + + return psi_pressure; +} + +float ABPDRRT005PG2A5::get_pressure_pascal() +{ + float pascal_pressure; + if(abpdrrt005pg2a5_get_pressure_pascal(m_abpdrrt005pg2a5, &pascal_pressure) != UPM_SUCCESS) { + throw std::runtime_error(std::string(__FUNCTION__) + + ": abpdrrt005pg2a5_get_pressure_pascal unable to get " + + "pressure from sensor"); + } + + return pascal_pressure; +} \ No newline at end of file diff --git a/src/abpdrrt005pg2a5/abpdrrt005pg2a5.h b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.h new file mode 100644 index 00000000..e1184c60 --- /dev/null +++ b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.h @@ -0,0 +1,92 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2017 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include +#include +#include +#include + +#include "upm.h" +#include "mraa/i2c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ABPDRRT005PG2A5_ADDRESS 0x28 +#define OUTPUT_10_PERCENT_COUNT 1638 +#define OUTPUT_90_PERCENT_COUNT 14746 +#define ABPDRRT005PG2A5_PRESSURE_MAX 5 +#define ABPDRRT005PG2A5_PRESSURE_MIN 0 + +/** + * @file abpdrrt005pg2a5.h + * @library abpdrrt005pg2a5 + * @brief C API for the ABPDRRT005PG2A5 Honeywell Pressure Sensor + * + * @include abpdrrt005pg2a5.c + */ + + typedef struct _abpdrrt005pg2a5_context { + mraa_i2c_context i2c; + uint8_t i2c_bus_number; + uint8_t address; +} *abpdrrt005pg2a5_context; + +/** + * ABPDRRT005PG2A5 Initialization function + * + * @param bus I2C bus to use + * @return device context pointer + */ +abpdrrt005pg2a5_context abpdrrt005pg2a5_init(uint8_t bus, uint8_t dev_address); + +/** + * ABPDRRT005PG2A5 Close function + * + * @param dev abpdrrt005pg2a5_context pointer + */ +void abpdrrt005pg2a5_close(abpdrrt005pg2a5_context dev); + +/** + * Function to get the pressure in psi + * The datasheet provides a way to calculate the pressure + * in psi. + * + * @return upm_result_t UPM success/error code + */ +upm_result_t abpdrrt005pg2a5_get_pressure_psi(abpdrrt005pg2a5_context dev, float* pressure_psi); + +/** + * Function to get the pressure in pascal + * This is calculated using a conversion function. + * + * @return upm_result_t UPM success/error code + */ +upm_result_t abpdrrt005pg2a5_get_pressure_pascal(abpdrrt005pg2a5_context dev, float* pressure_pascal); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/abpdrrt005pg2a5/abpdrrt005pg2a5.hpp b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.hpp new file mode 100644 index 00000000..0d7b882f --- /dev/null +++ b/src/abpdrrt005pg2a5/abpdrrt005pg2a5.hpp @@ -0,0 +1,88 @@ +/* + * Author: Abhishek Malik + * Copyright (c) 2017 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include "abpdrrt005pg2a5.h" + +namespace upm { +/** + * @defgroup abpdrrt005pg2a5 libupm-abpdrrt005pg2a5 + * @ingroup honeywell i2c + */ + +/** + * @library abpdrrt005pg2a5 + * @sensor abpdrrt005pg2a5 + * @comname ABP Honeywell Pressure Sensor + * @type other + * @man Honeywell + * @web https://sensing.honeywell.com/honeywell-sensing-basic-board-mount-pressure-sensors-abp-series-datasheet-323005128-c-en.pdf + * @con i2c + * @kit other + * + * @brief API for the ABP Honeywell Pressure Sensor + * + * This is the UPM Module for the ABPDRRT005PG2A5 Honeywell Pressure + * sensor. This sensor uses an onboard ASIC to output values + * of pressure that are updated at approximately 2 KHz. It is capable + * of detecting pressure in the 0-5 psi range and it has an i2c + * based interface. Temperature calculation using this sensor + * is not recommended as the values are not calibrated. + * + * @image html abpdrrt005pg2a5.jpg + * @snippet abpdrrt005pg2a5.cxx Interesting + */ + + class ABPDRRT005PG2A5 { + + public: + /** + * ABPDRRT005PG2A5 constructor + * + * @param bus i2c bus to be used + * @param devAddress i2c address of the sensor + */ + ABPDRRT005PG2A5(int bus, int devAddress); + /** + * ABPDRRT005PG2A5 destructor + */ + ~ABPDRRT005PG2A5(); + /** + * Get pressure in pounds per square inch + * + * @return pressure in psi + */ + float get_pressure_psi(); + /** + * Get pressure in pascals + * + * @return pressure in pascal + */ + float get_pressure_pascal(); + + private: + abpdrrt005pg2a5_context m_abpdrrt005pg2a5; + }; +} \ No newline at end of file diff --git a/src/abpdrrt005pg2a5/javaupm_abpdrrt005pg2a5.i b/src/abpdrrt005pg2a5/javaupm_abpdrrt005pg2a5.i new file mode 100644 index 00000000..282433d6 --- /dev/null +++ b/src/abpdrrt005pg2a5/javaupm_abpdrrt005pg2a5.i @@ -0,0 +1,20 @@ +%module javaupm_abpdrrt005pg2a5 +%include "../upm.i" +%include "stdint.i" +%include "typemaps.i" + +%{ + #include "abpdrrt005pg2a5.hpp" +%} +%include "abpdrrt005pg2a5.hpp" + +%pragma(java) jniclasscode=%{ + static { + try { + System.loadLibrary("javaupm_abpdrrt005pg2a5"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. \n" + e); + System.exit(1); + } + } +%} diff --git a/src/abpdrrt005pg2a5/jsupm_abpdrrt005pg2a5.i b/src/abpdrrt005pg2a5/jsupm_abpdrrt005pg2a5.i new file mode 100644 index 00000000..c3ce0dfa --- /dev/null +++ b/src/abpdrrt005pg2a5/jsupm_abpdrrt005pg2a5.i @@ -0,0 +1,8 @@ +%module jsupm_abpdrrt005pg2a5 +%include "../upm.i" + +%{ + #include "abpdrrt005pg2a5.hpp" +%} + +%include "abpdrrt005pg2a5.hpp" diff --git a/src/abpdrrt005pg2a5/pyupm_abpdrrt005pg2a5.i b/src/abpdrrt005pg2a5/pyupm_abpdrrt005pg2a5.i new file mode 100644 index 00000000..f830338b --- /dev/null +++ b/src/abpdrrt005pg2a5/pyupm_abpdrrt005pg2a5.i @@ -0,0 +1,11 @@ +// Include doxygen-generated documentation +%include "pyupm_doxy2swig.i" +%module pyupm_abpdrrt005pg2a5 +%include "../upm.i" + +%feature("autodoc", "3"); + +%include "abpdrrt005pg2a5.hpp" +%{ + #include "abpdrrt005pg2a5.hpp" +%}