All modifications that have been made in april 2026 tu compile upm

with latest version of cmake, C++, C,  python3 and last java version. It has
not been possible to reach a successfull compilation with node and cordova.

Most of the modifications are workarouds because the software requires an
heavy revision from a tue dev whom I am not.

 Modifications qui seront validées :
	modifié :         CMakeLists.txt
	modifié :         cmake/modules/FindNode.cmake
	modifié :         cmake/modules/FindNpm.cmake
	modifié :         cmake/modules/OpenCVDetectPython.cmake
	nouveau fichier : cmake/modules/OpenCVDetectPython.oldcmake
	modifié :         include/upm_types.h
	modifié :         src/CMakeLists.txt
	modifié :         src/ehr/ehr.cxx
	supprimé :        src/hp20x/CMakeLists.txt
	supprimé :        src/hp20x/hp20x.cxx
	supprimé :        src/hp20x/hp20x.hpp
	supprimé :        src/hp20x/hp20x.json
This commit is contained in:
2026-04-21 09:55:31 +02:00
parent 23c137467d
commit b4f87037ac
12 changed files with 276 additions and 808 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8.11) cmake_minimum_required (VERSION 4.0)
project (upm) project (upm)
# Before going any further, define build options # Before going any further, define build options
@@ -6,13 +6,13 @@ option (BUILDDOC "Build all doc" OFF)
option (BUILDCPP "Build CPP sensor libraries" ON) option (BUILDCPP "Build CPP sensor libraries" ON)
option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF) option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF)
option (BUILDSWIGPYTHON "Build swig python modules" ON) option (BUILDSWIGPYTHON "Build swig python modules" ON)
option (BUILDSWIGNODE "Build swig node modules" ON) option (BUILDSWIGNODE "Build swig node modules" OFF)
option (BUILDSWIGJAVA "Build swig java modules" OFF) option (BUILDSWIGJAVA "Build swig java modules" ON)
option (BUILDCORDOVA "Build cordova bindings" OFF) option (BUILDCORDOVA "Build cordova bindings" OFF)
option (BUILDEXAMPLES "Build C/C++/JAVA examples" OFF) option (BUILDEXAMPLES "Build C/C++/JAVA examples" ON)
option (NPM "Generate NPM/GYP tarballs" OFF) option (NPM "Generate NPM/GYP tarballs" OFF)
option (BUILDTESTS "Generate check-ups for upm" OFF) option (BUILDTESTS "Generate check-ups for upm" ON)
option (WERROR "Make all warnings into errors." ON) option (WERROR "Make all warnings into errors." OFF)
# Warn if building in source root # Warn if building in source root
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
@@ -189,7 +189,8 @@ endif (BUILDCORDOVA)
# Find swig if any wrapper is enabled # Find swig if any wrapper is enabled
if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA) if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA)
find_package (SWIG 3.0.5 REQUIRED) # find_package (SWIG 3.0.5 REQUIRED)
find_package (SWIG 4.4.1 REQUIRED)
include (${SWIG_USE_FILE}) include (${SWIG_USE_FILE})
endif () endif ()
@@ -202,29 +203,30 @@ if (BUILDSWIGPYTHON OR BUILDTESTS)
include (cmake/modules/OpenCVDetectPython.cmake) include (cmake/modules/OpenCVDetectPython.cmake)
# Fail if building tests but no python interpreter was found # Fail if building tests but no python interpreter was found
if (BUILDTESTS AND NOT PYTHON2INTERP_FOUND) if (BUILDTESTS AND NOT Python3_FOUND)
message(FATAL_ERROR "BUILDTESTS=ON requires the python2 interpreter") message(FATAL_ERROR "BUILDTESTS=ON requires the python2 interpreter")
endif (BUILDTESTS AND NOT PYTHON2INTERP_FOUND) endif (BUILDTESTS AND NOT Python3_FOUND)
# Fail if no LIBS were found # Fail if no LIBS were found
if (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND) #if (NOT PYTHON2LIBS_FOUND AND NOT Python3_FOUND)
if (NOT PYTHON2LIBS_FOUND AND NOT Python_LIBRARIES)
message(FATAL_ERROR "At least one python lib is required") message(FATAL_ERROR "At least one python lib is required")
endif (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND) endif (NOT PYTHON2LIBS_FOUND AND NOT Python_LIBRARIES)
endif (BUILDSWIGPYTHON OR BUILDTESTS) endif (BUILDSWIGPYTHON OR BUILDTESTS)
# Which versions of python were found? # Which versions of python were found?
if (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON) if (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON)
message(STATUS "Building python2 modules with python-${PYTHON2LIBS_VERSION_STRING}") message(STATUS "Building python2 modules with python-${PYTHON2LIBS_VERSION_STRING}")
endif (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON) endif (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON)
if (PYTHON3LIBS_FOUND AND BUILDSWIGPYTHON) if (Python3_FOUND AND BUILDSWIGPYTHON)
message(STATUS "Building python3 modules with python-${PYTHON3LIBS_VERSION_STRING}") message(STATUS "Building python3 modules with python-${Python_VERSION}")
endif (PYTHON3LIBS_FOUND AND BUILDSWIGPYTHON) endif (Python3_FOUND AND BUILDSWIGPYTHON)
# Python2 is currently required for python documentation # Python2 is currently required for python documentation
if (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND) #if (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND)
message(FATAL_ERROR "Failed to find python2 interpreter which is required " # message(FATAL_ERROR "Failed to find python2 interpreter which is required "
"to build python documentation.") # "to build python documentation.")
endif (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND) #endif (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND)
# Set CMAKE_INSTALL_LIBDIR if not defined # Set CMAKE_INSTALL_LIBDIR if not defined
include(GNUInstallDirs) include(GNUInstallDirs)
@@ -261,33 +263,33 @@ set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_
# enable c++11 standards support unconditionally # enable c++11 standards support unconditionally
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_VERSION VERSION_LESS "3.1")
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++23" COMPILER_SUPPORTS_CXX23)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11) if (COMPILER_SUPPORTS_CXX23)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23")
elseif (COMPILER_SUPPORTS_CXX0X) elseif (COMPILER_SUPPORTS_CXX0X)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else() else()
message(FATAL_ERROR "A C++11 compliant compiler is required to build UPM.") message(FATAL_ERROR "A C++23 compliant compiler is required to build UPM.")
endif() endif()
else() else()
# 3.1+ uses this generic method to enable c++11 # 3.1+ uses this generic method to enable c++23
set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD 23)
set (CXX_STANDARD_REQUIRED ON) set (CXX_STANDARD_REQUIRED ON)
set (CXX_EXTENSIONS OFF) set (CXX_EXTENSIONS OFF)
endif() endif()
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_VERSION VERSION_LESS "3.1")
CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11) CHECK_C_COMPILER_FLAG("-std=c23" COMPILER_SUPPORTS_C23)
if (COMPILER_SUPPORTS_C11) if (COMPILER_SUPPORTS_C23)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c23")
else() else()
message(FATAL_ERROR "A C11 compliant C compiler is required to build UPM.") message(FATAL_ERROR "A C23 compliant C compiler is required to build UPM.")
endif() endif()
else() else()
# 3.1+ uses this generic method to enable c11 # 3.1+ uses this generic method to enable c23
set (CMAKE_C_STANDARD 11) set (CMAKE_C_STANDARD 23)
set (C_STANDARD_REQUIRED ON) set (C_STANDARD_REQUIRED ON)
set (C_EXTENSIONS OFF) set (C_EXTENSIONS OFF)
endif() endif()

