3.9.2.4 class AccelerometerDoubleTappingData

Class Attribute

Direction: Hex value indicating the tap direction. The direction can be determined in human readable form using get_logicalname API and class name as AccelerometerDirection.

Set/Get Property

This sensor class provides additional functions that can be used to set or get some of the properties specific to this sensor.

The following table lists the set/get properties of the sensor class:

Set/Get properties Description
get_axis_active() Returns x, y, z values: 1 if axis is active else 0.
set_axis_active([x=None, y=None, z=None]) Sets one or more axis as active. Pass 1 to set the axis and 0 to disable it.
get_properties() Returns a dictionary with "DoubleTapThreshold", "DoubleTapDuration", "DoubleTapLatency", "DoubleTapInterval" as the keys and their respective values.
set_properties([DoubleTapThreshold = None, DoubleTapDuration = None, DoubleTapLatency = None, DoubleTapInterval = None]) Sets the tap related properties.

Example

from sensor import *
import e32


class DemoApp():

    def __init__(self):
        self.doubletap = AccelerometerDoubleTappingData()
        self.doubletap.set_axis_active(x=0, y=1, z=1)
        print "Active Axis are: ", self.doubletap.get_axis_active()
        self.doubletap.set_callback(data_callback=self.my_callback)

    def my_callback(self):
        print "Raw Direction value:", self.doubletap.direction
        print "Direction:", get_logicalname(AccelerometerDirection,
                                             self.doubletap.direction)
        print "Timestamp:", self.doubletap.timestamp

    def run(self):
        self.doubletap.start_listening()

if __name__ == '__main__':
    d = DemoApp()
    d.run()
    e32.ao_sleep(15)
    d.doubletap.stop_listening()
    print "Exiting Double Tap"

See About this document... for information on suggesting changes.