From db20a5c24775e1c4ab5bb112d09ce4873f54feb5 Mon Sep 17 00:00:00 2001 From: Clay Murphy Date: Wed, 4 Jun 2014 11:19:27 -0700 Subject: Docs: Adding example of period_ns to on-change entry. Bug: 15314263 Change-Id: Icca772f999583c8d10098cfd8f1e5d822ba7cf1e --- src/devices/sensors/base_triggers.jd | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/devices/sensors/base_triggers.jd b/src/devices/sensors/base_triggers.jd index 1d2bd78a..81d25477 100644 --- a/src/devices/sensors/base_triggers.jd +++ b/src/devices/sensors/base_triggers.jd @@ -28,16 +28,25 @@ page.title=Base sensors and trigger modes

Sensors can report events in different ways called trigger modes; each sensor type has one and only one trigger mode associated to it. Four trigger modes exist:

+

Continuous

Events are reported at a constant rate defined by setDelay(). Example sensors using the continuous trigger mode are accelerometers and gyroscopes.

+

On-change

-

Events are reported only if the sensor's value has changed. setDelay() is used - to set a lower limit to the reporting period, meaning the minimum time between - consecutive events. Activating the sensor also triggers an event. The HAL must - return an event immediately when an on-change sensor is activated. Example - sensors using the on-change trigger mode are the step counter and proximity - sensor types.

+

Events are reported only if the sensor's value has changed. Activating the +sensor also triggers an event, meaning the HAL must return an event immediately +when an on-change sensor is activated. Example sensors using the on-change +trigger mode are the step counter and proximity sensor types.

+ +

Here is how the period_ns parameter affects setDelay(...) and +batch(...). The period_ns parameter is used to set a lower limit +to the reporting period, meaning the minimum time between consecutive events. +Here is an example: If activating the step counter with period_ns = 10 seconds, +walking for 1 minute, and then not walking for 1 minute, the events will +be generated every 10 seconds during the first minute, and no event will be +generated in the second minute.

+

One-shot

Upon detection of an event, the sensor deactivates itself and then sends a single event. Order matters to avoid race conditions. No other event is sent -- cgit v1.2.3