View File

@@ -92,7 +92,7 @@ if (NODEJS_EXECUTABLE)
mark_as_advanced (NODEJS_EXECUTABLE) mark_as_advanced (NODEJS_EXECUTABLE)
find_package_handle_standard_args (Nodejs find_package_handle_standard_args (Node
REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS
VERSION_VAR NODE_VERSION_STRING) VERSION_VAR NODE_VERSION_STRING)
message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")") message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")")

View File

@@ -64,7 +64,7 @@ else()
endif() endif()
endif () endif ()
find_package_handle_standard_args(NPM find_package_handle_standard_args(Npm
REQUIRED_VARS NPM_EXECUTABLE NPM_DIR REQUIRED_VARS NPM_EXECUTABLE NPM_DIR
VERSION_VAR NPM_VERSION ) VERSION_VAR NPM_VERSION )

View File

@@ -19,36 +19,38 @@
# include_dir (variable): Output of found Python include dir # include_dir (variable): Output of found Python include dir
# include_dir2 (variable): Output of found Python include dir2 # include_dir2 (variable): Output of found Python include dir2
# packages_path (variable): Output of found Python packages path # packages_path (variable): Output of found Python packages path
function(find_python preferred_version min_version library_env include_dir_env function(find_python preferred_version min_version library_env include_dir_env
found executable version_string version_major version_minor found executable version_string version_major version_minor
libs_found libs_version_string libraries library debug_libraries libs_found libs_version_string libraries library debug_libraries
debug_library include_path include_dir include_dir2 packages_path) debug_library include_path include_dir include_dir2 packages_path)
if(NOT ${found}) if(NOT ${found})
if(${executable}) if(${executable})
set(PYTHON_EXECUTABLE "${${executable}}") set(Python3_EXECUTABLE "${${executable}}")
endif() endif()
find_package(PythonInterp "${preferred_version}") find_package(Python3 "${preferred_version}" COMPONENTS Interpreter Development)
if(NOT PYTHONINTERP_FOUND) if(NOT Python3_FOUND)
find_package(PythonInterp "${min_version}") find_package(Python3 "${min_version}")
endif() endif()
if(PYTHONINTERP_FOUND) if(Python3_FOUND)
# Copy outputs # Copy outputs
set(_found ${PYTHONINTERP_FOUND}) set(_found ${Python3_FOUND})
set(_executable ${PYTHON_EXECUTABLE}) set(_executable ${Python3_EXECUTABLE})
set(_version_string ${PYTHON_VERSION_STRING}) set(_version_string ${ython3_VERSION})
set(_version_major ${PYTHON_VERSION_MAJOR}) set(_version_major ${Python3_VERSION_MAJOR})
set(_version_minor ${PYTHON_VERSION_MINOR}) set(_version_minor ${Python3_VERSION_MINOR})
set(_version_patch ${PYTHON_VERSION_PATCH}) set(_version_patch ${Python3_VERSION_PATCH})
# Clear find_host_package side effects # Clear find_host_package side effects
unset(PYTHONINTERP_FOUND) unset(Python3_FOUND)
unset(PYTHON_EXECUTABLE CACHE) unset(Python3_EXECUTABLE CACHE)
unset(PYTHON_VERSION_STRING) unset(Python3_VERSION_STRING)
unset(PYTHON_VERSION_MAJOR) unset(Python3_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR) unset(Python3_VERSION_MINOR)
unset(PYTHON_VERSION_PATCH) unset(Python3_VERSION_PATCH)
endif() endif()
if(_found) if(_found)
@@ -58,42 +60,42 @@ if(NOT ${found})
# not using _version_string here, because it might not conform to the CMake version format # not using _version_string here, because it might not conform to the CMake version format
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
# builder version can differ from target, matching base version (e.g. 2.7) # builder version can differ from target, matching base version (e.g. 2.7)
find_package(PythonLibs "${_version_major_minor}") find_package(Python "${_version_major_minor}" COMPONENTS Interpreter Development)
else() else()
find_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT) find_package(Python "${_version_major_minor}.${_version_patch}" EXACT COMPONENTS Interpreter Development)
endif() endif()
if(PYTHONLIBS_FOUND) if(Python_FOUND)
# Copy outputs # Copy outputs
set(_libs_found ${PYTHONLIBS_FOUND}) set(_libs_found ${Python_Development_FOUND})
set(_libraries ${PYTHON_LIBRARIES}) set(_libraries ${Python_LIBRARIES})
set(_include_path ${PYTHON_INCLUDE_PATH}) set(_include_path ${Python_INCLUDE_DIR})
set(_include_dirs ${PYTHON_INCLUDE_DIRS}) set(_include_dirs ${Python_INCLUDE_DIRS})
set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES}) set(_debug_libraries ${Python_LIBRARIES})
set(_libs_version_string ${PYTHONLIBS_VERSION_STRING}) set(_libs_version_string ${Python_VERSION})
set(_debug_library ${PYTHON_DEBUG_LIBRARY}) set(_debug_library ${Python_LIBRARY})
set(_library ${PYTHON_LIBRARY}) set(_library ${Python_LIBRARY})
set(_library_debug ${PYTHON_LIBRARY_DEBUG}) set(_library_debug ${Python_LIBRARY})
set(_library_release ${PYTHON_LIBRARY_RELEASE}) set(_library_release ${Python_LIBRARY})
set(_include_dir ${PYTHON_INCLUDE_DIR}) set(_include_dir ${Python_INCLUDE_DIR})
set(_include_dir2 ${PYTHON_INCLUDE_DIR2}) set(_include_dir2 ${Python_INCLUDE_DIR2})
# Clear find_package side effects # Clear find_package side effects
unset(PYTHONLIBS_FOUND) unset(Python_Development_FOUND)
unset(PYTHON_LIBRARIES) unset(Python_LIBRARIES)
unset(PYTHON_INCLUDE_PATH) unset(Python_INCLUDE_DIR)
unset(PYTHON_INCLUDE_DIRS) unset(Python_INCLUDE_DIRS)
unset(PYTHON_DEBUG_LIBRARIES) unset(Python_LIBRARIES)
unset(PYTHONLIBS_VERSION_STRING) unset(Python_VERSION)
unset(PYTHON_DEBUG_LIBRARY CACHE) unset(Python_LIBRARY CACHE)
unset(PYTHON_LIBRARY) unset(Python_LIBRARY)
unset(PYTHON_LIBRARY_DEBUG) unset(Python_LIBRARY_DEBUG)
unset(PYTHON_LIBRARY_RELEASE) unset(Python_LIBRARY_RELEASE)
unset(PYTHON_LIBRARY CACHE) unset(Python_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE) unset(Python_LIBRARY CACHE)
unset(PYTHON_LIBRARY_RELEASE CACHE) unset(Python_LIBRARY CACHE)
unset(PYTHON_INCLUDE_DIR CACHE) unset(Python_INCLUDE_DIR CACHE)
unset(PYTHON_INCLUDE_DIR2 CACHE) unset(Python_INCLUDE_DIR2 CACHE)
endif() endif()
endif() endif()
@@ -135,26 +137,26 @@ endfunction(find_python)
set(MIN_VER_PYTHON2 2.7) set(MIN_VER_PYTHON2 2.7)
set(MIN_VER_PYTHON3 3.2) set(MIN_VER_PYTHON3 3.2)
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR #find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING # Python3_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND # PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY # PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH # PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH) # PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH)
find_python(3 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR find_python(3 "${MIN_VER_PYTHON3}" Python_LIBRARY Python_INCLUDE_DIR
PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING Python3_FOUND Python3_EXECUTABLE Python3_VERSION
PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND Python3_VERSION_MAJOR Python3_VERSION_MINOR PYTHON3LIBS_FOUND
PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY Python_VERSION Python_LIBRARIES Python_LIBRARY
PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG Python_INCLUDE_DIR
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH) Python_INCLUDE_DIR Python_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH)
if(PYTHON_DEFAULT_EXECUTABLE) if(PYTHON_DEFAULT_EXECUTABLE)
set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_AVAILABLE "TRUE")
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter elseif(Python3_FOUND) # Use Python 2 as default Python interpreter
set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}") set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
elseif(PYTHON3INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 2) elseif(Python3_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 2)
set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}") set(PYTHON_DEFAULT_EXECUTABLE "${Python3_EXECUTABLE}")
endif() endif()

