Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
3d453811fb | |||
67b0b9b219 | |||
502b928aff | |||
a9cb0718fe | |||
a1dac4228a | |||
6e2587576d | |||
f8179328cf | |||
dae5c67c02 | |||
eb2ff59fe5 | |||
b36eb487eb | |||
bc61e9f86b | |||
61175740f6 | |||
a41f59984f | |||
0bab36a95a | |||
ff88313462 | |||
3f5c357971 | |||
d2e11d6f11 | |||
3e82dd8d0a | |||
4f5030ecf7 | |||
784e8a3eb8 | |||
7fbe71102a | |||
6f34162ac5 | |||
46ab65a344 | |||
d8cf4c82a5 | |||
ab14f4f82e | |||
56cbeb6183 | |||
6efe6916ba | |||
ea544e8391 | |||
0c46dd28be | |||
d493c015fd | |||
1e3797ec48 | |||
6effb25bd6 | |||
796f188cb3 | |||
e0bc9573d4 | |||
5733918a2f | |||
6740932c47 | |||
9fb0ca3466 | |||
d6ce082274 | |||
3587162611 |
@ -15,7 +15,7 @@ find_package (PkgConfig REQUIRED)
|
||||
|
||||
# force a libmraa search and minimum required version every time a config is generated
|
||||
unset(MRAA_FOUND CACHE)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.6.0)
|
||||
pkg_check_modules (MRAA REQUIRED mraa>=0.6.2)
|
||||
message (INFO " found libmraa version: ${MRAA_VERSION}")
|
||||
|
||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||
@ -30,7 +30,7 @@ include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
||||
message (WARNING " - Install git to compile a production libmraa!")
|
||||
set (VERSION "v0.3.0-dirty")
|
||||
set (VERSION "v0.3.1-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - UPM Version ${VERSION}")
|
||||
@ -65,6 +65,10 @@ if (BUILDDOC)
|
||||
find_package (Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/*.png)
|
||||
foreach(PNG_FILE ${PNG_FILES})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target (doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
@ -90,7 +94,7 @@ if (BUILDDOC)
|
||||
# todo: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]]module</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
DEPENDS doc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
@ -106,7 +110,7 @@ if (BUILDDOC)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target(jsdoc ALL
|
||||
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../../../docs/images/
|
||||
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
|
||||
COMMAND ${NODE_EXECUTABLE} tolower -i html/node
|
||||
DEPENDS doc
|
||||
|
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright © 2014 Intel Corporation
|
||||
Copyright © 2014-2015 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
13
README.md
@ -23,6 +23,9 @@ may also create more complex structures in order to interface with them.
|
||||
|
||||
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
|
||||
|
||||
### Supported Sensors
|
||||
|
||||
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
|
||||
@ -57,10 +60,16 @@ Make sure you add yourself as an author on every new code file submitted.
|
||||
If you are providing a fix with significant changes, feel free to add yourself
|
||||
as a contributor. Signing-off your commits is mandatory.
|
||||
|
||||
C/C++ API Documentation
|
||||
API Documentation
|
||||
==============
|
||||
|
||||
The C/C++ documentation is available [here](http://iotdk.intel.com/docs/master/upm/).
|
||||
@htmlonly
|
||||
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="docs/c++.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/python.png"/></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/node.png"/></a>
|
||||
|
||||
@endhtmlonly
|
||||
|
||||
Version @ref changelog [here](docs/changelog.md).
|
||||
|
||||
|
@ -38,6 +38,7 @@ if (NODE_EXECUTABLE)
|
||||
set (V8_VERSION_STRING ${_V8_VERSION})
|
||||
string (REPLACE "." ";" _V8_VERSION_LIST "${_V8_VERSION}")
|
||||
string (REPLACE "." "" V8_DEFINE_STRING "${_V8_VERSION}")
|
||||
string (STRIP ${V8_DEFINE_STRING} V8_DEFINE_STRING)
|
||||
list (GET _V8_VERSION_LIST 0 V8_VERSION_MAJOR)
|
||||
list (GET _V8_VERSION_LIST 1 V8_VERSION_MINOR)
|
||||
list (GET _V8_VERSION_LIST 2 V8_VERSION_PATCH)
|
||||
@ -49,8 +50,8 @@ if (NODE_EXECUTABLE)
|
||||
set (NODE_VERSION_MINOR "10")
|
||||
set (NODE_VERSION_PATCH "30")
|
||||
set (V8_VERSION_MAJOR "3")
|
||||
set (V8_VERSION_MAJOR "14")
|
||||
set (V8_VERSION_MAJOR "5")
|
||||
set (V8_VERSION_MINOR "28")
|
||||
set (V8_VERSION_PATCH "72")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
endif ()
|
||||
|
BIN
docs/c++.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
@ -4,6 +4,15 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v0.3.1
|
||||
|
||||
* Updated index pages for API documentation and cross-linked them
|
||||
* More images were added for Grove, Adafruit and Sparkfun sensors along with
|
||||
licensing information
|
||||
* Addressed several issues reported by static code analysis tools
|
||||
* Added support for Grove NFC Tag sensor
|
||||
* Fixed several typos in library and sensor names
|
||||
|
||||
### v0.3.0
|
||||
|
||||
* New CMake targets to build python and node documentation with Sphinx and
|
||||
|
BIN
docs/images/ad8232.jpg
Executable file
After Width: | Height: | Size: 222 KiB |
BIN
docs/images/apds9002.jpg
Executable file
After Width: | Height: | Size: 22 KiB |
BIN
docs/images/at42qt1070.jpg
Executable file
After Width: | Height: | Size: 178 KiB |
BIN
docs/images/ecs1030.jpg
Executable file
After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 12 KiB |
BIN
docs/images/grovebutton.jpg
Executable file
After Width: | Height: | Size: 164 KiB |
BIN
docs/images/groveled.jpg
Executable file
After Width: | Height: | Size: 138 KiB |
BIN
docs/images/grovelight.jpg
Executable file
After Width: | Height: | Size: 22 KiB |
BIN
docs/images/groverelay.jpg
Executable file
After Width: | Height: | Size: 18 KiB |
BIN
docs/images/grovescam.jpg
Executable file
After Width: | Height: | Size: 135 KiB |
BIN
docs/images/grovetemp.jpg
Executable file
After Width: | Height: | Size: 21 KiB |
BIN
docs/images/guvas12d.jpg
Executable file
After Width: | Height: | Size: 100 KiB |
BIN
docs/images/l298.jpg
Executable file
After Width: | Height: | Size: 169 KiB |
BIN
docs/images/m24lr64e.jpg
Executable file
After Width: | Height: | Size: 24 KiB |
BIN
docs/images/maxsonarez.jpg
Executable file
After Width: | Height: | Size: 60 KiB |
BIN
docs/images/sm130.jpg
Executable file
After Width: | Height: | Size: 114 KiB |
@ -80,7 +80,7 @@ useful to us and converting it to a double.
|
||||
|
||||
Our final example, very easy to use API!
|
||||
|
||||
@snippet examples/max31855.cxx Interesting
|
||||
@snippet examples/c++/max31855.cxx Interesting
|
||||
|
||||
### Building
|
||||
|
||||
|
BIN
docs/node.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
docs/python.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
@ -3,7 +3,7 @@
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
**Welcome to UPM Python documentation!**
|
||||
**Welcome to UPM Python Documentation!**
|
||||
=========================================
|
||||
|
||||
.. include:: ../../README.md
|
||||
@ -14,7 +14,15 @@
|
||||
################
|
||||
|
||||
For building UPM, please follow this `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md>`_.
|
||||
|
||||
|
||||
``Examples``
|
||||
############
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_
|
||||
repository.
|
||||
|
||||
Individual sensor usage examples for python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
|
||||
``Making your own UPM Module``
|
||||
##############################
|
||||
|
||||
@ -22,7 +30,7 @@ This `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md
|
||||
|
||||
There is also an example available for max31855 `sensor <https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md>`_.
|
||||
|
||||
``Naming Conventions and rules for new UPM Contributions``
|
||||
``Naming Conventions and Rules for New UPM Contributions``
|
||||
##########################################################
|
||||
|
||||
Before you begin development, please take a look at our naming `conventions <https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md>`_.
|
||||
@ -33,11 +41,11 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
|
||||
.. note::
|
||||
|
||||
* Make sure you add yourself as an author on every new code file submitted.
|
||||
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
|
||||
* Make sure you add yourself as an author on every new code file submitted.
|
||||
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
|
||||
* Signing-off your commits is mandatory.
|
||||
|
||||
``List of available sensors drivers``
|
||||
``List of Available Sensors Drivers``
|
||||
######################################
|
||||
|
||||
.. toctree::
|
||||
@ -45,20 +53,25 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
|
||||
|
||||
modules
|
||||
|
||||
``C/C++ API Documentation``
|
||||
``Other API Documentation``
|
||||
###########################
|
||||
|
||||
The C/C++ API documentation is available `here <http://iotdk.intel.com/docs/master/upm/>`_.
|
||||
.. image:: ../docs/c++.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/modules.html
|
||||
.. image:: ../docs/python.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/python
|
||||
.. image:: ../docs/node.png
|
||||
:target: http://iotdk.intel.com/docs/master/upm/node
|
||||
|
||||
``Version``
|
||||
###########
|
||||
``Version Changelog``
|
||||
#####################
|
||||
|
||||
For Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
|
||||
For our Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
|
||||
|
||||
``Limitations and List of Changes``
|
||||
``Known Limitations``
|
||||
###################################
|
||||
|
||||
For List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
|
||||
For the List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
|
||||
|
||||
``Indices and tables``
|
||||
######################
|
||||
|
@ -43,20 +43,17 @@ opts
|
||||
|
||||
// use promise-style programming rather than spaghetti callbacks
|
||||
Promise.promisifyAll(fs);
|
||||
|
||||
|
||||
// TODO: create directory structure if doesn't exist
|
||||
var formats = opts.formats.split(',');
|
||||
formats.forEach(function(format){
|
||||
mkdirp('jsdoc/' + format + '/' + opts.module);
|
||||
});
|
||||
Promise.promisifyAll(mkdirp);
|
||||
|
||||
|
||||
// main
|
||||
xml2js.parse().then(function(specjs) {
|
||||
var formats = opts.formats.split(',');
|
||||
Promise.all(_.map(formats, function(format) {
|
||||
var generateDocs = require(__dirname + '/generators/' + format + '/generator');
|
||||
var outFile = opts.outdir + '/' + format + '/' + specjs.MODULE + '/doc.js';
|
||||
return fs.writeFileAsync(outFile, generateDocs(specjs));
|
||||
var dir = opts.outdir + '/' + format + '/' + specjs.MODULE;
|
||||
return mkdirp.mkdirpAsync(dir).then(function() {
|
||||
return fs.writeFileAsync(dir + '/doc.js', generateDocs(specjs));
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@ -58,6 +58,7 @@ function GENERATE_MODULE(module) {
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ '@instance\n'
|
||||
|
@ -28,44 +28,66 @@ var _ = require('lodash');
|
||||
|
||||
// generate json for ternjs input
|
||||
function generateDocs(specjs) {
|
||||
var docs = GENERATE_MODULE(specjs.MODULE);
|
||||
GENERATE_TYPE = (function(enums) {
|
||||
return function(type) {
|
||||
return (_.contains(enums, type) ? ('Enum ' + type) : type);
|
||||
}
|
||||
})(_.keys(specjs.ENUMS_BY_GROUP));
|
||||
var docs = { '!name': specjs.MODULE + 'library' };
|
||||
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
|
||||
_.each(specjs.ENUMS, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
_.each(specjs.METHODS, function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(specjs.CLASSES, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
|
||||
if (_.isEmpty(specjs.CLASSGROUPS)) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
|
||||
} else {
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
_.extend(docs, GENERATE_MODULE(groupName));
|
||||
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
|
||||
});
|
||||
docs[specjs.MODULE][parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
});
|
||||
}
|
||||
return JSON.stringify(docs, null, 2);
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(module) {
|
||||
var docs = { '!name': module + 'library' };
|
||||
var docs = {};
|
||||
docs[module] = {};
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate the spec for the given list of classes
|
||||
function GENERATE_CLASSES(classes) {
|
||||
var docs = {};
|
||||
_.each(classes, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
if (_.has(docs, parentClass)) {
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
docs[parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
}
|
||||
});
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate method spec
|
||||
function GENERATE_METHOD(name, spec) {
|
||||
var doc = {};
|
||||
|
14
doxy/node/generators/yuidoc/generator.js
vendored
@ -46,7 +46,7 @@ function generateDocs(specjs) {
|
||||
docs += GENERATE_MODULE('common', '');
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
|
||||
});
|
||||
@ -76,7 +76,7 @@ function GENERATE_MODULE(name, description) {
|
||||
function GENERATE_CLASSES(classes, parent) {
|
||||
return _.reduce(classes, function(memo, classSpec, className) {
|
||||
return memo
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent)
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
|
||||
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec, className);
|
||||
}, '')
|
||||
@ -91,15 +91,21 @@ function GENERATE_CLASSES(classes, parent) {
|
||||
|
||||
|
||||
// generate class spec
|
||||
function GENERATE_CLASS(name, description, parent) {
|
||||
function GENERATE_CLASS(name, description, namespace, parent) {
|
||||
return GENERATE_DOC(description + '\n'
|
||||
+ '@class ' + name + '\n'
|
||||
+ (parent ? ('@module ' + parent + '\n') : ''));
|
||||
+ (namespace ? ('@module ' + namespace + '\n') : '')
|
||||
/*
|
||||
TODO: leave out until figure out what swig does with inheritance
|
||||
+ (parent ? ('@extends ' + parent + '\n') : '')
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')
|
||||
|
10
doxy/node/generators/yuidoc/helper.js
vendored
@ -77,17 +77,15 @@ function listByGroup(modules, classes, field, projectRoot) {
|
||||
var groups = Object.keys(modulesByGroup).sort();
|
||||
var html = '';
|
||||
var pfx = projectRoot + 'modules/';
|
||||
var first = true;
|
||||
for (i = 0; i < groups.length; i++) {
|
||||
var group = groups[i];
|
||||
html += (first ? '' : '</span>');
|
||||
html += '<div class="upmGroup"><div class="right-arrow"></div>' + group + '</div><span class="upmModules" style="display:none">';
|
||||
var moduleNames = modulesByGroup[group];
|
||||
for (j = 0; j < moduleNames.length; j++) {
|
||||
var moduleName = moduleNames[j];
|
||||
html += '<a href="' + pfx + moduleName + '.html">' + moduleName + '</a>';
|
||||
}
|
||||
first = false;
|
||||
html += '</span>';
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@ -117,7 +115,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
vertical-align: 5px; \
|
||||
display: inline; \
|
||||
float: left; \
|
||||
} \
|
||||
div.down-arrow { \
|
||||
width: 0; \
|
||||
@ -127,7 +125,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
border-top: 5px solid #356de4; \
|
||||
font-size: 0; \
|
||||
margin-right: 5px; \
|
||||
display: inline; \
|
||||
float: left; \
|
||||
} \
|
||||
div.upmGroup { \
|
||||
font-weight: bold; \
|
||||
@ -137,7 +135,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
|
||||
|
||||
var scripts = "YUI().use('node', 'event', function (Y) {"
|
||||
+ onClickHandler
|
||||
+ insertStyles
|
||||
// + insertStyles
|
||||
+ "});";
|
||||
|
||||
|
||||
|
@ -311,13 +311,13 @@ abbr {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
@ -357,7 +357,7 @@ ul li p {
|
||||
#hd img {
|
||||
margin-right: 10px;
|
||||
vertical-align: middle;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -787,3 +787,28 @@ kbd .cmd { font-family: Monaco, Helvetica; }
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.right-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-bottom: 5px solid transparent;
|
||||
border-top: 5px solid transparent;
|
||||
border-left: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.down-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 5px solid #356de4;
|
||||
font-size: 0;
|
||||
margin-right: 5px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.upmGroup {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
<h1>UPM</h1>
|
||||
<p>
|
||||
The UPM API is a high level sensor library for IoT devices using MRAA. See examples <a href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.
|
||||
Back to <a href="http://iotdk.intel.com/docs/master/upm/node/"> index </a> page.
|
||||
<br><em>SparkFun sensor images provided under <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>CC BY-NC-SA-3.0</a>.</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
166
doxy/node/generators/yuidoc/tmpl/partials/index.handlebars
Normal file
@ -0,0 +1,166 @@
|
||||
<div class="apidocs">
|
||||
<div class="content" id="docs-main">
|
||||
<h1><strong>Welcome to UPM Node.JS Documentation!</strong><a class="headerlink"
|
||||
href="#welcome-to-upm-python-documentation"></a></h1>
|
||||
|
||||
|
||||
<p>Browse to a module or class using the sidebar to view its API
|
||||
documentation.</p>
|
||||
|
||||
<p>UPM is a high level repository for sensors that use libmraa. Each
|
||||
sensor links to libmraa and are not meant to be interlinked although
|
||||
some groups of sensors may be. Each sensor contains a header which
|
||||
allows to interface with it. Typically a sensor is represented as a
|
||||
class and instantiated.</p>
|
||||
|
||||
<p>The constructor is expected to initialise the sensor and parameters
|
||||
may be used to provide identification/pin location on the board.</p>
|
||||
|
||||
<p>Typically an update() function will be called in order to get new
|
||||
data from the sensor in order to reduce load when doing multiple reads
|
||||
to sensor data.</p>
|
||||
<div class="section" id="examples">
|
||||
<h3><code class="docutils literal"><span class="pre">Examples</span></code><a class="headerlink"
|
||||
href="#examples"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Multi-sensor samples for the starter and specialized kits can be
|
||||
found in the
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/iot-devkit-samples">iot-devkit-samples</a>
|
||||
repository.</p>
|
||||
|
||||
<p>Individual sensor usage examples for node.js are available
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="building-upm">
|
||||
<h3><tt class="docutils literal"><span class="pre">Building</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
href="#building-upm"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For building UPM, please follow this
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md">link</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="making-your-own-upm-module">
|
||||
<h3><tt class="docutils literal"><span class="pre">Making</span>
|
||||
<span class="pre">your</span> <span class="pre">own</span>
|
||||
<span class="pre">UPM</span> <span class="pre">Module</span></tt><a class="headerlink"
|
||||
href="#making-your-own-upm-module"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>This
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md">link</a>
|
||||
has more information on making a new UPM module.</p>
|
||||
|
||||
<p>There is also an example available for max31855
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md">sensor</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section"
|
||||
id="naming-conventions-and-rules-for-new-upm-contributions">
|
||||
<h3><tt class="docutils literal"><span class="pre">Naming</span>
|
||||
<span class="pre">Conventions</span> <span class="pre">and</span>
|
||||
<span class="pre">Rules</span> <span class="pre">for</span>
|
||||
<span class="pre">New</span> <span class="pre">UPM</span>
|
||||
<span class="pre">Contributions</span></tt><a class="headerlink"
|
||||
href="#naming-conventions-and-rules-for-new-upm-contributions"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Before you begin development, please take a look at our naming
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md">conventions</a>.</p>
|
||||
|
||||
|
||||
<p>Also, please read the guidelines for contributions to
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/contributions.md">UPM</a>.</p>
|
||||
|
||||
|
||||
<p>Don’t forget to check the documentation
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/documentation.md">section</a>.</p>
|
||||
|
||||
<div class="admonition note">
|
||||
|
||||
<p class="first admonition-title">Note</p>
|
||||
<ul class="last simple">
|
||||
<li>Make sure you add yourself as an author on every new code
|
||||
file submitted.</li>
|
||||
<li>If you are providing a fix with significant changes, feel
|
||||
free to add yourself as a contributor.</li>
|
||||
<li>Signing-off your commits is mandatory.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="api-documentation">
|
||||
<h1><strong>Other API Documentation</strong><a class="headerlink"
|
||||
href="#api-documentation"
|
||||
title="Permalink to this headline"></a></h1>
|
||||
|
||||
|
||||
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/c++.png" /></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/python.png" /></a>
|
||||
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/node.png" /></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section" id="version-changelog">
|
||||
<h3><tt class="docutils literal"><span class="pre">Version</span>
|
||||
<span class="pre">Changelog</span></tt><a class="headerlink"
|
||||
href="#version-changelog"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For our Version Changelog, please see
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="known-limitations">
|
||||
<h3><tt class="docutils literal"><span class="pre">Known</span>
|
||||
<span class="pre">Limitations</span></tt><a class="headerlink"
|
||||
href="#known-limitations"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>For the List of Known Limitations, please see
|
||||
<a class="reference external"
|
||||
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="keyboard-shortcuts">
|
||||
<h3><tt class="docutils literal"><span class="pre">Keyboard</span>
|
||||
<span class="pre">Shortcuts</span></tt><a class="headerlink"
|
||||
href="#keyboard-shortcuts"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<p>Press <kbd>s</kbd> to focus the API search box.</p> </li>
|
||||
<li>
|
||||
|
||||
<p>Use <kbd>Up</kbd> and <kbd>Down</kbd> to select classes,
|
||||
modules, and search results.</p> </li>
|
||||
<li class="mac-only">
|
||||
|
||||
<p>With the API search box or sidebar focused, use <kbd><span class="cmd">⌘</span>-Left</kbd>
|
||||
or <kbd><span class="cmd">⌘</span>-Right</kbd> to switch
|
||||
sidebar tabs.</p> </li>
|
||||
<li class="pc-only">
|
||||
|
||||
<p>With the API search box or sidebar focused, use <kbd>Ctrl+Left</kbd>
|
||||
and <kbd>Ctrl+Right</kbd> to switch sidebar tabs.</p> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
@ -69,6 +69,8 @@ var xml2js = {
|
||||
// CLASSES: {
|
||||
// <class name>: {
|
||||
// description: <class description>,
|
||||
// parent: <parent class name>,
|
||||
// group: <group name>,
|
||||
// methods: { ... },
|
||||
// variables: {
|
||||
// <variable name>: {
|
||||
@ -83,7 +85,9 @@ var xml2js = {
|
||||
// CLASSGROUPS: {
|
||||
// <group name>: {
|
||||
// description: <group description>,
|
||||
// classes: [ <class name>, ... ]
|
||||
// classes: [ <class name>, ... ],
|
||||
// enums: { ... },
|
||||
// enums_by_group: { ... }
|
||||
// }, ...
|
||||
// }
|
||||
MODULE: '',
|
||||
@ -98,7 +102,8 @@ var xml2js = {
|
||||
TYPEMAPS: {
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(int|short|long|float|double|size_t|u?int\\d{1,2}_t)?$': 'Number',
|
||||
'^bool$': 'Boolean',
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String' // TODO: verify that swig does this mapping
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String', // TODO: verify that swig does this mapping
|
||||
'^void\\s*\\(\\s*\\*\\s*\\)\\s*\\(\\s*void\\s*\\*\\)\\s*$': 'Function'
|
||||
},
|
||||
|
||||
|
||||
@ -157,13 +162,14 @@ var xml2js = {
|
||||
try {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
var className = getName(spec_c);
|
||||
xml2js.CLASSES[className] = {
|
||||
_.extend(xml2js.CLASSES[className], {
|
||||
description: getDescription(spec_c),
|
||||
parent: getParent(spec_c, className),
|
||||
enums: getEnums(spec_c, false, className),
|
||||
enums_by_group: getEnums(spec_c, true, className),
|
||||
variables: getVariables(spec_c, className),
|
||||
methods: getMethods(spec_c, className)
|
||||
};
|
||||
});
|
||||
} catch(e) {
|
||||
console.log(e.toString() + ': class ' + className + ' was not parsed correctly.');
|
||||
}
|
||||
@ -177,15 +183,48 @@ var xml2js = {
|
||||
return fs.readFileAsync(xml2js.opts.inputdir + '/' + fn, 'utf8').then(function(xml) {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
if (_.isEmpty(getSubmodules(spec_c))) {
|
||||
xml2js.CLASSGROUPS[getName(spec_c)] = {
|
||||
var group = getName(spec_c);
|
||||
var classes = getSubclassNames(spec_c);
|
||||
xml2js.CLASSGROUPS[group] = {
|
||||
description: getDescription(spec_c),
|
||||
classes: getSubclassNames(spec_c)
|
||||
}
|
||||
classes: classes
|
||||
};
|
||||
_.each(classes, function(c) {
|
||||
if (_.has(xml2js.CLASSES, c)) {
|
||||
xml2js.CLASSES[c].group = group;
|
||||
} else {
|
||||
console.log('Warning: Group ' + group + ' has unknown class ' + c);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
return Promise.all(parseClasses.concat(parseGroups));
|
||||
}).then(function() {
|
||||
if (!_.isEmpty(xml2js.CLASSGROUPS)) {
|
||||
// try to categorize ungrouped classes, if any
|
||||
var grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
_.each(ungrouped, function(c) {
|
||||
_.each(findUsage(c), function(group) {
|
||||
xml2js.CLASSGROUPS[group].classes.push(c);
|
||||
});
|
||||
});
|
||||
grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
// try to categorize ungrouped enums, if any
|
||||
_.each(xml2js.ENUMS_BY_GROUP, function(enumGroupSpec, enumGroupName) {
|
||||
_.each(findUsage(enumGroupName, true), function(c) {
|
||||
xml2js.CLASSES[c].enums_by_group[enumGroupName] = enumGroupSpec;
|
||||
_.each(enumGroupSpec.members, function(enumName) {
|
||||
xml2js.CLASSES[c].enums[enumName] = xml2js.ENUMS[enumName];
|
||||
delete xml2js.ENUMS[enumName];
|
||||
});
|
||||
delete xml2js.ENUMS_BY_GROUP[enumGroupName];
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function() {
|
||||
if (xml2js.opts.custom && fs.existsSync(xml2js.opts.custom)) {
|
||||
return fs.readFileAsync(xml2js.opts.custom, 'utf8').then(function(custom) {
|
||||
@ -199,9 +238,9 @@ var xml2js = {
|
||||
console.log(xml2js.opts.custom ? ('Error: No such customization file exists: ' + xml2js.opts.custom) : 'No customizations given.');
|
||||
}
|
||||
}).then(function() {
|
||||
generateCustomPointerClasses();
|
||||
validateMethods();
|
||||
validateVars();
|
||||
generateCustomPointerClasses();
|
||||
return _.pick(xml2js, 'MODULE', 'ENUMS', 'ENUMS_BY_GROUP', 'METHODS', 'CLASSES', 'CLASSGROUPS');
|
||||
});
|
||||
}
|
||||
@ -391,7 +430,30 @@ function generateCustomPointerClasses() {
|
||||
}
|
||||
|
||||
|
||||
// override autogenerated methods with custom configuration
|
||||
// search for usage of a type
|
||||
function findUsage(type, classOnly) {
|
||||
var filterClasses = function(fn) { return _.without(_.map(xml2js.CLASSES, fn), undefined); };
|
||||
var usesType = function(classSpec, className) {
|
||||
var methodsOfType = (_.find(classSpec.methods, function(methodSpec, methodName) {
|
||||
return ((!_.isEmpty(methodSpec.return) && methodSpec.return.type == type) ||
|
||||
(_.contains(_.pluck(methodSpec.params, 'type'), type)));
|
||||
}) != undefined);
|
||||
var variablesOfType = _.contains(_.pluck(classSpec.variable, 'type'), type);
|
||||
return ((methodsOfType || variablesOfType) ? className : undefined);
|
||||
};
|
||||
var extendsType = function(classSpec, className) {
|
||||
return ((classSpec.parent == type) ? className : undefined);
|
||||
};
|
||||
var classes = _.union(filterClasses(usesType), filterClasses(extendsType));
|
||||
if (classOnly) {
|
||||
return classes;
|
||||
} else {
|
||||
return _.without(_.uniq(_.pluck(_.pick(xml2js.CLASSES, classes), 'group')), undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// override autogenerated methods with custom configuration
|
||||
function customizeMethods(custom) {
|
||||
_.each(custom, function(classMethods, className) {
|
||||
_.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
|
||||
@ -527,6 +589,19 @@ function getSubmodules(spec_c) {
|
||||
}
|
||||
|
||||
|
||||
// get parent class, if any
|
||||
function getParent(spec_c, className) {
|
||||
var parent = getChild(spec_c, 'basecompoundref');
|
||||
if (parent) {
|
||||
parent = getText(parent);
|
||||
if (!_.has(xml2js.CLASSES, parent)) {
|
||||
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
function hasParams(paramsSpec) {
|
||||
return !(_.isEmpty(paramsSpec) ||
|
||||
((_.size(paramsSpec) == 1) && getText(getChild(paramsSpec[0], 'type')) == 'void'));
|
||||
@ -559,6 +634,7 @@ function getMethods(spec_c, parent) {
|
||||
if (!_.isEmpty(returnSpec)) {
|
||||
retval = getReturn(returnSpec, getReturnDetails(description), methodName, parent);
|
||||
}
|
||||
methodName = getUniqueMethodName(methodName, spec_js, parent);
|
||||
spec_js[methodName] = {
|
||||
description: methodDescription,
|
||||
params: params,
|
||||
@ -575,6 +651,17 @@ function getMethods(spec_c, parent) {
|
||||
}
|
||||
|
||||
|
||||
// get a unique string to represent the name of an overloaded method
|
||||
function getUniqueMethodName(methodName, module, parent) {
|
||||
if (methodName in module) {
|
||||
do {
|
||||
methodName += '!';
|
||||
} while (methodName in module);
|
||||
}
|
||||
return methodName;
|
||||
}
|
||||
|
||||
|
||||
// get variable specifications for a class
|
||||
function getVariables(spec_c, parent) {
|
||||
var spec_js = {};
|
||||
|
@ -122,6 +122,7 @@ add_executable (ht9170-example ht9170.cxx)
|
||||
add_executable (h3lis331dl-example h3lis331dl.cxx)
|
||||
add_executable (ad8232-example ad8232.cxx)
|
||||
add_executable (grovescam-example grovescam.cxx)
|
||||
add_executable (m24lr64e-example m24lr64e.cxx)
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
|
||||
@ -222,6 +223,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/ht9170)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/h3lis331dl)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/ad8232)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/grovescam)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src/m24lr64e)
|
||||
|
||||
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
|
||||
@ -345,3 +347,4 @@ target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
@ -58,7 +58,7 @@ void sendCommand(upm::HM11* ble, char *cmd)
|
||||
{
|
||||
memset(buffer, 0, BUFSIZ);
|
||||
|
||||
ble->readData(buffer, BUFSIZ);
|
||||
ble->readData(buffer, BUFSIZ - 1);
|
||||
cout << "Returned: " << buffer << endl;
|
||||
}
|
||||
else
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "hmtrp.h"
|
||||
@ -128,7 +129,8 @@ int main (int argc, char **argv)
|
||||
// check to see if data is available first.
|
||||
if (radio->dataAvailable())
|
||||
{
|
||||
int rv = radio->readData(radioBuffer, bufferLength);
|
||||
memset(radioBuffer, 0, bufferLength);
|
||||
int rv = radio->readData(radioBuffer, bufferLength - 1);
|
||||
|
||||
if (rv > 0)
|
||||
cout << "Received: " << radioBuffer << endl;
|
||||
|
@ -36,4 +36,5 @@ main(int argc, char **argv)
|
||||
lcd->write("Hello World");
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,4 +39,6 @@ main(int argc, char **argv)
|
||||
lcd->setCursor(3,6);
|
||||
lcd->write("Hello World");
|
||||
delete lcd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
65
examples/c++/m24lr64e.cxx
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* 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 <unistd.h>
|
||||
#include <iostream>
|
||||
#include "m24lr64e.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an M24LR64E on I2C bus 0
|
||||
|
||||
upm::M24LR64E *nfcTag = new upm::M24LR64E(M24LR64E_I2C_BUS);
|
||||
|
||||
// This example accesses the device in the 'user' (default) mode,
|
||||
// reads the last byte of data in the EEPROM, inverts it, writes
|
||||
// it back, and then re-reads it.
|
||||
|
||||
// Read the last byte of the EEPROM area
|
||||
|
||||
int addr = M24LR64E::EEPROM_I2C_LENGTH - 1;
|
||||
printf("Address: %d\n", addr);
|
||||
uint8_t byte = nfcTag->readByte(addr);
|
||||
printf("Read byte: %02x\n", byte);
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
byte = ~byte;
|
||||
nfcTag->writeByte(addr, byte);
|
||||
printf("Wrote inverted byte: %02x\n", byte);
|
||||
|
||||
// Now read it back.
|
||||
byte = nfcTag->readByte(addr);
|
||||
printf("Read byte: %02x\n", byte);
|
||||
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete nfcTag;
|
||||
return 0;
|
||||
}
|
@ -95,4 +95,5 @@ main(int argc, char **argv)
|
||||
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -123,4 +123,5 @@ main(int argc, char **argv)
|
||||
|
||||
delete lcd;
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ main(int argc, char** argv)
|
||||
int timezone = -7; // Your UTC offset
|
||||
time_t rawtime;
|
||||
struct tm * gmt;
|
||||
char myTime[4];
|
||||
char myTime[5];
|
||||
|
||||
fprintf(stdout, "TM1637 Display Example\n");
|
||||
signal(SIGINT, sig_handler);
|
||||
@ -62,8 +62,10 @@ main(int argc, char** argv)
|
||||
time(&rawtime); // Update raw time
|
||||
gmt = gmtime(&rawtime); // Get current time
|
||||
|
||||
int hour = (gmt) ? gmt->tm_hour : 0;
|
||||
int min = (gmt) ? gmt->tm_min : 0;
|
||||
// Format and store the time in 24 hour format
|
||||
sprintf(myTime, "%2d%02d", (gmt->tm_hour + timezone + 24) % 24, gmt->tm_min);
|
||||
snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min);
|
||||
|
||||
myDisplay.write(myTime); // Write to display as string
|
||||
myDisplay.setColon(point ^= true); // Toggle the dots on the display
|
||||
|
59
examples/javascript/m24lr64e.js
Normal file
@ -0,0 +1,59 @@
|
||||
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||
/*jshint unused:true */
|
||||
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
var nfcTagObj = require('jsupm_m24lr64e');
|
||||
|
||||
// Instantiate a M24LR64E Grove NFC Tag Module on UART 0
|
||||
var nfcTag = new nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS);
|
||||
|
||||
// This example accesses the device in the 'user' (default) mode,
|
||||
// reads the last byte of data in the EEPROM, inverts it, writes
|
||||
// it back, and then re-reads it.
|
||||
|
||||
// Read the last byte of the EEPROM area
|
||||
var addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1);
|
||||
console.log("Address: " + addr);
|
||||
var byte = nfcTag.readByte(addr);
|
||||
|
||||
console.log("Read byte: " + byte.toString(16));
|
||||
|
||||
// Now change it to it's opposite and write it
|
||||
byte = (~byte & 0xff);
|
||||
nfcTag.writeByte(addr, byte);
|
||||
console.log("Wrote inverted byte: " + byte.toString(16));
|
||||
|
||||
// Now read it back.
|
||||
byte = nfcTag.readByte(addr);
|
||||
console.log("Read byte: " + byte.toString(16));
|
||||
|
||||
// clean up
|
||||
nfcTag = null;
|
||||
nfcTagObj.cleanUp();
|
||||
nfcTagObj = null;
|
||||
console.log("Exiting...");
|
||||
process.exit(0);
|
49
examples/python/m24lr64e.py
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
import pyupm_m24lr64e as nfcTagObj
|
||||
|
||||
# Instantiate a M24LR64E Grove NFC Tag Module on UART 0
|
||||
nfcTag = nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS)
|
||||
|
||||
# This example accesses the device in the 'user' (default) mode,
|
||||
# reads the last byte of data in the EEPROM, inverts it, writes
|
||||
# it back, and then re-reads it.
|
||||
|
||||
# Read the last byte of the EEPROM area
|
||||
addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1)
|
||||
print "Address: ", addr
|
||||
byte = nfcTag.readByte(addr)
|
||||
|
||||
print "Read byte: ", format(byte, '02x')
|
||||
|
||||
# Now change it to it's opposite and write it
|
||||
byte = (~byte & 0xff)
|
||||
nfcTag.writeByte(addr, byte)
|
||||
print "Wrote inverted byte: ", format(byte, '02x')
|
||||
|
||||
# Now read it back.
|
||||
byte = nfcTag.readByte(addr)
|
||||
print "Read byte: ", format(byte, '02x')
|
||||
|
@ -66,7 +66,7 @@ macro(upm_doxygen)
|
||||
add_dependencies (${libname}doc_i doc)
|
||||
if (BUILDSWIG)
|
||||
add_dependencies (_pyupm_${libname} ${libname}doc_i)
|
||||
add_dependencies (pydoc _pyupm_${libname})
|
||||
add_dependencies (pydoc _pyupm_${libname})
|
||||
else ()
|
||||
add_dependencies (${libname} doc)
|
||||
endif ()
|
||||
|
@ -61,10 +61,15 @@ namespace upm {
|
||||
* that should work, using information from the Sparkfun website.
|
||||
*
|
||||
* This example just dumps the raw data.
|
||||
*
|
||||
* @image html ad8232.jpg
|
||||
* <br><em>AD8232 Heart Rate Monitor image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* @snippet ad8232.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
class AD8232 {
|
||||
public:
|
||||
|
||||
|
@ -114,7 +114,7 @@ void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
|
||||
// 1 = extended 0.6ms to 2.4ms
|
||||
// 2 = extended 0.8ms to 2.2ms
|
||||
|
||||
uint16_t duration;
|
||||
uint16_t duration = 0;
|
||||
int result;
|
||||
int r2;
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief ADIS16448 accelerometer library
|
||||
* @defgroup adis16448 libupm-adis16488
|
||||
* @defgroup adis16448 libupm-adis16448
|
||||
* @ingroup generic spi accelerometer
|
||||
*/
|
||||
|
||||
|
@ -47,6 +47,7 @@ namespace upm {
|
||||
* This sensor transforms luminous intensity to output analog values.
|
||||
* It uses the APDS-9002 ambient light sensor.
|
||||
*
|
||||
* @image html apds9002.jpg
|
||||
* @snippet apds9002.cxx Interesting
|
||||
*/
|
||||
|
||||
|
@ -56,6 +56,7 @@ namespace upm {
|
||||
*
|
||||
* It was developed using the Grove Q Touch Sensor board.
|
||||
*
|
||||
* @image html at42qt1070.jpg
|
||||
* @snippet at42qt1070.cxx Interesting
|
||||
*/
|
||||
class AT42QT1070 {
|
||||
|
@ -62,7 +62,7 @@
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief Bosch BPM & GY65 atmospheric pressure sensor library
|
||||
* @brief Bosch BMP & GY65 atmospheric pressure sensor library
|
||||
* @defgroup bmpx8x libupm-bmpx8x
|
||||
* @ingroup seeed adafruit sparkfun i2c pressure
|
||||
*/
|
||||
|
@ -53,6 +53,7 @@ namespace upm {
|
||||
* @comname ECS1030 Non-Invasive Current Sensor
|
||||
* @type electric
|
||||
* @man sparkfun
|
||||
* @web https://www.sparkfun.com/products/11005
|
||||
* @con analog
|
||||
*
|
||||
* @brief API for the ECS1030 Non-Invasive Current/Electricity Sensor
|
||||
@ -64,6 +65,11 @@ namespace upm {
|
||||
* measure a load up to 30 Amps which makes it great for building your own
|
||||
* energy monitors.
|
||||
*
|
||||
* @image html ecs1030.jpg
|
||||
* <br><em>ECS1030 Sensor image provided by Sparkfun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* @snippet ecs1030.cxx Interesting
|
||||
*/
|
||||
class ECS1030 {
|
||||
|
@ -40,6 +40,7 @@ namespace upm {
|
||||
* @comname Flex Sensor
|
||||
* @type flexfor
|
||||
* @man sparkfun
|
||||
* @web https://www.sparkfun.com/products/8606
|
||||
* @con analog
|
||||
*
|
||||
* @brief API for the Spectra Symbol Flex sensor
|
||||
@ -49,6 +50,10 @@ namespace upm {
|
||||
* the original Nintendo Power Glove.
|
||||
*
|
||||
* @image html flex.jpg
|
||||
* <br><em>Flex Sensor image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* @snippet flex.cxx Interesting
|
||||
*/
|
||||
class Flex {
|
||||
|
@ -60,6 +60,7 @@ class Grove {
|
||||
* @ingroup grove gpio
|
||||
* @snippet groveled.cxx Interesting
|
||||
* @snippet groveled-multi.cxx Interesting
|
||||
* @image html groveled.jpg
|
||||
*/
|
||||
class GroveLed: public Grove {
|
||||
public:
|
||||
@ -111,6 +112,7 @@ class GroveLed: public Grove {
|
||||
*
|
||||
* @ingroup grove gpio
|
||||
* @snippet groverelay.cxx Interesting
|
||||
* @image html groverelay.jpg
|
||||
*/
|
||||
class GroveRelay: public Grove {
|
||||
public:
|
||||
@ -161,6 +163,7 @@ class GroveRelay: public Grove {
|
||||
*
|
||||
* @ingroup grove analog
|
||||
* @snippet grovetemp.cxx Interesting
|
||||
* @image html grovetemp.jpg
|
||||
*/
|
||||
class GroveTemp: public Grove {
|
||||
public:
|
||||
@ -201,6 +204,7 @@ class GroveTemp: public Grove {
|
||||
*
|
||||
* @ingroup grove analog
|
||||
* @snippet grovelight.cxx Interesting
|
||||
* @image html grovelight.jpg
|
||||
*/
|
||||
class GroveLight: public Grove {
|
||||
public:
|
||||
@ -348,6 +352,7 @@ class GroveSlide: public Grove {
|
||||
*
|
||||
* @ingroup grove gpio
|
||||
* @snippet grovebutton.cxx Interesting
|
||||
* @image html grovebutton.jpg
|
||||
*/
|
||||
class GroveButton: public Grove {
|
||||
public:
|
||||
|
@ -36,6 +36,6 @@
|
||||
* @brief API for Grove Button
|
||||
*
|
||||
* Very basic UPM module for Grove button
|
||||
*
|
||||
* @image html grovebutton.jpg
|
||||
* @snippet grovebutton.cxx Interesting
|
||||
*/
|
||||
*/
|
||||
|
@ -41,7 +41,8 @@
|
||||
* negative seat (cathode). The flat side of the bulb corresponds
|
||||
* to the cathode while the rounded side corresponds to the anode.
|
||||
*
|
||||
* @image html groveled.h
|
||||
* @snippet groveled.cxx Interesting
|
||||
* @snippet groveled-multi.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
* analog pin will be larger in bright light and smaller in the dark.
|
||||
* An approximate lux value can also be returned.
|
||||
*
|
||||
* @image html grovelight.jpg
|
||||
* @snippet grovelight.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
* control a higher voltage and/or higher current. When closed,
|
||||
* the indicator LED will light up and current is allowed to flow.
|
||||
*
|
||||
* @image html groverelay.jpg
|
||||
* @snippet groverelay.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
*
|
||||
* Very basic UPM module for Grove temperature sensor on analog
|
||||
*
|
||||
* @image html grovetemp.h
|
||||
* @snippet grovetemp.cxx Interesting
|
||||
*/
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ GROVESCAM::GROVESCAM(int uart, uint8_t camAddr)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -70,7 +70,8 @@ namespace upm {
|
||||
* sketch.
|
||||
*
|
||||
* It is connected via a UART at 115200 baud.
|
||||
*
|
||||
*
|
||||
* @image html grovescam.jpg
|
||||
* @snippet grovescam.cxx Interesting
|
||||
*/
|
||||
|
||||
|
@ -46,6 +46,7 @@ namespace upm {
|
||||
*
|
||||
* UPM module for the GUVAS12D UV Sensor
|
||||
*
|
||||
* @image html guvas12d.jpg
|
||||
* @snippet guvas12d.cxx Interesting
|
||||
*/
|
||||
class GUVAS12D {
|
||||
|
@ -42,7 +42,7 @@ HM11::HM11(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ HMTRP::HMTRP(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ HTU21D::~HTU21D() {
|
||||
mraa_i2c_stop(m_i2ControlCtx);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
HTU21D::resetSensor(void)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -134,7 +134,7 @@ class HTU21D {
|
||||
* it is in a known state. This function can be used to reset
|
||||
* the min/max temperature and pressure values.
|
||||
*/
|
||||
int resetSensor(void);
|
||||
void resetSensor(void);
|
||||
|
||||
/**
|
||||
* Function intended to test the device and verify it
|
||||
|
@ -81,7 +81,7 @@ Itg3200::~Itg3200()
|
||||
mraa_i2c_stop(m_i2c);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
void
|
||||
Itg3200::calibrate(void)
|
||||
{
|
||||
int reads = 600;
|
||||
|
@ -73,9 +73,8 @@ public:
|
||||
* Calibrates the sensor to 0 on all axes. Sensor needs to be resting for accurate calibration.
|
||||
* Takes about 3 seconds and is also called by constructor on object creation.
|
||||
*
|
||||
* @return 0 for successful calibration
|
||||
*/
|
||||
mraa_result_t calibrate();
|
||||
void calibrate();
|
||||
|
||||
/**
|
||||
* Returns the temperature reading from the integrated temperature sensor in Celsius degrees
|
||||
|
@ -31,13 +31,13 @@ namespace upm {
|
||||
|
||||
/**
|
||||
* @brief Analog Joystick library
|
||||
* @defgroup joystick libupm-joystick
|
||||
* @defgroup joystick12 libupm-joystick12
|
||||
* @ingroup generic analog ainput
|
||||
*/
|
||||
|
||||
/**
|
||||
* @library joystick
|
||||
* @sensor joystick
|
||||
* @library joystick12
|
||||
* @sensor joystick12
|
||||
* @comname Analog Joystick
|
||||
* @type ainput
|
||||
* @man generic
|
||||
|
@ -45,6 +45,7 @@ namespace upm {
|
||||
* @comname L298 Dual H-Bridge Motor Driver
|
||||
* @type motor
|
||||
* @man seeed sparkfun
|
||||
* @web https://www.sparkfun.com/products/9670
|
||||
* @con gpio pwm
|
||||
*
|
||||
* @brief API for the L298 Dual H-Bridge module
|
||||
@ -53,7 +54,12 @@ namespace upm {
|
||||
*
|
||||
* This module can support 2 DC motors, or 1 2-phase stepper motor.
|
||||
* It requires 3 pins per DC motor (or h-bridge), or 4 pins for
|
||||
* the stepper (uses both h-bridges).
|
||||
* the stepper (uses both h-bridges).
|
||||
*
|
||||
* @image html l298.jpg
|
||||
* <br><em>L298 Dual H-Bridge Motor Driver image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* Example driving a DC motor
|
||||
* @snippet l298.cxx Interesting
|
||||
|
@ -45,7 +45,7 @@ mraa_result_t
|
||||
I2CLcd::write(int row, int column, std::string msg)
|
||||
{
|
||||
setCursor(row, column);
|
||||
write(msg);
|
||||
return write(msg);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
|
@ -128,13 +128,16 @@ SSD1308::home()
|
||||
mraa_result_t
|
||||
SSD1308::writeChar(uint8_t value)
|
||||
{
|
||||
mraa_result_t rv;
|
||||
if (value < 0x20 || value > 0x7F) {
|
||||
value = 0x20; // space
|
||||
}
|
||||
|
||||
for (uint8_t idx = 0; idx < 8; idx++) {
|
||||
m_i2c_lcd_control.writeReg(LCD_DATA, BasicFont[value - 32][idx]);
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_DATA, BasicFont[value - 32][idx]);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
@ -148,6 +151,8 @@ SSD1308::setNormalDisplay()
|
||||
mraa_result_t
|
||||
SSD1308::setAddressingMode(displayAddressingMode mode)
|
||||
{
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, DISPLAY_CMD_MEM_ADDR_MODE); // set addressing mode
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, mode); // set page addressing mode
|
||||
mraa_result_t rv;
|
||||
rv =m_i2c_lcd_control.writeReg(LCD_CMD, DISPLAY_CMD_MEM_ADDR_MODE); // set addressing mode
|
||||
rv =m_i2c_lcd_control.writeReg(LCD_CMD, mode); // set page addressing mode
|
||||
return rv;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ SSD1327::home()
|
||||
return setCursor(0, 0);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
void
|
||||
SSD1327::setGrayLevel(uint8_t level)
|
||||
{
|
||||
grayHigh = (level << 4) & 0xF0;
|
||||
@ -236,6 +236,7 @@ SSD1327::setGrayLevel(uint8_t level)
|
||||
mraa_result_t
|
||||
SSD1327::writeChar(uint8_t value)
|
||||
{
|
||||
mraa_result_t rv = MRAA_SUCCESS;
|
||||
if (value < 0x20 || value > 0x7F) {
|
||||
value = 0x20; // space
|
||||
}
|
||||
@ -250,10 +251,11 @@ SSD1327::writeChar(uint8_t value)
|
||||
data |= (bitOne) ? grayHigh : 0x00;
|
||||
data |= (bitTwo) ? grayLow : 0x00;
|
||||
|
||||
m_i2c_lcd_control.writeReg(LCD_DATA, data);
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_DATA, data);
|
||||
usleep(CMD_SLEEP - 2000);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
@ -266,35 +268,39 @@ SSD1327::setNormalDisplay()
|
||||
mraa_result_t
|
||||
SSD1327::setHorizontalMode()
|
||||
{
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
||||
mraa_result_t rv = MRAA_SUCCESS;
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x42); // horizontal mode
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x42); // horizontal mode
|
||||
usleep(CMD_SLEEP);
|
||||
|
||||
// Row Address
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x75); // Set Row Address
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x75); // Set Row Address
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x00); // Start 0
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x00); // Start 0
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x5f); // End 95
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x5f); // End 95
|
||||
usleep(CMD_SLEEP);
|
||||
|
||||
// Column Address
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x15); // Set Column Address
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x15); // Set Column Address
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x08); // Start from 8th Column of driver
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x08); // Start from 8th Column of driver
|
||||
// IC. This is 0th Column for OLED
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x37); // End at (8 + 47)th column. Each
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x37); // End at (8 + 47)th column. Each
|
||||
// Column has 2 pixels(or segments)
|
||||
usleep(CMD_SLEEP);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setVerticalMode()
|
||||
{
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
||||
mraa_result_t rv = MRAA_SUCCESS;
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
||||
usleep(CMD_SLEEP);
|
||||
m_i2c_lcd_control.writeReg(LCD_CMD, 0x46); // Vertical mode
|
||||
rv = m_i2c_lcd_control.writeReg(LCD_CMD, 0x46); // Vertical mode
|
||||
usleep(CMD_SLEEP);
|
||||
return rv;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class SSD1327 : public I2CLcd
|
||||
* @param gray level from 0-255
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t setGrayLevel(uint8_t level);
|
||||
void setGrayLevel(uint8_t level);
|
||||
/**
|
||||
* Write a string to LCD
|
||||
*
|
||||
|
5
src/m24lr64e/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set (libname "m24lr64e")
|
||||
set (libdescription "upm m24lr64e grove NFC tag")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_h ${libname}.h)
|
||||
upm_module_init()
|
10
src/m24lr64e/jsupm_m24lr64e.i
Normal file
@ -0,0 +1,10 @@
|
||||
%module jsupm_m24lr64e
|
||||
%include "../upm.i"
|
||||
|
||||
%include "stdint.i"
|
||||
|
||||
%{
|
||||
#include "m24lr64e.h"
|
||||
%}
|
||||
|
||||
%include "m24lr64e.h"
|
290
src/m24lr64e/m24lr64e.cxx
Normal file
@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* 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 <unistd.h>
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "m24lr64e.h"
|
||||
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
|
||||
M24LR64E::M24LR64E(int bus, AccessMode mode):
|
||||
m_i2c(bus)
|
||||
{
|
||||
if (mode == USER_MODE)
|
||||
m_addr = M24LR64E_DEFAULT_I2C_ADDR;
|
||||
else
|
||||
m_addr = M24LR64E_DEFAULT_I2C_ADDR_E2;
|
||||
|
||||
mraa_result_t rv;
|
||||
if ( (rv = m_i2c.address(m_addr)) != MRAA_SUCCESS)
|
||||
{
|
||||
cerr << "M24LR64E: Could not initialize i2c address. " << endl;
|
||||
mraa_result_print(rv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
M24LR64E::~M24LR64E()
|
||||
{
|
||||
}
|
||||
|
||||
bool M24LR64E::submitPasswd(uint32_t passwd)
|
||||
{
|
||||
// this device actually uses two bytes to address a register
|
||||
const int pktLen = 11;
|
||||
uint8_t buf[pktLen];
|
||||
|
||||
buf[0] = 0x09;
|
||||
buf[1] = 0x00;
|
||||
|
||||
buf[2] = ((passwd >> 24) & 0xff);
|
||||
buf[3] = ((passwd >> 16) & 0xff);
|
||||
buf[4] = ((passwd >> 8) & 0xff);
|
||||
buf[5] = (passwd & 0xff);
|
||||
|
||||
buf[6] = 0x09;
|
||||
|
||||
// the password is written twice
|
||||
buf[7] = ((passwd >> 24) & 0xff);
|
||||
buf[8] = ((passwd >> 16) & 0xff);
|
||||
buf[9] = ((passwd >> 8) & 0xff);
|
||||
buf[10] = (passwd & 0xff);
|
||||
|
||||
if (m_i2c.write(buf, pktLen))
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool M24LR64E::writePasswd(uint32_t passwd)
|
||||
{
|
||||
const int pktLen = 11;
|
||||
uint8_t buf[pktLen];
|
||||
|
||||
buf[0] = 0x09;
|
||||
buf[1] = 0x00;
|
||||
|
||||
buf[2] = ((passwd >> 24) & 0xff);
|
||||
buf[3] = ((passwd >> 16) & 0xff);
|
||||
buf[4] = ((passwd >> 8) & 0xff);
|
||||
buf[5] = (passwd & 0xff);
|
||||
|
||||
buf[6] = 0x07;
|
||||
|
||||
// the password is written twice
|
||||
buf[7] = ((passwd >> 24) & 0xff);
|
||||
buf[8] = ((passwd >> 16) & 0xff);
|
||||
buf[9] = ((passwd >> 8) & 0xff);
|
||||
buf[10] = (passwd & 0xff);
|
||||
|
||||
if (m_i2c.write(buf, pktLen))
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void M24LR64E::sectorProtectConfig(unsigned int sectorNumber,
|
||||
bool protectEnable,
|
||||
SectorAccessRight accessRight,
|
||||
SectorSelectPassWd passwd)
|
||||
{
|
||||
if(!protectEnable) {
|
||||
EEPROM_Write_Byte(sectorNumber,0x0);
|
||||
} else {
|
||||
EEPROM_Write_Byte(sectorNumber,
|
||||
protectEnable | (accessRight<<1) |(passwd<<2));
|
||||
}
|
||||
}
|
||||
|
||||
void M24LR64E::clearSectorProtect(void)
|
||||
{
|
||||
uint8_t buf[64]={0x0};
|
||||
EEPROM_Write_Bytes(0, buf, 64);
|
||||
}
|
||||
|
||||
|
||||
void M24LR64E::sectorWriteLockBit(unsigned int sectorNumber,
|
||||
bool sockEnable)
|
||||
{
|
||||
unsigned int sectorAddress = SECTOR_SECURITY_STATUS_BASE_ADDR
|
||||
+ (sectorNumber/8);
|
||||
uint8_t sectorBit = sectorNumber % 8;
|
||||
uint8_t preStatus = EEPROM_Read_Byte(sectorAddress);
|
||||
|
||||
bool status = (preStatus >> sectorBit) & 0x01;
|
||||
if(status != sockEnable) {
|
||||
if(status == true) {
|
||||
writeByte(sectorAddress,preStatus&(~(1<<sectorBit)));
|
||||
} else {
|
||||
writeByte(sectorAddress,preStatus|(1<<sectorBit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t M24LR64E::getDSFID()
|
||||
{
|
||||
return EEPROM_Read_Byte(DSFID_ADDR);
|
||||
}
|
||||
|
||||
uint8_t M24LR64E::getAFI()
|
||||
{
|
||||
return EEPROM_Read_Byte(AFI_ADDR);
|
||||
}
|
||||
|
||||
void M24LR64E::getUID(uint8_t* buf)
|
||||
{
|
||||
EEPROM_Read_Bytes(UID_ADDR,buf,UID_LENGTH);
|
||||
}
|
||||
|
||||
uint32_t M24LR64E::getMemorySize()
|
||||
{
|
||||
uint32_t volume = 0x0;
|
||||
volume = EEPROM_Read_Byte(MEM_SIZE_ADDR);
|
||||
volume = volume<<8|EEPROM_Read_Byte(MEM_SIZE_ADDR+1);
|
||||
volume = volume<<8|EEPROM_Read_Byte(MEM_SIZE_ADDR+2);
|
||||
return volume;
|
||||
}
|
||||
|
||||
void M24LR64E::clearMemory()
|
||||
{
|
||||
for(int i = 0; i < EEPROM_I2C_LENGTH; i++){
|
||||
writeByte(i,0x0);
|
||||
}
|
||||
}
|
||||
|
||||
void M24LR64E::writeByte(unsigned int address, uint8_t data)
|
||||
{
|
||||
EEPROM_Write_Byte(address, data);
|
||||
}
|
||||
|
||||
void M24LR64E::writeBytes(unsigned int address, uint8_t* buf, unsigned int len)
|
||||
{
|
||||
EEPROM_Write_Bytes(address, buf, len);
|
||||
}
|
||||
|
||||
uint8_t M24LR64E::readByte(unsigned int address)
|
||||
{
|
||||
return EEPROM_Read_Byte(address);
|
||||
}
|
||||
|
||||
void M24LR64E::readBytes(unsigned int address, uint8_t* buf, unsigned int len)
|
||||
{
|
||||
EEPROM_Read_Bytes(address, buf, len);
|
||||
}
|
||||
|
||||
void M24LR64E::EEPROM_Write_Byte(unsigned int address, uint8_t data)
|
||||
{
|
||||
const int pktLen = 3;
|
||||
uint8_t buf[pktLen];
|
||||
|
||||
buf[0] = ((address >> 8) & 0xff);
|
||||
buf[1] = (address & 0xff);
|
||||
buf[2] = data;
|
||||
|
||||
if (m_i2c.write(buf, pktLen))
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
|
||||
usleep(I2C_WRITE_TIME * 1000);
|
||||
}
|
||||
|
||||
void M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
|
||||
unsigned int len)
|
||||
{
|
||||
const int pktLen = 2 + len;
|
||||
uint8_t buf[pktLen];
|
||||
|
||||
buf[0] = ((address >> 8) & 0xff);
|
||||
buf[1] = (address & 0xff);
|
||||
|
||||
for (int i=0; i<len; i++)
|
||||
buf[2+i] = data[i];
|
||||
|
||||
if (m_i2c.write(buf, pktLen))
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
|
||||
usleep(I2C_WRITE_TIME * 1000);
|
||||
}
|
||||
|
||||
uint8_t M24LR64E::EEPROM_Read_Byte(unsigned int address)
|
||||
{
|
||||
const int apktLen = 2;
|
||||
uint8_t abuf[apktLen];
|
||||
|
||||
abuf[0] = ((address >> 8) & 0xff);
|
||||
abuf[1] = (address & 0xff);
|
||||
|
||||
if (m_i2c.write(abuf, apktLen))
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
const int pktLen = 1;
|
||||
uint8_t buf[apktLen];
|
||||
|
||||
buf[0] = 0;
|
||||
|
||||
if (m_i2c.read(buf, pktLen) != pktLen)
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": read failed" << endl;
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
return buf[0];
|
||||
}
|
||||
|
||||
unsigned int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
|
||||
uint8_t* buf, unsigned int len)
|
||||
{
|
||||
const int apktLen = 2;
|
||||
uint8_t abuf[apktLen];
|
||||
|
||||
abuf[0] = ((address >> 8) & 0xff);
|
||||
abuf[1] = (address & 0xff);
|
||||
|
||||
if (m_i2c.write(abuf, apktLen))
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
int rv = m_i2c.read(buf, len);
|
||||
if (rv != len)
|
||||
{
|
||||
cerr << __FUNCTION__ << "@" << __LINE__ << ": read failed" << endl;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
283
src/m24lr64e/m24lr64e.h
Normal file
@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
*
|
||||
* This code was adapted from the Seeed Studio code at:
|
||||
* https://github.com/Seeed-Studio/NFC_Tag_M24LR6E
|
||||
*
|
||||
* Copyright (c) 2014 seeed technology inc.
|
||||
* Website : www.seeed.cc
|
||||
* Author : lawliet zou
|
||||
* Create Time: March 2014
|
||||
*
|
||||
* 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 <mraa/i2c.hpp>
|
||||
|
||||
#define M24LR64E_I2C_BUS 0
|
||||
#define M24LR64E_DEFAULT_I2C_ADDR 0x53
|
||||
#define M24LR64E_DEFAULT_I2C_ADDR_E2 (M24LR64E_DEFAULT_I2C_ADDR | 0x04)
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief Grove NFC Tag
|
||||
* @defgroup m24lr64e libupm-m24lr64e
|
||||
* @ingroup seeed i2c other
|
||||
*/
|
||||
|
||||
/**
|
||||
* @library m24lr64e
|
||||
* @sensor m24lr64e
|
||||
* @comname Grove NFC Tag
|
||||
* @type other
|
||||
* @man seeed
|
||||
* @web http://www.seeedstudio.com/wiki/Grove_-_NFC_Tag
|
||||
* @con i2c
|
||||
*
|
||||
* @brief C++ API for the M24LR64E based Grove NFC Tag
|
||||
*
|
||||
* The Grove NFC tag is, in essence, an 8KB EEPROM that can be written
|
||||
* to or read from using I2C and NFC equipped devices.
|
||||
*
|
||||
* The USER mode (default) allows read and write access to all 8KB
|
||||
* of space, provided the sector security status (SSS) allows it.
|
||||
* The ROOT mode allows modification of the SSS data and other
|
||||
* information, provided the proper password is submitted. The
|
||||
* default password for a new tag is 0x00000000. See the data sheet
|
||||
* for much more detailed information.
|
||||
*
|
||||
* The Seeed Studio wiki page for this device includes a link to an
|
||||
* Android application that can be used to also read and write the
|
||||
* device via NFC, as well as set the NFC passwords, which cannot be
|
||||
* done via I2C.
|
||||
*
|
||||
* @image html m24lr64e.jpg
|
||||
* @snippet m24lr64e.cxx Interesting
|
||||
*/
|
||||
class M24LR64E {
|
||||
public:
|
||||
|
||||
static const int EEPROM_I2C_LENGTH = 8192;
|
||||
static const int PASSWORD_LENGTH = 4;
|
||||
static const int SECTOR_SECURITY_STATUS_BASE_ADDR = 0x800; // 2048
|
||||
|
||||
static const uint8_t LOCK_PROTECT_BIT = 0x01;
|
||||
static const uint8_t WRITE_READ_PROTECT_BIT = 0x02;
|
||||
static const uint8_t PASSWORD_CTRL_BIT = 0x04;
|
||||
|
||||
static const int UID_LENGTH = 8; // bytes
|
||||
|
||||
static const unsigned int I2C_WRITE_TIME = 5; // 5ms
|
||||
|
||||
/**
|
||||
* M24LR64E addresses, accessable only in root mode
|
||||
*/
|
||||
typedef enum {
|
||||
I2C_PASSWORD_ADDR = 2304,
|
||||
RF_PASSWORD_1_ADDR = 2308, // RF pwds not available in
|
||||
RF_PASSWORD_2_ADDR = 2312, // i2c access modes
|
||||
RF_PASSWORD_3_ADDR = 2316,
|
||||
DSFID_ADDR = 2320, // 1 byte
|
||||
AFI_ADDR = 2321, // 1 byte
|
||||
RESV_ADDR = 2322, // 1 bytes
|
||||
CONFIG_ADDR = 2323, // 1 bytes
|
||||
UID_ADDR = 2324, // 8 bytes
|
||||
MEM_SIZE_ADDR = 2332, // 3 bytes
|
||||
IC_REF_ADDR = 2335, // 1 byte
|
||||
PROG_COMP_ENERGY_HARVEST_ADDR = 2339 // 1 byte
|
||||
} M24LR64E_ADDR_T;
|
||||
|
||||
enum AccessMode {
|
||||
USER_MODE = 0x0, // offer simple read/write access right
|
||||
ROOT_MODE = 0x1 // offer password change access right
|
||||
};
|
||||
|
||||
enum SectorAccessRight {
|
||||
// **********************************
|
||||
// * submit passWd * no submit *
|
||||
//b2,b1 * Read * Write * Read * Write *
|
||||
// 00 * 1 1 1 0 *
|
||||
// 01 * 1 1 1 1 *
|
||||
// 10 * 1 1 0 0 *
|
||||
// 11 * 0 1 0 0 *
|
||||
// **********************************
|
||||
Access_1110 = 0,
|
||||
Access_1111 = 1,
|
||||
Access_1100 = 2,
|
||||
Access_0111 = 3,
|
||||
};
|
||||
|
||||
enum SectorSelectPassWd {
|
||||
//00 => no passwd protect
|
||||
//01 => passWd 1
|
||||
//10 => passWd 2
|
||||
//11 => passwd 3
|
||||
noPasswd = 0,
|
||||
passwd_1 = 1,
|
||||
passwd_2 = 2,
|
||||
passwd_3 = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* m24lr64e constructor
|
||||
*
|
||||
* @param bus i2c bus to use
|
||||
* @param mode the access mode (user or root) to use
|
||||
*/
|
||||
M24LR64E(int bus, AccessMode mode = USER_MODE);
|
||||
|
||||
/**
|
||||
* M24LR64E Destructor
|
||||
*/
|
||||
~M24LR64E();
|
||||
|
||||
/**
|
||||
* submit an i2c access password
|
||||
*
|
||||
* @param passwd the 4-byte access password
|
||||
*/
|
||||
bool submitPasswd(uint32_t passwd);
|
||||
|
||||
/**
|
||||
* write a new i2c password
|
||||
*
|
||||
* @param passwd the 4-byte access password
|
||||
*/
|
||||
bool writePasswd(uint32_t passwd);
|
||||
|
||||
/**
|
||||
* Set the protection bit for a sector. Must be in ROOT mode
|
||||
*
|
||||
* @param sectorNumber the sector whose protection you are modifying
|
||||
* @param protectEnable true if you are enabling protection
|
||||
* @param accessRight the access rights to set
|
||||
* @param passwd the password number to enable, if any
|
||||
*/
|
||||
void sectorProtectConfig(unsigned int sectorNumber,
|
||||
bool protectEnable,
|
||||
SectorAccessRight accessRight,
|
||||
SectorSelectPassWd passwd);
|
||||
|
||||
/**
|
||||
* Clear the sector protection bits. Must be in ROOT mode.
|
||||
*/
|
||||
void clearSectorProtect(void);
|
||||
|
||||
/**
|
||||
* Set or clear the Sector Security Status Lock bit for a sector.
|
||||
* Must be in ROOT mode.
|
||||
*
|
||||
* @param sectorNumber the sector who's SSS you want to modify
|
||||
* @param sockEnable true r false to set or clear the bit
|
||||
*/
|
||||
void sectorWriteLockBit(unsigned int sectorNumber,
|
||||
bool sockEnable);
|
||||
|
||||
/**
|
||||
* return the Data Storage Familiy Identifier
|
||||
* Must be in ROOT mode.
|
||||
*
|
||||
* @return the DSFID
|
||||
*/
|
||||
uint8_t getDSFID();
|
||||
|
||||
/**
|
||||
* return the Application Family Identifier
|
||||
* Must be in ROOT mode.
|
||||
*
|
||||
* @return the AFI
|
||||
*/
|
||||
uint8_t getAFI();
|
||||
|
||||
/**
|
||||
* return the Unique ID.
|
||||
* Must be in ROOT mode.
|
||||
*
|
||||
* @param buf buffer to hold returned UID. Must be UID_LENGTH bytes.
|
||||
*/
|
||||
void getUID(uint8_t* buf);
|
||||
|
||||
/**
|
||||
* return the memory size
|
||||
* Must be in ROOT mode.
|
||||
*
|
||||
* @return the amount of memory present
|
||||
*/
|
||||
uint32_t getMemorySize();
|
||||
|
||||
/**
|
||||
* set all memory to 0, if permissions allow
|
||||
*/
|
||||
void clearMemory();
|
||||
|
||||
/**
|
||||
* write a byte to EEPROM
|
||||
*
|
||||
* @param address address to write to
|
||||
* @param data data to write
|
||||
*/
|
||||
void writeByte(unsigned int address, uint8_t data);
|
||||
|
||||
/**
|
||||
* write bytes to EEPROM
|
||||
*
|
||||
* @param address address to write to
|
||||
* @param data data to write
|
||||
* @param data length of data buffer
|
||||
*/
|
||||
void writeBytes(unsigned int address, uint8_t* buf, unsigned int len);
|
||||
|
||||
/**
|
||||
* read a byte from EEPROM
|
||||
*
|
||||
* @param address address to read from
|
||||
* @return data value read
|
||||
*/
|
||||
uint8_t readByte(unsigned int address);
|
||||
|
||||
/**
|
||||
* read multiple bytes from EEPROM
|
||||
*
|
||||
* @param address address to read from
|
||||
* @param buffer buffer to store data
|
||||
* @param len number of bytes to read
|
||||
*/
|
||||
void readBytes(unsigned int address, uint8_t* buf, unsigned int len);
|
||||
|
||||
protected:
|
||||
mraa::I2c m_i2c;
|
||||
void EEPROM_Write_Byte(unsigned int address, uint8_t data);
|
||||
void EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
|
||||
unsigned int len);
|
||||
uint8_t EEPROM_Read_Byte(unsigned int address);
|
||||
unsigned int EEPROM_Read_Bytes(unsigned int address,
|
||||
uint8_t* buf, unsigned int len);
|
||||
|
||||
private:
|
||||
uint8_t m_addr;
|
||||
};
|
||||
}
|
||||
|
||||
|
15
src/m24lr64e/pyupm_m24lr64e.i
Normal file
@ -0,0 +1,15 @@
|
||||
%module pyupm_m24lr64e
|
||||
%include "../upm.i"
|
||||
|
||||
%include "stdint.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
#ifdef DOXYGEN
|
||||
%include "m24lr64e_doc.i"
|
||||
#endif
|
||||
|
||||
%include "m24lr64e.h"
|
||||
%{
|
||||
#include "m24lr64e.h"
|
||||
%}
|
@ -44,6 +44,7 @@ namespace upm {
|
||||
* @altname EZ1, EZ2, EZ3, EZ4
|
||||
* @type sound
|
||||
* @man sparkfun
|
||||
* @web https://www.sparkfun.com/products/8502
|
||||
* @con analog
|
||||
*
|
||||
* @brief API for the LV-MaxSonar-EZ family of ultrasonic rangers
|
||||
@ -58,6 +59,11 @@ namespace upm {
|
||||
*
|
||||
* This driver was developed using an LV-MaxSonar-EZ3.
|
||||
*
|
||||
* @image html maxsonarez.jpg
|
||||
* <br><em>LV-MaxSonar-EZ Ultrasonic Ranger image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* @snippet maxsonarez.cxx Interesting
|
||||
*/
|
||||
|
||||
|
@ -42,7 +42,7 @@ MHZ16::MHZ16(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ MPU9150::getDeviceID () {
|
||||
return regData;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
void
|
||||
MPU9150::getData () {
|
||||
uint8_t buffer[14];
|
||||
|
||||
|
@ -159,7 +159,7 @@ class MPU9150 {
|
||||
* Get the Accelerometer, Gyro and Compass data from the chip and
|
||||
* save it in private section.
|
||||
*/
|
||||
mraa_result_t getData ();
|
||||
void getData ();
|
||||
|
||||
/**
|
||||
* @param data structure with 3 axis (x,y,z)
|
||||
|
@ -163,7 +163,7 @@ float OTP538U::objectTemperature()
|
||||
// add +2 to compensate for the -20C and -10C slots below zero
|
||||
int voltOffset = int(ambTemp / 10) + 1 + 2;
|
||||
float voltage = sensorVolts * 10.0;
|
||||
for (slot=0; slot<otp538u_vt_table_max; slot++)
|
||||
for (slot=0; slot<(otp538u_vt_table_max - 1); slot++)
|
||||
{
|
||||
if ( (voltage > otp538u_vt_table[slot][voltOffset]) &&
|
||||
(voltage < otp538u_vt_table[slot+1][voltOffset]) )
|
||||
|
@ -299,10 +299,8 @@ namespace upm {
|
||||
*
|
||||
* @param enabled true to enable restart, false to disable.
|
||||
* Default is enabled.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
bool enableRestart(bool enabled) { m_restartEnabled = enabled; };
|
||||
void enableRestart(bool enabled) { m_restartEnabled = enabled; };
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ void start_sampler (pulsensor_context * ctx) {
|
||||
int error;
|
||||
ctx_counter++;
|
||||
usleep (100000);
|
||||
error = pthread_create (&(ctx->sample_thread), NULL, do_sample, (void *) ctx);
|
||||
error = pthread_create (&(ctx->sample_thread), NULL, &do_sample, (void *) ctx);
|
||||
if (error != 0) {
|
||||
printf ("ERROR : Cannot created sampler thread.\n");
|
||||
}
|
||||
@ -144,4 +144,5 @@ void * do_sample (void * arg) {
|
||||
|
||||
usleep (2000);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ mraa_result_t Servo::setAngle (int angle) {
|
||||
}
|
||||
|
||||
m_currAngle = angle;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_result_t Servo::haltPwm () {
|
||||
|
@ -56,7 +56,12 @@ namespace upm {
|
||||
*
|
||||
* @brief API for SM130 RFID reader module
|
||||
*
|
||||
* This file defines the interface for sm130 RFID library
|
||||
* This file defines the interface for sm130 RFID library
|
||||
*
|
||||
* @image html sm130.jpg
|
||||
* <br><em>SM130 RFID Reader image provided by SparkFun under
|
||||
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
||||
* CC BY-NC-SA-3.0</a>.</em>
|
||||
*
|
||||
* @snippet sm130.cxx Interesting
|
||||
*/
|
||||
|
@ -79,13 +79,13 @@ StepMotor::setSpeed (int speed) {
|
||||
mraa_result_t
|
||||
StepMotor::stepForward (int ticks) {
|
||||
dirForward ();
|
||||
move (ticks);
|
||||
return move (ticks);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
StepMotor::stepBackwards (int ticks) {
|
||||
dirBackwards ();
|
||||
move (ticks);
|
||||
return move (ticks);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
|
@ -40,7 +40,7 @@ Ublox6::Ublox6(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ WT5001::WT5001(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ ZFM20::ZFM20(int uart)
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||
|
||||
if (!devPath)
|
||||
{
|
||||
|