Skip to content

Commit

Permalink
3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lkasso committed Apr 10, 2021
1 parent be1a371 commit cdb9eb0
Show file tree
Hide file tree
Showing 97 changed files with 6,390 additions and 392 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# MetaWear Android API
The MetaWear Android API is a library for interacting with [MbientLab's sensor boards](https://mbientlab.com/sensors/) on an Android device. A minimum of Android 4.3 (SDK 18) is required to use this library, however for the best results, it is recommended that users be on **Android 4.4 (SDK 19) or
higher**.
The MetaWear Android API is a library for interacting with [MbientLab's sensor boards](https://mbientlab.com/sensors/) on an Android device. A minimum of Android 7.0 (SDK 24) is required to use this library, however for the best results, it is recommended that users be on **Android 10 (SDK 29) or higher**.

# Setup
## Adding Compile Dependency
Expand All @@ -20,7 +19,7 @@ Then, add the compile element to the dependencies closure in the module's ``buil

```gradle
dependencies {
compile 'com.mbientlab:metawear:3.4.0'
compile 'com.mbientlab:metawear:3.8.1'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
25 changes: 25 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="MetaWearAPI" default="publish" basedir="." >
<property name="dist.dir" value="dist" />
<property name="aar.dir" value="library/build/outputs/aar" />
<property name="aar.file" value="library-release.aar" />
<property name="artifact.file" value="metawear.aar" />
<property name="artifact.source.file" value="metawear-sources.jar" />

<target name="clean">
<delete dir="${dist.dir}" />
</target>
<target name="setup">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/${artifact.source.file}" basedir="library/src/main/java"/>
<copy file="${aar.dir}/${aar.file}" toFile="${dist.dir}/${artifact.file}"/>
</target>
<target name="ivy-resolve">
<ivy:resolve file="ivy.xml" />
</target>
<target name="publish" depends="ivy-resolve,setup" description="Publish this build into repository">
<ivy:publish pubrevision="${version}" resolver="publish-server" >
<artifacts pattern="${dist.dir}/[artifact](-[classifier]).[ext]"/>
</ivy:publish>
</target>
</project>
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
223 changes: 223 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " epub3 to make an epub3"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"

.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*

.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MetaWearAndroidAPI.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MetaWearAndroidAPI.qhc"

.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."

.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/MetaWearAndroidAPI"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MetaWearAndroidAPI"
@echo "# devhelp"

.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

.PHONY: epub3
epub3:
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."

.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."

.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
23 changes: 23 additions & 0 deletions docs/concepts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Automated Reconnect
^^^^^^^^^^^^^^^^^^^
If the `connectAsync` task fails or connection is lost, you can reconnect by calling `connectAsync` until it succeeds. retry the
You can retry connect attempts, even
If your app needs to maintain an active connection, you can continually try the `connectAsync` function until it succeeds. ::

public static Task<Void> reconnect(final MetaWearBoard board) {
return board.connectAsync().continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
if (task.isFaulted()) {
return reconnect(board);
}
return task;
}
});
}
::
public static Task<Void> reconnect(final MetaWearBoard board) {
return board.connectAsync().continueWithTask(task -> task.isFaulted() ? reconnect(board) : task);
}


15 changes: 15 additions & 0 deletions docs/source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "!layout.html" %}

{%- block extrahead %}
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40595645-1', 'auto');
ga('send', 'pageview');
</script>

<link rel="shortcut icon" href="../../images/favicon.ico">
{% endblock %}
78 changes: 78 additions & 0 deletions docs/source/accelerometer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.. highlight:: java

Accelerometer
=============
All MbientLab boards come with an accelerometer, a device which measure acceleration forces e.g. gravity and motion, accessed through the
`Accelerometer <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/module/Accelerometer.html>`_ interface.

Beecause there are different accelerometers used across the boards, the base ``Accelerometer`` interface was designed to be used with any accelerometer
thus it can only access the measured acceleration data. Developers building apps for specific MetaWear models should also review the
:ref:`Bosch Accelerometer` or :ref:`Mma8452q Accelerometer` sections`.

::

import com.mbietnlab.metawear.Accelerometer;

Accelerometer accelerometer= board.getModule(Accelerometer.class);

Global Enable
-------------
To retrieve data from the accelerometers, developers will also need to set a global enable bit with the ``Accelerometer`` level
`start <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/module/Accelerometer.html#start-->`_ function. The global ``start``
method must be called last, after all the sensor configuration has been set and async producers enabled. Conversly to return the accelerometer to
standby mode, call `stop <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/module/Accelerometer.html#stop-->`_.

::

// enable the sensor
// call last after configuring and enabling other data producers
accelerometer.start();

// disable the sensor
accelerometer.stop();

Configuration
-------------
It is important that you first set the output data rate and data range before using the accelerometer as these setings are typically global settings
that affect the configuration of other acceleromter features. To configure the accelerometer, call
`config <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/module/Accelerometer.html#configure-->`_ and use the returned editor object
to set the output data rate and range. As this is a generic editor interface, only float values are accepted and the actual settings used may not be
the same as the values passed in. ::

accelerometer.configure()
.odr(25f) // Set sampling frequency to 25Hz, or closest valid ODR
.range(4f) // Set data range to +/-4g, or closet valid range
.commit();

Log.i("MainActivity", "Actual Odr = " + accelerometer.getOdr());
Log.i("MainActivity", "Actual Range = " + accelerometer.getRange());

Acceleration Data
-----------------
The accelerometers provide access to the raw acceleration data they measure. Use the
`acceleration <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/module/Accelerometer.html#acceleration-->`_ method to get the
``AsyncDataProducer`` object controlling the acceleration data. Then, setup a data route to handle the dadta, and finally, start the accelerometer.

Raw acceleration data is represented by the API as a
`Acceleration <https://mbientlab.com/docs/metawear/android/latest/com/mbientlab/metawear/data/Acceleration.html>`_ type.

::

accelerometer.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteElement source) {
source.stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("MainActivity", data.value(Acceleration.class).toString());
}
});
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
accelerometer.acceleration().start();
accelerometer.start();
return null;
}
});
Loading

0 comments on commit cdb9eb0

Please sign in to comment.