View File

@@ -0,0 +1,160 @@
# Find specified Python version
# Arguments:
# preferred_version (value): Version to check for first
# min_version (value): Minimum supported version
# library_env (value): Name of Python library ENV variable to check
# include_dir_env (value): Name of Python include directory ENV variable to check
# found (variable): Set if interpreter found
# executable (variable): Output of executable found
# version_string (variable): Output of found version
# version_major (variable): Output of found major version
# version_minor (variable): Output of found minor version
# libs_found (variable): Set if libs found
# libs_version_string (variable): Output of found libs version
# libraries (variable): Output of found Python libraries
# library (variable): Output of found Python library
# debug_libraries (variable): Output of found Python debug libraries
# debug_library (variable): Output of found Python debug library
# include_path (variable): Output of found Python include path
# include_dir (variable): Output of found Python include dir
# include_dir2 (variable): Output of found Python include dir2
# packages_path (variable): Output of found Python packages path
function(find_python preferred_version min_version library_env include_dir_env
found executable version_string version_major version_minor
libs_found libs_version_string libraries library debug_libraries
debug_library include_path include_dir include_dir2 packages_path)
if(NOT ${found})
if(${executable})
set(PYTHON_EXECUTABLE "${${executable}}")
endif()
find_package(PythonInterp "${preferred_version}")
if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp "${min_version}")
endif()
if(PYTHONINTERP_FOUND)
# Copy outputs
set(_found ${PYTHONINTERP_FOUND})
set(_executable ${PYTHON_EXECUTABLE})
set(_version_string ${PYTHON_VERSION_STRING})
set(_version_major ${PYTHON_VERSION_MAJOR})
set(_version_minor ${PYTHON_VERSION_MINOR})
set(_version_patch ${PYTHON_VERSION_PATCH})
# Clear find_host_package side effects
unset(PYTHONINTERP_FOUND)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_VERSION_STRING)
unset(PYTHON_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR)
unset(PYTHON_VERSION_PATCH)
endif()
if(_found)
set(_version_major_minor "${_version_major}.${_version_minor}")
if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
# not using _version_string here, because it might not conform to the CMake version format
if(CMAKE_CROSSCOMPILING)
# builder version can differ from target, matching base version (e.g. 2.7)
find_package(PythonLibs "${_version_major_minor}")
else()
find_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT)
endif()
if(PYTHONLIBS_FOUND)
# Copy outputs
set(_libs_found ${PYTHONLIBS_FOUND})
set(_libraries ${PYTHON_LIBRARIES})
set(_include_path ${PYTHON_INCLUDE_PATH})
set(_include_dirs ${PYTHON_INCLUDE_DIRS})
set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES})
set(_libs_version_string ${PYTHONLIBS_VERSION_STRING})
set(_debug_library ${PYTHON_DEBUG_LIBRARY})
set(_library ${PYTHON_LIBRARY})
set(_library_debug ${PYTHON_LIBRARY_DEBUG})
set(_library_release ${PYTHON_LIBRARY_RELEASE})
set(_include_dir ${PYTHON_INCLUDE_DIR})
set(_include_dir2 ${PYTHON_INCLUDE_DIR2})
# Clear find_package side effects
unset(PYTHONLIBS_FOUND)
unset(PYTHON_LIBRARIES)
unset(PYTHON_INCLUDE_PATH)
unset(PYTHON_INCLUDE_DIRS)
unset(PYTHON_DEBUG_LIBRARIES)
unset(PYTHONLIBS_VERSION_STRING)
unset(PYTHON_DEBUG_LIBRARY CACHE)
unset(PYTHON_LIBRARY)
unset(PYTHON_LIBRARY_DEBUG)
unset(PYTHON_LIBRARY_RELEASE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
unset(PYTHON_LIBRARY_RELEASE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_INCLUDE_DIR2 CACHE)
endif()
endif()
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
RESULT_VARIABLE _cvpy_process
OUTPUT_VARIABLE _std_packages_path
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${_std_packages_path}" MATCHES "site-packages")
set(_packages_path "python${_version_major_minor}/site-packages")
else() #debian based assumed, install to the dist-packages.
set(_packages_path "python${_version_major_minor}/dist-packages")
endif()
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}")
set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}")
else()
set(_packages_path "lib/${_packages_path}")
endif()
endif()
# Export return values
set(${found} "${_found}" CACHE INTERNAL "")
set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor")
set(${version_string} "${_version_string}" CACHE INTERNAL "")
set(${version_major} "${_version_major}" CACHE INTERNAL "")
set(${version_minor} "${_version_minor}" CACHE INTERNAL "")
set(${libs_found} "${_libs_found}" CACHE INTERNAL "")
set(${libs_version_string} "${_libs_version_string}" CACHE INTERNAL "")
set(${libraries} "${_libraries}" CACHE INTERNAL "Python libraries")
set(${library} "${_library}" CACHE FILEPATH "Path to Python library")
set(${debug_libraries} "${_debug_libraries}" CACHE INTERNAL "")
set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug")
set(${include_path} "${_include_path}" CACHE INTERNAL "")
set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir")
set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2")
set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.")
endif()
endfunction(find_python)
set(MIN_VER_PYTHON2 2.7)
set(MIN_VER_PYTHON3 3.2)
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH)
find_python(3 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND
PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY
PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH)
if(PYTHON_DEFAULT_EXECUTABLE)
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
elseif(PYTHON3INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 2)
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
endif()

