Compare commits

..

12 Commits

Author SHA1 Message Date
0050f92b06 lcd: rename from iiclcd to i2clcd, add swig
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-12 14:16:39 +01:00
058c40e340 servo: update to use cmake macro for servo
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-12 11:44:17 +01:00
cea5816c43 upm: new standard for modules cmake file
* Update all previously updated modules

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-12 11:39:10 +01:00
54a4afc6a7 my9221 mma7455: corrected spelling mistake
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 20:50:19 +01:00
1dd8626044 mma7455: added new accelerometer module
Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
2014-06-11 13:21:58 +00:00
1c138d9167 ledbar: rename to my9221
* Use new cmake macro

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 15:11:36 +01:00
3dccffe055 4digitdisplay: rename to tm1637
* Use new cmake macro

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 15:07:21 +01:00
34e343869c upm: update past modules to use new CMake macro
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 15:02:44 +01:00
d71e4e5dc2 cmake: update swig support
* Bumped required CMake Version

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 14:36:56 +01:00
7e3358b586 doc: make docs not generate by default. BUILDDOC
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-11 14:36:56 +01:00
ca0b0cce44 doxygen: added documentation to new public methods
Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
2014-06-10 13:39:02 +00:00
12b2ab6991 max44000: Added swig to the module and set i2c methods as public
Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
2014-06-10 13:34:27 +00:00
57 changed files with 784 additions and 300 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 2.8.11)
project (upm)
find_package (SWIG)
@ -39,22 +39,28 @@ endif()
set (upm_VERSION_MAJOR ${VERSION_MAJOR})
set (upm_VERSION_MINOR ${VERSION_MINOR})
set (upm_VERSION_PATCH ${VERSION_PATCH})
set (upm_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH})
set (CMAKE_SWIG_FLAGS "")
option (IPK "Generate IPK using CPack" OFF)
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
# add a target to generate API documentation with Doxygen
find_package (Doxygen)
if (DOXYGEN_FOUND)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target (doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif (DOXYGEN_FOUND)
if (BUILDDOC)
# add a target to generate API documentation with Doxygen
find_package (Doxygen)
if (DOXYGEN_FOUND)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target (doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif (DOXYGEN_FOUND)
endif()
if (IPK)
include (TargetArch)

View File

@ -13,17 +13,19 @@ add_executable (son-hcsr04 hcsr04.cxx)
add_executable (oled-1308 oled-1308.cxx)
add_executable (oled-1327 oled-1327.cxx)
add_executable (proximity max44000.cxx)
add_executable (accelerometer mma7455.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
include_directories (${PROJECT_SOURCE_DIR}/src/lcd)
include_directories (${PROJECT_SOURCE_DIR}/src/buzzer)
include_directories (${PROJECT_SOURCE_DIR}/src/ledbar)
include_directories (${PROJECT_SOURCE_DIR}/src/4digitdisplay)
include_directories (${PROJECT_SOURCE_DIR}/src/my9221)
include_directories (${PROJECT_SOURCE_DIR}/src/tm1637)
include_directories (${PROJECT_SOURCE_DIR}/src/nrf24l01)
include_directories (${PROJECT_SOURCE_DIR}/src/servo)
include_directories (${PROJECT_SOURCE_DIR}/src/hcsr04)
include_directories (${PROJECT_SOURCE_DIR}/src/max44000)
include_directories (${PROJECT_SOURCE_DIR}/src/mma7455)
target_link_libraries (compass hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled grove ${CMAKE_THREAD_LIBS_INIT})
@ -31,8 +33,8 @@ target_link_libraries (grovetemp grove ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lcm-lcd i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rgb-lcd i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (buzzer-sound buzzer ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (led-bar ledbar ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (seg-lcd 4digitdisplay ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (led-bar my9221 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (seg-lcd tm1637 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf_transmitter nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf_receiver nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (es08a servo ${CMAKE_THREAD_LIBS_INIT})
@ -40,3 +42,4 @@ target_link_libraries (son-hcsr04 hcsr04 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (oled-1308 i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (oled-1327 i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (proximity max44000 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (accelerometer mma7455 ${CMAKE_THREAD_LIBS_INIT})

64
examples/mma7455.cxx Normal file
View File

@ -0,0 +1,64 @@
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 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 <unistd.h>
#include <iostream>
#include "mma7455.h"
#include <signal.h>
#include <pthread.h>
int doWork = 0;
upm::MMA7455 *sensor = NULL;
void
sig_handler(int signo)
{
printf("got signal\n");
if (signo == SIGINT) {
printf("exiting application\n");
doWork = 1;
}
}
int
main(int argc, char **argv)
{
//! [Interesting]
sensor = new upm::MMA7455(0, ADDR);
short x, y, z;
while (!doWork) {
sensor->readData(&x, &y, &z);
std::cout << "Accelerometer X(" << x << ") Y(" << y << ") Z(" << z << ")" << std::endl;
usleep (100000);
}
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
return 0;
}

View File

@ -1,12 +0,0 @@
set (libname "4digitdisplay")
add_library (4digitdisplay SHARED tm1637.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (4digitdisplay ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES tm1637.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm 4 Digit Buzzer")
endif()

View File

@ -8,6 +8,111 @@ macro(subdirlist result curdir)
endforeach()
set(${result} ${dirlist})
endmacro()
macro (upm_CREATE_INSTALL_PKGCONFIG generated_file install_location)
configure_file (${PROJECT_SOURCE_DIR}/src/pkgconfig.in
${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (upm_CREATE_INSTALL_PKGCONFIG)
macro(upm_SWIG_PYTHON)
if(BUILDSWIGPYTHON)
set (CMAKE_C_FLAGS -DSWIGPYTHON=${SWIG_FOUND})
set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON)
swig_add_module (pyupm_${libname} python pyupm_${libname}.i ${module_src})
swig_link_libraries (pyupm_${libname} ${PYTHON_LIBRARIES} ${MAA_LIBRARIES})
target_include_directories ( ${SWIG_MODULE_pyupm_${libname}_REAL_NAME}
PUBLIC
"${PYTHON_INCLUDE_PATH}"
"${PYTHON_INCLUDE_DIRS}"
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_pyupm_${libname}.so
${CMAKE_CURRENT_BINARY_DIR}/pyupm_${libname}.py
DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/
COMPONENT ${libname})
endif()
endmacro()
macro(upm_SWIG_NODE)
if(BUILDSWIGNODE)
set (CMAKE_CXX_FLAGS -DBUILDING_NODE_EXTENSION)
set_source_files_properties (jsupm_${libname}.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (jsupm_${libname}.i PROPERTIES SWIG_FLAGS "-node")
swig_add_module (jsupm_${libname} javascript jsupm_${libname}.i ${module_src})
swig_link_libraries (jsupm_${libname} ${MAA_LIBRARIES} ${NODE_LIBRARIES})
target_include_directories ( ${SWIG_MODULE_jsupm_${libname}_REAL_NAME}
PUBLIC
"${NODE_INCLUDE_DIRS}"
)
set_target_properties (jsupm_${libname} PROPERTIES
PREFIX ""
SUFFIX ".node"
)
createpackagejson(${libname})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}.node
DESTINATION lib/node_modules/jsupm_${libname} COMPONENT ${libname})
endif()
endmacro()
macro(upm_doxygen)
if (DOXYGEN_FOUND)
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
)
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
add_dependencies (${libname}doc_i doc)
add_dependencies (${SWIG_MODULE_pyupm_${libname}_REAL_NAME} ${libname}doc_i)
endif ()
endmacro()
if (SWIG_FOUND)
if(BUILDSWIGPYTHON)
find_package (PythonLibs)
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
endif(BUILDSWIGPYTHON)
if(BUILDSWIGNODE)
find_path (NODE_ROOT_DIR "node/node.h")
set (NODE_INCLUDE_DIRS
${NODE_ROOT_DIR}/src
${NODE_ROOT_DIR}/node
${NODE_ROOT_DIR}/deps/v8/include
${NODE_ROOT_DIR}/deps/uv/include
)
macro(createpackagejson)
configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/package.json
DESTINATION lib/node_modules/jsupm_${libname} COMPONENT ${libname})
endmacro()
endif(BUILDSWIGNODE)
endif()
macro(upm_module_init)
add_library (${libname} SHARED ${module_src})
include_directories (${MAA_INCLUDE_DIR} .)
target_link_libraries (${libname} ${MAA_LIBRARIES})
set_target_properties(${libname} PROPERTIES PREFIX "libupm-")
upm_create_install_pkgconfig (upm-${libname}.pc lib${LIB_SUFFIX}/pkgconfig)
if (SWIG_FOUND)
upm_swig_python()
upm_swig_node()
upm_doxygen()
endif()
install (TARGETS ${libname} DESTINATION lib COMPONENT ${libname})
install (FILES ${module_h} DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "${libdescription}")
endif()
endmacro(upm_module_init)
subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
foreach(subdir ${SUBDIRS})
add_subdirectory(${subdir})

View File

@ -1,12 +1,5 @@
set (libname "buzzer")
add_library (buzzer SHARED buzzer.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (buzzer ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES buzzer.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm buzzer")
endif()
set (libdescription "upm buzzer")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -1,47 +1,5 @@
set (libname "grove")
add_library (grove SHARED grove.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (grove ${MAA_LIBRARIES})
if (SWIG_FOUND)
find_package (PythonLibs)
include_directories (
${PYTHON_INCLUDE_PATH}
${PYTHON_INCLUDE_DIRS}
${MAA_INCLUDE_DIR}
.
)
set_source_files_properties (pyupm_grove.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (jsupm_grove.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (jsupm_grove.i PROPERTIES SWIG_FLAGS "-node")
swig_add_module (pyupm_grove python pyupm_grove.i grove.cxx)
# swig_add_module (jsupm_grove javascript jsupm_grove.i grove.cxx)
swig_link_libraries (pyupm_grove ${PYTHON_LIBRARIES} ${MAA_LIBRARIES})
# swig_link_libraries (jsupm_grove ${MAA_LIBRARIES})
if (DOXYGEN_FOUND)
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
)
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
add_dependencies (${libname}doc_i doc)
add_dependencies (${SWIG_MODULE_pyupm_grove_REAL_NAME} ${libname}doc_i)
endif ()
endif ()
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES grove.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm grove libary")
endif()
set (libdescription "upm grove module")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -1,12 +1,5 @@
set (libname "hcsr04")
add_library (hcsr04 SHARED hcsr04.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (hcsr04 ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES hcsr04.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm proximity sensor")
endif()
set (libdescription "upm proximity sensor")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -1,47 +1,5 @@
set (libname "hmc5883l")
add_library (hmc5883l SHARED hmc5883l.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (hmc5883l ${MAA_LIBRARIES})
if (SWIG_FOUND)
find_package (PythonLibs)
include_directories (
${PYTHON_INCLUDE_PATH}
${PYTHON_INCLUDE_DIRS}
${MAA_INCLUDE_DIR}
.
)
set_source_files_properties (pyupm_hmc5883l.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (jsupm_hmc5883l.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (jsupm_hmc5883l.i PROPERTIES SWIG_FLAGS "-node")
swig_add_module (pyupm_hmc5883l python pyupm_hmc5883l.i hmc5883l.cxx)
# swig_add_module (jsupm_hmc5883l javascript jsupm_hmc5883l.i hmc5883l.cxx)
swig_link_libraries (pyupm_hmc5883l ${PYTHON_LIBRARIES} ${MAA_LIBRARIES})
# swig_link_libraries (jsupm_hmc5883l ${MAA_LIBRARIES})
if (DOXYGEN_FOUND)
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
)
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
add_dependencies (${libname}doc_i doc)
add_dependencies (${SWIG_MODULE_pyupm_hmc5883l_REAL_NAME} ${libname}doc_i)
endif ()
endif ()
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES hmc5883l.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm Digital Compass")
endif()
set (libdescription "libupm Digital Compass")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -1,12 +1,5 @@
set (libname "i2clcd")
add_library (i2clcd SHARED iiclcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx ssd1327.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (i2clcd ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES iiclcd.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm lcd")
endif()
set (libdescription "upm lcd/oled displays")
set (module_src i2clcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx ssd1327.cxx)
set (module_h i2clcd.h lcm1602.h jhd1313m1.h ssd1308.h ssd1327.h)
upm_module_init()

View File

@ -25,11 +25,11 @@
#include <iostream>
#include <unistd.h>
#include "iiclcd.h"
#include "i2clcd.h"
using namespace upm;
IICLcd::IICLcd (int bus, int lcdAddress) {
I2CLcd::I2CLcd (int bus, int lcdAddress) {
m_lcd_control_address = lcdAddress;
m_bus = bus;
@ -42,18 +42,18 @@ IICLcd::IICLcd (int bus, int lcdAddress) {
}
maa_result_t
IICLcd::write (int row, int column, std::string msg) {
I2CLcd::write (int row, int column, std::string msg) {
setCursor (row, column);
write (msg);
}
maa_result_t
IICLcd::close() {
I2CLcd::close() {
return maa_i2c_stop(m_i2c_lcd_control);
}
maa_result_t
IICLcd::i2cReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) {
I2CLcd::i2cReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) {
maa_result_t error = MAA_SUCCESS;
uint8_t data[2] = { addr, value };
@ -64,7 +64,7 @@ IICLcd::i2cReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t value)
}
maa_result_t
IICLcd::i2Cmd (maa_i2c_context ctx, uint8_t value) {
I2CLcd::i2Cmd (maa_i2c_context ctx, uint8_t value) {
maa_result_t error = MAA_SUCCESS;
uint8_t data[2] = { LCD_CMD, value };
@ -75,7 +75,7 @@ IICLcd::i2Cmd (maa_i2c_context ctx, uint8_t value) {
}
maa_result_t
IICLcd::i2cData (maa_i2c_context ctx, uint8_t value) {
I2CLcd::i2cData (maa_i2c_context ctx, uint8_t value) {
maa_result_t error = MAA_SUCCESS;
uint8_t data[2] = { LCD_DATA, value };

View File

@ -67,9 +67,9 @@ namespace upm {
#define LCD_RW 0x02 // Read/Write bit
#define LCD_RS 0x01 // Register select bit
class IICLcd {
class I2CLcd {
public:
IICLcd (int bus, int lcdAddress);
I2CLcd (int bus, int lcdAddress);
maa_result_t write (int x, int y, std::string msg);
virtual maa_result_t write (std::string msg) = 0;

View File

@ -29,7 +29,7 @@
using namespace upm;
Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : IICLcd(bus, lcdAddress) {
Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcdAddress) {
maa_result_t error = MAA_SUCCESS;
m_rgb_address = rgbAddress;

View File

@ -24,11 +24,11 @@
#pragma once
#include <string>
#include "iiclcd.h"
#include "i2clcd.h"
namespace upm {
class Jhd1313m1 : public IICLcd {
class Jhd1313m1 : public I2CLcd {
public:
Jhd1313m1 (int bus, int lcdAddress, int rgbAddress);
~Jhd1313m1 ();

21
src/lcd/jsupm_i2clcd.i Normal file
View File

@ -0,0 +1,21 @@
%module jsupm_i2clcd
%include "i2clcd.h"
%{
#include "i2clcd.h"
%}
%include "jhd1313m1.h"
%{
#include "jhd1313m1.h"
%}
%include "lcm1602.h"
%{
#include "lcm1602.h"
%}
%include "ssd1327.h"
%{
#include "ssd1327.h"
%}

View File

@ -1,7 +0,0 @@
%module jsupm_jhd1313m1
%{
#include "jhd1313m1.h"
%}
%include "jhd1313m1.h"

View File

@ -1,7 +0,0 @@
%module jsupm_lcm1602
%{
#include "lcm1602.h"
%}
%include "lcm1602.h"

View File

@ -1,7 +0,0 @@
%module jsupm_ssd1308
%{
#include "ssd1308.h"
%}
%include "ssd1308.h"

View File

@ -1,7 +0,0 @@
%module jsupm_ssd1327
%{
#include "ssd1327.h"
%}
%include "ssd1327.h"

View File

@ -32,7 +32,7 @@
using namespace upm;
Lcm1602::Lcm1602(int bus_in, int addr_in) : IICLcd (bus_in, addr_in) {
Lcm1602::Lcm1602(int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
maa_result_t error = MAA_SUCCESS;
usleep(50000);

View File

@ -28,11 +28,11 @@
#pragma once
#include <string>
#include "iiclcd.h"
#include "i2clcd.h"
namespace upm {
class Lcm1602 : public IICLcd {
class Lcm1602 : public I2CLcd {
public:
/** LCM1602 Constructor.
* Calls MAA initialisation functions.

23
src/lcd/pyupm_i2clcd.i Normal file
View File

@ -0,0 +1,23 @@
%module pyupm_i2clcd
%feature("autodoc", "3");
%include "i2clcd.h"
%{
#include "i2clcd.h"
%}
%include "jhd1313m1.h"
%{
#include "jhd1313m1.h"
%}
%include "lcm1602.h"
%{
#include "lcm1602.h"
%}
%include "ssd1327.h"
%{
#include "ssd1327.h"
%}

View File

@ -1,8 +0,0 @@
%module pyupm_jhd1313m1
%feature("autodoc", "3");
%include "jhd1313m1.h"
%{
#include "jhd1313m1.h"
%}

View File

@ -1,12 +0,0 @@
%module pyupm_lcm1602
%feature("autodoc", "3");
#ifdef DOXYGEN
%include "lcm1602_doc.i"
#endif
%include "lcm1602.h"
%{
#include "lcm1602.h"
%}

View File

@ -1,8 +0,0 @@
%module pyupm_ssd1308
%feature("autodoc", "3");
%include "ssd1308.h"
%{
#include "ssd1308.h"
%}

View File

@ -1,8 +0,0 @@
%module pyupm_ssd1327
%feature("autodoc", "3");
%include "ssd1327.h"
%{
#include "ssd1327.h"
%}

View File

@ -29,7 +29,7 @@
using namespace upm;
SSD1308::SSD1308 (int bus_in, int addr_in) : IICLcd (bus_in, addr_in) {
SSD1308::SSD1308 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
i2Cmd (m_i2c_lcd_control, DISPLAY_CMD_OFF); // display off
printf ("NO_GDB :: DISPLAY_CMD_OFF \n");
usleep (4500);

View File

@ -25,7 +25,7 @@
#pragma once
#include <string>
#include "iiclcd.h"
#include "i2clcd.h"
namespace upm {
@ -145,7 +145,7 @@ typedef enum {
PAGE = 2
} displayAddressingMode;
class SSD1308 : public IICLcd {
class SSD1308 : public I2CLcd {
public:
/** SSD1308 Constructor.
* Calls MAA initialisation functions.

View File

@ -32,7 +32,7 @@ using namespace upm;
#define INIT_SLEEP 50000
#define CMD_SLEEP 10000
SSD1327::SSD1327 (int bus_in, int addr_in) : IICLcd (bus_in, addr_in) {
SSD1327::SSD1327 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
maa_result_t error = MAA_SUCCESS;
usleep (INIT_SLEEP);
i2Cmd (m_i2c_lcd_control, 0xFD); // Unlock OLED driver IC MCU interface from entering command. i.e: Accept commands

View File

@ -25,7 +25,7 @@
#pragma once
#include <string>
#include "iiclcd.h"
#include "i2clcd.h"
namespace upm {
/*
@ -145,7 +145,7 @@ typedef enum {
PAGE = 2
} displayAddressingMode;
class SSD1327 : public IICLcd {
class SSD1327 : public I2CLcd {
public:
/** SSD1308 Constructor.
* Calls MAA initialisation functions.

View File

@ -1,13 +0,0 @@
set (libname "ledbar")
add_library (ledbar SHARED my9221.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (ledbar ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES my9221.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm LEDBAR")
endif()

View File

@ -1,12 +1,5 @@
set (libname "max44000")
add_library (max44000 SHARED max44000.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (max44000 ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES max44000.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm MAX44000")
endif()
set (libdescription "upm MAX44000")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -43,8 +43,8 @@ MAX44000::MAX44000 (int bus, int devAddr) {
fprintf(stderr, "Messed up i2c bus\n");
}
i2cWriteReg (MCR, 0x2C);
i2cWriteReg (TCR, 0x6);
// i2cWriteReg (MCR, 0x2C);
// i2cWriteReg (TCR, 0x6);
}
MAX44000::~MAX44000() {

View File

@ -29,12 +29,23 @@
#define ADDR 0x4A // device address
// registers address
#define ALSDATA_HIGH 0x04 // ambient sensor data high byte
#define ALSDATA_LOW 0x05 // ambient sensor data low byte
#define PRXDATA 0x15 // proximity sensor data
#define ISR 0x00 // Interrupt Status Register
#define MCR 0x01 // Main Configuration Register
#define RCR 0x02 // Receive Configuration Register
#define TCR 0x03 // Transmit Configuration Register
#define ALSDATA_HIGH 0x04 // ambient sensor data high byte
#define ALSDATA_LOW 0x05 // ambient sensor data low byte
#define PRXDATA 0x15 // proximity sensor data
#define ALS_UP_THRESH_HIGH 0x06 // ALS Interrupt Threshold Registers High
#define ALS_UP_THRESH_LOW 0x07 // ALS Interrupt Threshold Registers LOW
#define ALS_LO_THRESH_HIGH 0x08 // ALS Interrupt Threshold Registers High
#define ALS_LO_THRESH_LOW 0x09 // ALS Interrupt Threshold Registers Low
#define TPTR 0x0A // ALS/PROX Threshold Persist Timer Register
#define PROX_THRESH_IND 0x0B // Proximity Threshold Register
#define PROX_THRESH 0x0C // Proximity Threshold Register
#define TRIM_GAIN_GREEN 0x0F // Digital Gain Trim Register
#define TRIM_GAIN_IR 0x10 // Digital Gain Trim Register
#define HIGH 1
#define LOW 0
@ -90,14 +101,30 @@ class MAX44000 {
{
return m_name;
}
private:
uint16_t getALSData ();
uint16_t getPRXData ();
/**
* Read one byte register
*
* @param reg address of a register
*/
uint8_t i2cReadReg_8 (int reg);
/**
* Read two bytes register
*
* @param reg address of a register
*/
uint16_t i2cReadReg_16 (int reg);
/**
* Write to one byte register
*
* @param reg address of a register
* @param value byte to be written
*/
maa_result_t i2cWriteReg (uint8_t reg, uint8_t value);
private:
std::string m_name;
int m_maxControlAddr;

View File

@ -1,5 +1,7 @@
%module pyupm_max44000
%include "stdint.i"
%feature("autodoc", "3");
%include "max44000.h"

View File

@ -0,0 +1,5 @@
set (libname "mma7455")
set (libdescription "upm MMA7455")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -0,0 +1,7 @@
%module jsupm_mma7455
%{
#include "mma7455.h"
%}
%include "mma7455.h"

176
src/mma7455/mma7455.cxx Normal file
View File

@ -0,0 +1,176 @@
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 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 <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <math.h>
#include "mma7455.h"
using namespace upm;
MMA7455::MMA7455 (int bus, int devAddr) {
unsigned char data = 0;
int nBytes = 0;
m_name = "MMA7455";
m_controlAddr = devAddr;
m_bus = bus;
m_i2ControlCtx = maa_i2c_init(m_bus);
maa_result_t error = maa_i2c_address(m_i2ControlCtx, m_controlAddr);
if (error != MAA_SUCCESS) {
fprintf(stderr, "Messed up i2c bus\n");
return;
}
// setting GLVL 0x1 (64LSB/g) and MODE 0x1 (Measurement Mode)
data = (BIT (MMA7455_GLVL0) | BIT (MMA7455_MODE0));
error = ic2WriteReg (MMA7455_MCTL, &data, 0x1);
if (error != MAA_SUCCESS) {
std::cout << "ERROR :: MMA7455 instance wan not created (Mode)" << std::endl;
return;
}
if (MAA_SUCCESS != calibrate ()) {
std::cout << "ERROR :: MMA7455 instance wan not created (Calibrate)" << std::endl;
return;
}
}
MMA7455::~MMA7455() {
maa_i2c_stop(m_i2ControlCtx);
}
maa_result_t
MMA7455::calibrate () {
maa_result_t error = MAA_SUCCESS;
int i = 0;
accelData xyz;
xyz.value.x = xyz.value.y = xyz.value.z = 0;
do {
error = readData (&xyz.value.x, &xyz.value.y, &xyz.value.z);
if (MAA_SUCCESS != error) {
return error;
}
xyz.value.x += 2 * -xyz.value.x;
xyz.value.y += 2 * -xyz.value.y;
xyz.value.z += 2 * -(xyz.value.z - 64);
error = ic2WriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
if (error != MAA_SUCCESS) {
return error;
}
} while ( ++i < 3 );
return error;
}
maa_result_t
MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
accelData xyz;
unsigned char data = 0;
int nBytes = 0;
/*do {
nBytes = ic2ReadReg (MMA7455_STATUS, &data, 0x1);
} while ( !(data & MMA7455_DRDY) && nBytes == MAA_SUCCESS);
if (nBytes == MAA_SUCCESS) {
std::cout << "NO_GDB :: 1" << std::endl;
return MAA_SUCCESS;
}*/
nBytes = ic2ReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
if (nBytes == 0) {
std::cout << "NO_GDB :: 2" << std::endl;
return MAA_ERROR_UNSPECIFIED;
}
if (xyz.reg.x_msb & 0x02) {
xyz.reg.x_msb |= 0xFC;
}
if (xyz.reg.y_msb & 0x02) {
xyz.reg.y_msb |= 0xFC;
}
if (xyz.reg.z_msb & 0x02) {
xyz.reg.z_msb |= 0xFC;
}
// The result is the g-force in units of 64 per 'g'.
*ptrX = xyz.value.x;
*ptrY = xyz.value.y;
*ptrZ = xyz.value.z;
return MAA_SUCCESS;
}
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
if (MAA_SUCCESS != maa_i2c_address(m_i2ControlCtx, m_controlAddr)) {
return 0;
}
if (MAA_SUCCESS != maa_i2c_write_byte(m_i2ControlCtx, reg)) {
return 0;
}
if (MAA_SUCCESS != maa_i2c_address(m_i2ControlCtx, m_controlAddr)) {
return 0;
}
return (int) maa_i2c_read(m_i2ControlCtx, buf, size);
}
maa_result_t
MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
maa_result_t error = MAA_SUCCESS;
uint8_t data[size + 1];
data[0] = reg;
memcpy(&data[1], buf, size);
error = maa_i2c_address (m_i2ControlCtx, m_controlAddr);
if (error != MAA_SUCCESS) {
return error;
}
error = maa_i2c_write (m_i2ControlCtx, data, size + 1);
if (error != MAA_SUCCESS) {
return error;
}
return error;
}

223
src/mma7455/mma7455.h Normal file
View File

@ -0,0 +1,223 @@
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 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 <string>
#include <maa/i2c.h>
#define ADDR 0x1D // device address
// Register names according to the datasheet.
// Register 0x1C is sometimes called 'PW', and sometimes 'PD'.
// The two reserved registers can not be used.
#define MMA7455_XOUTL 0x00 // Read only, Output Value X LSB
#define MMA7455_XOUTH 0x01 // Read only, Output Value X MSB
#define MMA7455_YOUTL 0x02 // Read only, Output Value Y LSB
#define MMA7455_YOUTH 0x03 // Read only, Output Value Y MSB
#define MMA7455_ZOUTL 0x04 // Read only, Output Value Z LSB
#define MMA7455_ZOUTH 0x05 // Read only, Output Value Z MSB
#define MMA7455_XOUT8 0x06 // Read only, Output Value X 8 bits
#define MMA7455_YOUT8 0x07 // Read only, Output Value Y 8 bits
#define MMA7455_ZOUT8 0x08 // Read only, Output Value Z 8 bits
#define MMA7455_STATUS 0x09 // Read only, Status Register
#define MMA7455_DETSRC 0x0A // Read only, Detection Source Register
#define MMA7455_TOUT 0x0B // Temperature Output Value (Optional)
#define MMA7455_RESERVED1 0x0C // Reserved
#define MMA7455_I2CAD 0x0D // Read/Write, I2C Device Address
#define MMA7455_USRINF 0x0E // Read only, User Information (Optional)
#define MMA7455_WHOAMI 0x0F // Read only, "Who am I" value (Optional)
#define MMA7455_XOFFL 0x10 // Read/Write, Offset Drift X LSB
#define MMA7455_XOFFH 0x11 // Read/Write, Offset Drift X MSB
#define MMA7455_YOFFL 0x12 // Read/Write, Offset Drift Y LSB
#define MMA7455_YOFFH 0x13 // Read/Write, Offset Drift Y MSB
#define MMA7455_ZOFFL 0x14 // Read/Write, Offset Drift Z LSB
#define MMA7455_ZOFFH 0x15 // Read/Write, Offset Drift Z MSB
#define MMA7455_MCTL 0x16 // Read/Write, Mode Control Register
#define MMA7455_INTRST 0x17 // Read/Write, Interrupt Latch Reset
#define MMA7455_CTL1 0x18 // Read/Write, Control 1 Register
#define MMA7455_CTL2 0x19 // Read/Write, Control 2 Register
#define MMA7455_LDTH 0x1A // Read/Write, Level Detection Threshold Limit Value
#define MMA7455_PDTH 0x1B // Read/Write, Pulse Detection Threshold Limit Value
#define MMA7455_PD 0x1C // Read/Write, Pulse Duration Value
#define MMA7455_LT 0x1D // Read/Write, Latency Time Value (between pulses)
#define MMA7455_TW 0x1E // Read/Write, Time Window for Second Pulse Value
#define MMA7455_RESERVED2 0x1F // Reserved
// Defines for the bits, to be able to change
// between bit number and binary definition.
// By using the bit number, programming the MMA7455
// is like programming an AVR microcontroller.
// But instead of using "(1<<X)", or "_BV(X)",
// the Arduino "bit(X)" is used.
#define MMA7455_D0 0
#define MMA7455_D1 1
#define MMA7455_D2 2
#define MMA7455_D3 3
#define MMA7455_D4 4
#define MMA7455_D5 5
#define MMA7455_D6 6
#define MMA7455_D7 7
// Status Register
#define MMA7455_DRDY MMA7455_D0
#define MMA7455_DOVR MMA7455_D1
#define MMA7455_PERR MMA7455_D2
// Mode Control Register
#define MMA7455_MODE0 MMA7455_D0
#define MMA7455_MODE1 MMA7455_D1
#define MMA7455_GLVL0 MMA7455_D2
#define MMA7455_GLVL1 MMA7455_D3
#define MMA7455_STON MMA7455_D4
#define MMA7455_SPI3W MMA7455_D5
#define MMA7455_DRPD MMA7455_D6
// Control 1 Register
#define MMA7455_INTPIN MMA7455_D0
#define MMA7455_INTREG0 MMA7455_D1
#define MMA7455_INTREG1 MMA7455_D2
#define MMA7455_XDA MMA7455_D3
#define MMA7455_YDA MMA7455_D4
#define MMA7455_ZDA MMA7455_D5
#define MMA7455_THOPT MMA7455_D6
#define MMA7455_DFBW MMA7455_D7
// Control 2 Register
#define MMA7455_LDPL MMA7455_D0
#define MMA7455_PDPL MMA7455_D1
#define MMA7455_DRVO MMA7455_D2
// Interrupt Latch Reset Register
#define MMA7455_CLR_INT1 MMA7455_D0
#define MMA7455_CLR_INT2 MMA7455_D1
// Detection Source Register
#define MMA7455_INT1 MMA7455_D0
#define MMA7455_INT2 MMA7455_D1
#define MMA7455_PDZ MMA7455_D2
#define MMA7455_PDY MMA7455_D3
#define MMA7455_PDX MMA7455_D4
#define MMA7455_LDZ MMA7455_D5
#define MMA7455_LDY MMA7455_D6
#define MMA7455_LDX MMA7455_D7
// I2C Device Address Register
#define MMA7455_I2CDIS MMA7455_D7
#define HIGH 1
#define LOW 0
namespace upm {
union accelData {
struct {
unsigned char x_lsb;
unsigned char x_msb;
unsigned char y_lsb;
unsigned char y_msb;
unsigned char z_lsb;
unsigned char z_msb;
} reg;
struct {
short x;
short y;
short z;
} value;
};
#define BIT(n) (1<<n)
/**
* @brief C++ API for MMA7455 chip (accelerometer)
*
* This file defines the MMA7455 C++ interface for libmma7455
*
* @snippet mma7455.cxx Interesting
*
*/
class MMA7455 {
public:
/**
* Instanciates a MMA7455 object
*
* @param bus number of used bus
* @param devAddr addres of used i2c device
*/
MMA7455 (int bus, int devAddr);
/**
* MMA7455 object destructor, basicaly it close i2c connection.
*/
~MMA7455 ();
/**
* Return name of the component
*/
std::string name()
{
return m_name;
}
/**
* Calibrate the sensor
*/
maa_result_t calibrate ();
/**
* Read X, Y and Z acceleration data
*
* @param ptrX X axis
* @param ptrY Y axis
* @param ptrZ Z axis
*/
maa_result_t readData (short * ptrX, short * ptrY, short * ptrZ);
/**
*
*
* @param reg register address
* @param buf register data buffer
* @param size buffer size
*/
int ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
/**
*
*
* @param reg register address
* @param buf register data buffer
* @param size buffer size
*/
maa_result_t ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size);
private:
std::string m_name;
int m_controlAddr;
int m_bus;
maa_i2c_context m_i2ControlCtx;
};
}

View File

@ -0,0 +1,8 @@
%module pyupm_mma7455
%feature("autodoc", "3");
%include "mma7455.h"
%{
#include "mma7455.h"
%}

View File

@ -0,0 +1,5 @@
set (libname "my9221")
set (libdescription "upm ledbar")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -1,12 +1,5 @@
set (libname "nrf24l01")
add_library (nrf24l01 SHARED nrf24l01.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (nrf24l01 ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES nrf24l01.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm NRF tx/rx")
endif()
set (libdescription "libupm NRF tx/rx")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

8
src/package.json.in Normal file
View File

@ -0,0 +1,8 @@
{
"name" : "jsupm_@libname@",
"main" : "./jsupm_@libname@.node",
"engines": {
"node": ">= 1.0.x"
},
"license": "MIT"
}

11
src/pkgconfig.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib@LIB_SUFFIX@
includedir=${prefix}/include
Name: upm-@libname@
Description: upm lib @libname@
Version: @upm_VERSION_STRING@
Libs: -L${libdir} -lupm-@libname@
Cflags: -I${includedir}/upm

View File

@ -1,12 +1,5 @@
set (libname "servo")
add_library (servo SHARED servo.cxx es08a.cxx)
include_directories (${MAA_INCLUDE_DIR})
target_link_libraries (servo ${MAA_LIBRARIES})
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
install (FILES servo.h DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
set(CPACK_COMPONENT_${libname}_DESCRIPTION "libupm servo")
endif()
set (libdescription "upm servo")
set (module_src servo.cxx es08a.cxx)
set (module_h servo.h es08a.h)
upm_module_init()

View File

@ -1,7 +0,0 @@
%module jsupm_es08a
%{
#include "es08a.h"
%}
%include "es08a.h"

7
src/servo/jsupm_servo.i Normal file
View File

@ -0,0 +1,7 @@
%module jsupm_servo
%{
#include "servo.h"
%}
%include "servo.h"

View File

@ -1,4 +1,4 @@
%module pyupm_es08a
%module pyupm_servo
%feature("autodoc", "3");

View File

@ -0,0 +1,5 @@
set (libname "tm1637")
set (libdescription "upm 4 digit display tm1637")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()