Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkasso committed Mar 25, 2021
1 parent 97598a9 commit a71ac0a
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 5 deletions.
135 changes: 132 additions & 3 deletions docs/source/accelerometer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ necessary. ::
break;
MBL_MW_MODULE_ACC_TYPE_BMA255:
break;
MBL_MW_MODULE_ACC_TYPE_BMI270:
break;
MBL_MW_MODULE_TYPE_NA:
break;
default:
Expand Down Expand Up @@ -79,6 +81,121 @@ and is only for streaming; do not use it with data processing or logging. ::
libmetawear.mbl_mw_acc_enable_acceleration_sampling(board)
libmetawear.mbl_mw_acc_start(board)

Wrist Wear Gestures
---------------------
The BMI270 is designed for Wear OS by GoogleTM7 and features wrist gestures such as flick in/out, push arm down/pivot up, wrist jiggle/shake that help navigate the smartwatch.

See https://support.google.com/wearos/answer/6312406?hl=en

For flick-in detection, the user must slowly turn the wrist away from the body (i.e. roll-out shown with a light-grey arrow in) and then quickly bring it back (i.e. roll-in shown with a darker-black arrow in to its original position.

For flick-out detection, the user must quickly turn the wrist away from the body (i.e. roll-out shown with a darker-black arrow in above picture) and then slowly bring it back (i.e. roll-in shown with a light-grey arrow in above picture) to its original position.

The speed of the roll-out and roll-in movements determine if the user performed a flick-in or a flick-out movement. ::

// Start the accelerometer
libmetawear.mbl_mw_acc_start(board)
// Configure
libmetawear.mbl_mw_acc_bmi270_wrist_gesture_armside(board, 0) // left arm
libmetawear.mbl_mw_acc_bmi270_write_wrist_gesture_config(board)
// Get gesture signal
gesture_signal = libmetawear.mbl_mw_acc_bmi270_get_wrist_detector_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(gesture_sig, None, sensor_data_handler)
// Start detecting motion and turn on acc
libmetawear.mbl_mw_acc_bmi270_enable_wrist_gesture(board)
There are config functions for the wrist wear feature: ::

libmetawear.mbl_mw_acc_bmi270_wrist_gesture_peak()
libmetawear.mbl_mw_acc_bmi270_wrist_gesture_samples()
libmetawear.mbl_mw_acc_bmi270_wrist_gesture_duration()

Activity Detector
------------------
The BMI270 can detect simple user activities (unknown, still, walking, running) and can send an interrupt if those are changed, e.g. from walking to running or vice versus. ::

// Start the accelerometer
libmetawear.mbl_mw_acc_start(board)
// Get activity signal
activity_sig = libmetawear.mbl_mw_acc_bmi270_get_activity_detector_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(activity_sig, None, sensor_data_handler)
// Start detecting motion and turn on acc
libmetawear.mbl_mw_acc_bmi270_enable_activity_detection(board)

Wrist Wear Wakeup
----------------------
The BMI270 has a wrist wear wakeup feature that is designed to detect any natural way of user moving the hand to see the watch dial when wearing a classical wrist watch.

The feature is intended to be used as wakeup gesture (i.e. for triggering screen-on or screen-off) in wrist wearable devices.

This feature has dependency on the device orientation in the user system. Implementation of the feature to detect gesture assumes that the sensor co-ordinate frame is aligned with the device/system co- ordinate frame. The assumed default device/system co-ordinate frame is depicted below.

Please refer to `this section <https://mbientlab.com/documents/metawear/cpp/latest/accelerometer__bosch_8h.html#aca2fa97988a33550e20b02c816c6b91f>`_ regarding axis remapping. ::

// Start the accelerometer
libmetawear.mbl_mw_acc_start(board)
// Get gesture signal
wrist_sig = libmetawear.mbl_mw_acc_bmi270_get_wrist_detector_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(wrist_sig, None, sensor_data_handler)
// Start detecting motion and turn on acc
libmetawear.mbl_mw_acc_bmi270_enable_wrist_wakeup(board)
There are config functions for the wrist wear feature: ::

libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_angle_focus()
libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_angle_nonfocus()
libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_tilt_lr()
libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_tilt_ll()
libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_tilt_pd()
libmetawear.mbl_mw_acc_bmi270_wrist_wakeup_tilt_pu()

Motion Detector
----------------
The BMI270 can detect significant motion (android motion), any motion (high acc motion) or no motion. The accelerometer must be at least running at 25Hz.

Detect Any Motion
^^^^^^^^^^^^^^^^^^^
The anymotion detection uses the slope between two acceleration signals to detect changes in motion. ::

// Start the accelerometer
libmetawear.mbl_mw_acc_start(board)
// Set any motion config - acc must be on for this
libmetawear.mbl_mw_acc_bosch_set_any_motion_count(board, 5)
libmetawear.mbl_mw_acc_bosch_set_any_motion_threshold(board, 170.0)
libmetawear.mbl_mw_acc_bosch_write_motion_config(board, MBL_MW_ACC_BOSCH_MOTION_ANYMOTION)
// Get any motion signal
any_motion = libmetawear.mbl_mw_acc_bosch_get_motion_data_signal(board);
libmetawear.mbl_mw_datasignal_subscribe(any_motion, None, sensor_data_handler)
// Start detecting motion
libmetawear.mbl_mw_acc_bosch_enable_motion_detection(board, MBL_MW_ACC_BOSCH_MOTION_ANYMOTION)
Detect No Motion
^^^^^^^^^^^^^^^^^^^
The nomotion detection can detect when there is no motion for a certain amount of time. ::

libmetawear.mbl_mw_acc_start(board)
libmetawear.mbl_mw_acc_bosch_set_no_motion_count(board, 5)
libmetawear.mbl_mw_acc_bosch_set_no_motion_threshold(board, 144.0)
libmetawear.mbl_mw_acc_bosch_write_motion_config(board, MBL_MW_ACC_BOSCH_MOTION_NOMOTION)
no_motion = libmetawear.mbl_mw_acc_bosch_get_motion_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(no_motion, None, sensor_data_handler)
libmetawear.mbl_mw_acc_bosch_enable_motion_detection(board, MBL_MW_ACC_BOSCH_MOTION_NOMOTION)

Detect Significant Motion
^^^^^^^^^^^^^^^^^^^^^^^^^^
The significant motion interrupt implements the interrupt required for motion detection in Android 4.3 and greater: https://source.android.com/devices/sensors/sensor-types.html#significant_motion.
A significant motion is a motion due to a change in the user location.

Examples of such significant motions are walking or biking, sitting in a moving car, coach or train, etc.
Examples of situations that does typically not trigger significant motion include phone in pocket and person is stationary or phone is at rest on a table which is in normal office use. . ::
libmetawear.mbl_mw_acc_start(board)
libmetawear.mbl_mw_acc_bosch_set_sig_motion_blocksize(board, 250)
libmetawear.mbl_mw_acc_bosch_write_motion_config(board, MBL_MW_ACC_BOSCH_MOTION_SIGMOTION)
sig_motion = libmetawear.mbl_mw_acc_bosch_get_motion_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(sig_motion, None, sensor_data_handler)
libmetawear.mbl_mw_acc_bosch_enable_motion_detection(board, MBL_MW_ACC_BOSCH_MOTION_SIGMOTION)

Step Counter
------------
The BMI160 accelerometer comes with a built in step counter. It has three operation modes that configure the sensitivity and robustness of the counter:
Expand All @@ -98,6 +215,8 @@ When you have set the operation mode, call
libmetawear.mbl_mw_acc_bmi160_enable_step_counter(board)
libmetawear.mbl_mw_acc_bmi160_write_step_counter_config(board)

The BMI270 accelerometer does not support step counter modes.

Reading The Counter
^^^^^^^^^^^^^^^^^^^
One way to retrieve step counts is to periodcally read the step counter. To read the step counter, call
Expand All @@ -111,6 +230,8 @@ The counter is not enabled by default so you will need enable it by calling
libmetawear.mbl_mw_datasignal_subscribe(step_counter_signal, None, sensor_data_handler)
libmetawear.mbl_mw_datasignal_read(step_counter_signal)

For the BMI270, you can call `mbl_mw_acc_bmi270_enable_step_counter <https://mbientlab.com/documents/metawear/cpp/latest/accelerometer__bosch_8h.html#a48e850d6bdb4b7084c735885465fc1c7>`_ when configuring the board.

Using The Detector
^^^^^^^^^^^^^^^^^^
Alternatively, you can receive notifications for each step detected by calling
Expand All @@ -119,14 +240,22 @@ Alternatively, you can receive notifications for each step detected by calling
step_detector_signal= libmetawear.mbl_mw_acc_bmi160_get_step_detector_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(step_detector_signal, None, sensor_data_handler)

For the BMI270, the detector will not send notifications every step but instead every 20*X steps: ::

libmetawear.mbl_mw_acc_start(board)
libmetawear.mbl_mw_acc_bmi270_set_step_counter_trigger(board, 1) //every 20 steps
libmetawear.mbl_mw_acc_bmi270_write_step_counter_config(board)
libmetawear.mbl_mw_acc_bmi270_reset_step_counter(board)
detector = libmetawear.mbl_mw_acc_bmi270_get_step_detector_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(detector, None, sensor_data_handler)
libmetawear.mbl_mw_acc_bmi270_enable_step_counter(board)

Orientation Detection
---------------------
The orientation detector alerts you when the sensor's orientation changes between portrait/landscape and front/back. Data is represented as an
`MblMwSensorOrientation <https://mbientlab.com/docs/metawear/cpp/0/types_8h.html#a2e83167b55d36e1d48d100f342ad529c>`_ enum.

This feature is currently only supported on devices using the BMI160 or BMA255 accelerometers.

::
This feature is currently only supported on devices using the BMI160 or BMA255 accelerometers. It is not supported on the BMI270. ::

orientation = libmetawear.mbl_mw_acc_bosch_get_orientation_detection_data_signal(board)
libmetawear.mbl_mw_datasignal_subscribe(orientation, None, sensor_data_handler)
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '1.0.0'
version = '1.0.1'
# The full version, including alpha/beta/rc tags.
release = '1.0.0'
release = '1.0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
10 changes: 10 additions & 0 deletions docs/source/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ Once we are done logging, simply call: ::

libmetawear.mbl_mw_logging_stop(board)

Note for the MMS
----------------
The MMS (MetaMotionS) board uses NAND flash memory to store data on the device itself. The NAND memory stores data in pages that are 512 entries large. When data is retrieved, it is retrieved in page sized chunks.

Before doing a full download of the log memory on the MMS, the final set of data needs to be written to the NAND flash before it can be downloaded as a page. To do this, you must call the function: ::

libmetawear.mbl_mw_logging_flush_page(board)

This should not be called if you are still logging data.

Downloading Data
----------------
When you are ready to retrieve the data, execute
Expand Down
14 changes: 14 additions & 0 deletions docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@ A more detailed explanation of about BTLE connection parameters can be found on
`post <https://devzone.nordicsemi.com/question/60/what-is-connection-parameters/>`_ from the Nordic Developer Zone forums. ::

libmetawear.mbl_mw_settings_set_connection_parameters(self.board, 750.0, 1000.0, 128, 16384)

MMS 3V Regulator
---------------------
The MMS (MetaMotion) board has a 3V regulator that can be turned on and off for IOs.

It is automatically turned on to power the coin vibration motor (if there is one attached), the ambient light sensor, and the LED.

However, if you have an external peripheral on the IOs that needs 3V power (such as a buzzer or UV sensor), you can use this function to turn on the power: ::

libmetawear.mbl_mw_settings_enable_3V_regulator(board, 1)

And to turn it off: ::

libmetawear.mbl_mw_settings_enable_3V_regulator(board, 0)

0 comments on commit a71ac0a

Please sign in to comment.