View File

@@ -19,10 +19,7 @@ extern "C" {
#include <stdbool.h> #include <stdbool.h>
#elif __cplusplus #elif __cplusplus
#else #else
typedef enum { typedef enum {TRUE =1 , FALSE = 0} boolean;
false = 0,
true = 1
} bool;
#endif #endif
typedef enum { typedef enum {

View File

@@ -210,7 +210,7 @@ function (_print_target_summary)
endfunction (_print_target_summary) endfunction (_print_target_summary)
function (_get_target_dependency_interface_include_dirs target varIncludeDirs) function (_get_target_dependency_interface_include_dirs target varIncludeDirs)
set (${varIncludeDirs} "") set (${varIncludeDirs} "/usr/include/python3.13")
# For each LINK_LIBRARIES of target # For each LINK_LIBRARIES of target
get_property(_targets TARGET ${target} PROPERTY LINK_LIBRARIES) get_property(_targets TARGET ${target} PROPERTY LINK_LIBRARIES)
@@ -323,7 +323,7 @@ macro(_upm_swig_python)
# Set current python binary dir # Set current python binary dir
set (CMAKE_CURRENT_PYTHON_BINARY_DIR set (CMAKE_CURRENT_PYTHON_BINARY_DIR
${CMAKE_CURRENT_BINARY_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) ${CMAKE_CURRENT_BINARY_DIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
# Make sure swig places wrapper/.py collateral under python2/3 directory # Make sure swig places wrapper/.py collateral under python2/3 directory
# Save the original BINARY_DIR, set a new BINARY_DIR, then restore at # Save the original BINARY_DIR, set a new BINARY_DIR, then restore at
@@ -333,7 +333,7 @@ macro(_upm_swig_python)
set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_PYTHON_BINARY_DIR}) set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_PYTHON_BINARY_DIR})
# Swig module name (example: pyupm_a110x-python2) # Swig module name (example: pyupm_a110x-python2)
set (python_wrapper_name pyupm_${libname}-python${PYTHON_VERSION_MAJOR}) set (python_wrapper_name pyupm_${libname}-python${Python3_VERSION_MAJOR})
if (CMAKE_VERSION VERSION_LESS "3.8") if (CMAKE_VERSION VERSION_LESS "3.8")
swig_add_module (${python_wrapper_name} python ${SWIG_CURRENT_DOT_I_FILE}) swig_add_module (${python_wrapper_name} python ${SWIG_CURRENT_DOT_I_FILE})
else () else ()
@@ -343,7 +343,9 @@ macro(_upm_swig_python)
set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME}) set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME})
if(module_iface) if(module_iface)
add_dependencies(${python_wrapper_target} _pyupm_interfaces-python${PYTHON_VERSION_MAJOR}) #message(STATUS "python version major : " ${Python3_VERSION_MAJOR})
#add_dependencies(${python_wrapper_target} _pyupm_interfaces-python${Python3_VERSION_MAJOR})
add_dependencies(${python_wrapper_target} pyupm_interfaces-python${Python3_VERSION_MAJOR})
endif() endif()
add_dependencies(${python_wrapper_target} ${libname}) add_dependencies(${python_wrapper_target} ${libname})
@@ -381,12 +383,12 @@ macro(_upm_swig_python)
# Install .py's to python packages directory/upm # Install .py's to python packages directory/upm
install (FILES ${swig_extra_generated_files} install (FILES ${swig_extra_generated_files}
DESTINATION ${PYTHON_PACKAGES_PATH}/upm DESTINATION ${PYTHON_PACKAGES_PATH}/upm
COMPONENT ${CMAKE_PROJECT_NAME}-python${PYTHON_VERSION_MAJOR}) COMPONENT ${CMAKE_PROJECT_NAME}-python${Python3_VERSION_MAJOR})
# Install python wrapper module library # Install python wrapper module library
install (TARGETS ${python_wrapper_target} install (TARGETS ${python_wrapper_target}
DESTINATION ${PYTHON_PACKAGES_PATH}/upm DESTINATION ${PYTHON_PACKAGES_PATH}/upm
COMPONENT ${CMAKE_PROJECT_NAME}-python${PYTHON_VERSION_MAJOR}) COMPONENT ${CMAKE_PROJECT_NAME}-python${Python3_VERSION_MAJOR})
# Restore CMAKE_CURRENT_BINARY_DIR # Restore CMAKE_CURRENT_BINARY_DIR
set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR_SAVED}) set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR_SAVED})
@@ -412,19 +414,19 @@ function(upm_swig_python)
endif (PYTHON2LIBS_FOUND) endif (PYTHON2LIBS_FOUND)
# Generate python3 module if python3 libs are available # Generate python3 module if python3 libs are available
if (PYTHON3LIBS_FOUND) if (Python3_FOUND)
set(PYTHON_INCLUDE_DIRS ${PYTHON3_INCLUDE_DIRS}) set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
set(PYTHON_INCLUDE_PATH ${PYTHON3_INCLUDE_PATH}) set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIR})
set(PYTHON_LIBRARIES ${PYTHON3_LIBRARIES}) set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_VERSION_MAJOR ${PYTHON3_VERSION_MAJOR}) set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${PYTHON3_VERSION_MINOR}) set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
set(PYTHON_PACKAGES_PATH ${PYTHON3_PACKAGES_PATH}) set(PYTHON_PACKAGES_PATH ${Python3_PACKAGES_PATH})
_upm_swig_python() _upm_swig_python()
# Keep track of all Python3 targets # Keep track of all Python3 targets
set(UPM_TARGETS_PYTHON3 ${UPM_TARGETS_PYTHON3} ${python_wrapper_target} set(UPM_TARGETS_PYTHON3 ${UPM_TARGETS_PYTHON3} ${python_wrapper_target}
CACHE INTERNAL "List of Python target names") CACHE INTERNAL "List of Python target names")
endif (PYTHON3LIBS_FOUND) endif (Python3_FOUND)
endif (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};") endif (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};")
endfunction(upm_swig_python) endfunction(upm_swig_python)

View File

@@ -114,7 +114,7 @@ uint32_t EHR::beatCounter()
void EHR::beatISR(void *ctx) void EHR::beatISR(void *ctx)
{ {
upm::EHR *This = (upm::EHR *)ctx; upm::EHR *This = (upm::EHR *)ctx;
This->m_beatCounter++; This->m_beatCounter = This->m_beatCounter + 1;
} }
int EHR::heartRate() int EHR::heartRate()

View File

@@ -1,6 +0,0 @@
set (libname "hp20x")
set (libdescription "High-accuracy Barometer")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iPressure.hpp iTemperature.hpp)
upm_module_init(mraa)

View File

@@ -1,275 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#include <unistd.h>
#include <math.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include "hp20x.hpp"
using namespace upm;
using namespace std;
HP20X::HP20X(int bus, uint8_t address):
m_i2c(bus)
{
m_addr = address;
mraa::Result rv;
if ( (rv = m_i2c.address(m_addr)) != mraa::SUCCESS)
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.address() failed");
return;
}
}
HP20X::~HP20X()
{
}
bool HP20X::init(DSR_BITS_T dsr)
{
// wait for the device to report ready
waitforDeviceReady();
m_dsr = dsr;
// enable compensation? Datasheet says yes, but a register readback
// says no. Data does seem stable, so....
compensationEnable(true);
return true;
}
bool HP20X::isReady()
{
uint8_t intsrc = readReg(REG_INT_SRC);
if (intsrc & INT_SRC_DEV_RDY)
return true;
return false;
}
bool HP20X::waitforDeviceReady()
{
const int maxRetries = 20;
int retries = 0;
while (retries < maxRetries)
{
if (isReady())
return true;
usleep(20000);
retries++;
}
throw std::runtime_error(std::string(__FUNCTION__) +
": timeout waiting for device to become ready");
return false;
}
bool HP20X::writeCmd(uint8_t cmd)
{
mraa::Result rv;
if ((rv = m_i2c.writeByte(cmd)) != mraa::SUCCESS)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.writeByte() failed");
return false;
}
return true;
}
bool HP20X::writeReg(HP20X_REG_T reg, uint8_t data)
{
waitforDeviceReady();
uint8_t r = CMD_WRITE_REG | reg;
mraa::Result rv;
if ((rv = m_i2c.writeReg(r, data)) != mraa::SUCCESS)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.writeReg() failed");
return false;
}
return true;
}
uint8_t HP20X::readReg(HP20X_REG_T reg)
{
uint8_t r = CMD_READ_REG | reg;
return m_i2c.readReg(r);
}
int HP20X::readData()
{
uint8_t buf[3] = {0};
if (!m_i2c.read(buf, 3))
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.read() failed");
return 0;
}
// handle 24bit sign extension
int minus = 1;
if (buf[0] & 0x80)
{
// negative
buf[0] &= 0x3f;
minus = -1;
}
return ( minus * ((buf[0] << 16) | (buf[1] << 8) | buf[2]) );
}
float HP20X::getTemperature()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, T only
uint8_t cmd = CMD_ADC_CVT | (CHNL_T << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the temperature
writeCmd(CMD_READ_T);
return ((float)readData() / 100.0);
}
float HP20X::getPressure()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, PT only
uint8_t cmd = CMD_ADC_CVT | (CHNL_PT << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the pressure
writeCmd(CMD_READ_P);
// Return result in Pa, not milibars.
return (float)readData();
}
float HP20X::getAltitude()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, PT only
uint8_t cmd = CMD_ADC_CVT | (CHNL_PT << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the pressure
writeCmd(CMD_READ_A);
return ((float)readData() / 100.0);
}
void HP20X::compensationEnable(bool enable)
{
if (enable)
writeReg(REG_PARA, PARA_CMPS_EN);
else
writeReg(REG_PARA, 0);
}
bool HP20X::setInterruptEnable(uint8_t bits)
{
return writeReg(REG_INT_EN, bits);
}
bool HP20X::setInterruptConfig(uint8_t bits)
{
return writeReg(REG_INT_CFG, bits);
}
uint8_t HP20X::getInterruptSource()
{
return readReg(REG_INT_SRC);
}
void HP20X::setDSR(DSR_BITS_T dsr)
{
m_dsr = dsr;
}
void HP20X::recalibrateInternal()
{
waitforDeviceReady();
writeCmd(CMD_ANA_CAL);
}
void HP20X::softReset()
{
waitforDeviceReady();
writeCmd(CMD_SOFT_RST);
waitforDeviceReady();
}
void HP20X::setAltitudeOffset(int16_t off)
{
writeReg(REG_ALT_OFF_LSB, (off & 0xff));
writeReg(REG_ALT_OFF_MSB, ((off >> 8) & 0xff));
}
void HP20X::setPAThreshholds(int16_t low, int16_t med, int16_t high)
{
// low
writeReg(REG_PA_L_TH_LSB, (low & 0xff));
writeReg(REG_PA_L_TH_MSB, ((low >> 8) & 0xff));
// medium
writeReg(REG_PA_M_TH_LSB, (med & 0xff));
writeReg(REG_PA_M_TH_MSB, ((med >> 8) & 0xff));
// high
writeReg(REG_PA_H_TH_LSB, (high & 0xff));
writeReg(REG_PA_H_TH_MSB, ((high >> 8) & 0xff));
}
void HP20X::setTemperatureThreshholds(int8_t low, int8_t med, int8_t high)
{
// low
writeReg(REG_T_L_TH, low);
// medium
writeReg(REG_T_M_TH, med);
// high
writeReg(REG_T_H_TH, high);
}

View File

@@ -1,374 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <string>
#include <mraa/common.hpp>
#include <mraa/i2c.hpp>
#include <interfaces/iPressure.hpp>
#include <interfaces/iTemperature.hpp>
#define HP20X_I2C_BUS 0
#define HP20X_DEFAULT_I2C_ADDR 0x76
namespace upm {
/**
* @brief HP20X I2C Barometer (High-Accuracy)
* @defgroup hp20x libupm-hp20x
* @ingroup seeed i2c pressure
*/
/**
* @library hp20x
* @sensor hp20x
* @comname High-accuracy Barometer
* @altname HP20X Barometer (High-Accuracy)
* @type pressure
* @man seeed
* @web http://www.seeedstudio.com/depot/Grove-Barometer-HighAccuracy-p-1865.html
* @con i2c
*
* @brief API for the HP20X-based Grove Barometer (High-Accuracy)
*
* This is a high-accuracy barometer providing pressure, altitude,
* and temperature data. It can be calibrated for a given altitude
* offset, and a wide range of interrupt generating capabilities are
* supported. As usual, see the HP20X datasheet for more details.
*
* This module was developed using a Grove Barometer (High-Accuracy)
* based on an HP206C chip.
*
* @image html hp20x.jpg
* @snippet hp20x.cxx Interesting
*/
class HP20X : virtual public iPressure, virtual public iTemperature {
public:
/**
* HP20X commands
*/
typedef enum {
CMD_SOFT_RST = 0x06,
CMD_ADC_CVT = 0x40, // mask - ANDed with DSR and CHNL bits
CMD_READ_PT = 0x10, // read pressure/temp
CMD_READ_AT = 0x11, // read alt/temp
CMD_READ_P = 0x30, // read pressure only
CMD_READ_A = 0x31, // read alt only
CMD_READ_T = 0x32, // read temp only
CMD_ANA_CAL = 0x28, // recalibrate internal analog blocks
CMD_READ_REG = 0x80, // mask - ANDed with reg addr
CMD_WRITE_REG = 0xc0 // mask - ANDed with reg addr
} HP20X_CMD_T;
/**
* CHNL bits
*/
typedef enum {
CHNL_PT = 0x00, // pressure and temperature
CHNL_T = 0x02, // temperature
CHNL_SHIFT = 0 // don't use, indicates position in REG
} CHNL_BITS_T;
/**
* DSR bits
*/
typedef enum {
DSR_4096 = 0x00, // decimation rate of digital filter
DSR_2048 = 0x01,
DSR_1024 = 0x02,
DSR_512 = 0x03,
DSR_256 = 0x04,
DSR_128 = 0x05,
DSR_SHIFT = 2 // don't use, indicates position in REG
} DSR_BITS_T;
/**
* HP20X registers
*/
typedef enum {
REG_ALT_OFF_LSB = 0x00,
REG_ALT_OFF_MSB = 0x01,
REG_PA_H_TH_LSB = 0x02, // Pres/Alt high threshold
REG_PA_H_TH_MSB = 0x03,
REG_PA_M_TH_LSB = 0x04, // Pres/Alt medium threshold
REG_PA_M_TH_MSB = 0x05,
REG_PA_L_TH_LSB = 0x06, // Pres/Alt low threshold
REG_PA_L_TH_MSB = 0x07,
REG_T_H_TH = 0x08, // temperature high threshold
REG_T_M_TH = 0x09,
REG_T_L_TH = 0x0a,
REG_INT_EN = 0x0b, // interrupt enables
REG_INT_CFG = 0x0c, // interrupt configuration
REG_INT_SRC = 0x0d, // interrupt sources
REG_PARA = 0x0e // parameters config
} HP20X_REG_T;
/**
* INT_EN bits
*/
typedef enum {
INT_EN_T_WIN_EN = 0x01,
INT_EN_PA_WIN_EN = 0x02,
INT_EN_T_TRAV_EN = 0x04,
INT_EN_PA_TRAV_EN = 0x08,
INT_EN_T_RDY_EN = 0x10,
INT_EN_PA_RDY_EN = 0x20
// 0x40, 0x80 reserved
} INT_EN_BITS_T;
/**
* INT_CFG bits
*/
typedef enum {
INT_CFG_T_WIN_CFG = 0x01,
INT_CFG_PA_WIN_CFG = 0x02,
INT_CFG_T_TRAV_CFG = 0x04,
INT_CFG_PA_TRAV_CFG = 0x08,
INT_CFG_T_RDY_CFG = 0x10,
INT_CFG_PA_RDY_CFG = 0x20,
INT_CFG_PA_MODE = 0x40
// 0x80 reserved
} INT_CFG_BITS_T;
/**
* INT_SRC bits
*/
typedef enum {
INT_SRC_T_WIN = 0x01,
INT_SRC_PA_WIN = 0x02,
INT_SRC_T_TRAV = 0x04,
INT_SRC_PA_TRAV = 0x08,
INT_SRC_T_RDY = 0x10,
INT_SRC_PA_RDY = 0x20,
INT_SRC_DEV_RDY = 0x40, // device is ready
INT_SRC_TH_ERR = 0x80 // threshold error
} INT_SRC_BITS_T;
/**
* PARA bits
*/
typedef enum {
// 0x01-0x40 reserved
PARA_CMPS_EN = 0x80 // compensation enable
} PARA_BITS_T;
/**
* HP20X constructor
*
* @param bus I2C bus to use
* @param address Address for this device
*/
HP20X(int bus=HP20X_I2C_BUS, uint8_t address=HP20X_DEFAULT_I2C_ADDR);
/**
* HP20X destructor
*/
~HP20X();
/**
* Sets up initial values and starts operation
*
* @param dsr Data sampling rate; one of the DSR_BITS_T values
* @return True if successful
*/
bool init(DSR_BITS_T dsr=DSR_4096);
/**
* Sends a command to the device
*
* @param cmd Command to send; usually, one of the HP20X_CMD_T values
* @return True if successful
*/
bool writeCmd(uint8_t cmd);
/**
* Writes a value to a register
*
* @param reg Register to write to; one of the HP20X_REG_T values
* @param data Value to write
* @return True if successful
*/
bool writeReg(HP20X_REG_T reg, uint8_t data);
/**
* Reads a register and returns its value
*
* @param reg Register to read; one of the HP20X_REG_T values
* @return Value of a specified register
*/
uint8_t readReg(HP20X_REG_T reg);
/**
* Reads 3 bytes of data in response to a conversion request, and
* converts it to an integer
*
* @return Value read back (temperature, pressure, etc.)
*/
int readData();
/**
* Checks to see if the DR_RDY bit is set, indicating the device
* can accept commands
*
* @return True if the device is ready, false otherwise
*/
bool isReady();
/**
* Checks to see if the device is ready, and sleeps/retries if not.
* Returns once the device indicates it's ready.
*
* @return True if the device is ready; false if retries are exhausted
*/
bool waitforDeviceReady();
/**
* Returns the temperature in Celsius
*
* @return Temperature
*/
virtual float getTemperature();
/**
* Returns the pressure in pascal
*
* @return Pressure
*/
virtual float getPressure();
/**
* Returns the computed altitude in meters
*
* @return Altitude
*/
float getAltitude();
/**
* Enables or disables the on-chip compensator. This allows the
* chip to filter and clean up the output data.
*
* @param enable True to enable, false otherwise
*/
void compensationEnable(bool enable);
/**
* Sets up the interrupt enable register. This register defines
* which events can cause a hardware interrupt pin to be pulled high
* (active).
*
* @param bits One or more of the INT_EN_BITS_T bits
* @return True if successful, false otherwise
*/
bool setInterruptEnable(uint8_t bits);
/**
* Sets up the interrupt configuration register. This register
* defines which events can cause an interrupt to be indicated.
*
* @param bits One or more of the INT_EN_BITS_T bits
* @return True if successful, false otherwise
*/
bool setInterruptConfig(uint8_t bits);
/**
* Gets the interrupt source register. This register indicates
* which interrupts have been triggered. In addition, it
* indicates when certain operations have been completed.
*
* @return One of more of the INT_SRC_BITS_T values
*/
uint8_t getInterruptSource();
/**
* Sets the data sampling rate. Higher rates are more precise, but
* take more time per measurement.
*
* @param dsr One of the DSR_BITS_T values
*/
void setDSR(DSR_BITS_T dsr);
/**
* Starts an internal recalibration of analog blocks. This is
* faster than a soft reset.
*/
void recalibrateInternal();
/**
* Executes a soft reset. All register values are reset to power-on
* defaults. This function returns when the reset is
* complete and the device reports it is ready.
*/
void softReset();
/**
* Sets the altitude offset for your region. See the datasheet for
* more details. Setting this correctly for your region is
* required for accurate altitude data.
*
* @param off Offset
*/
void setAltitudeOffset(int16_t off);
/**
* Sets pressure/altitude thresholds for interrupt generation
*
* @param low Low threshold to generate an interrupt
* @param med Medium threshold to generate an interrupt
* @param high High threshold to generate an interrupt
*/
void setPAThreshholds(int16_t low, int16_t med, int16_t high);
/**
* Sets temperature thresholds for interrupt generation
*
* @param low Low threshold to generate an interrupt
* @param med Medium threshold to generate an interrupt
* @param high High threshold to generate an interrupt
*/
void setTemperatureThreshholds(int8_t low, int8_t med, int8_t high);
protected:
mraa::I2c m_i2c;
private:
uint8_t m_addr;
uint8_t m_dsr;
};
}

View File

@@ -1,40 +0,0 @@
{
"Library": "hp20x",
"Description": "API for the HP20X-based Grove Barometer (High-Accuracy)",
"Sensor Class":
{
"HP20X":
{
"Name": "HP20X Barometer (High-Accuracy)",
"Description": "This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details. This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.",
"Aliases": ["hp20x"],
"Categories": ["pressure"],
"Connections": ["i2c"],
"Project Type": ["environmental", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "hp20x.jpg",
"Examples":
{
"Java": ["HP20x_Example.java"],
"Python": ["hp20x.py"],
"Node.js": ["hp20x.js"],
"C++": ["hp20x.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5.5},
"Operating Current": {"unit": "mA", "low": 0.635, "high": 1.1},
"Measurement Range": {"unit": "hPa", "low": 300, "high": 1200}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Barometer-HighAccuracy-p-1865.html"],
"Datasheets": ["http://www.seeedstudio.com/wiki/File:HP206C_Datasheet.pdf"],
"Schematics": []
}
}
}
}