The following classes are provided by the Sensor module:
The Sensor class represents a physical sensor which delivers (possibly filtered) events. By default, events are not filtered. A filter can be applied by using the set_event_filter method. An example for an event filter is given by OrientationEventFilter, which can be applied to an acceleration sensor of the device.
In case different filters must be used for the same physical sensor, different Sensor objects have to be created for the same physical sensor.
sensor_id, category_id) |
sensor_id
and category_id
must represent a valid sensor id and category id, respectively. This means that
the ids passed on to __init__
must also appear in the dictionary returned by
the sensors
function.
In case sensor_id
and category_id
do not represent a valid sensor,
the connect
method will raise an exception.
callback) |
callback
. A sensor can only be connected
to one callback, so this will destroy any pre-existing connection to another callback.
If an event filter has been set, the events passed on to callback
will first pass
this event filter of the Sensor object.
If the connection is properly established, this method returns 1, otherwise 0.
Note: The connection can be established also if the callback does not exist or cannot be
called for any other reason.
) |
) |
True
if the sensor is connected, False
otherwise.
event_filter) |
event_filter
must be derived
from EventFilter in order to function properly.
If a callback connection has already been established before calling this method,
the connection will be re-established after the event filter has been installed.
The EventFilter class provides a generic interface for event filters. The default implementation only passes events on, that is, events are not filtered. Classes deriving from EventFilter can decide if an event should be delivered at all as well as they can alter the data that is passed on to the callback.
) |
callback
member is initialised to
None
.
) |
data) |
data
or any other set of data.
In case the event is decided to be delivered, overriding instances must
call self.callback
, which by default takes one argument.
) |
Derived from EventFilter.
This event filter is meant to be used together with the acceleration
sensors of the device. Note that it is not required to use it with any other sensor
type. It generates events when the devices orientation changes. For example, if it
is turned from the upright position to lying on the back side.
If an OrientationEventFiler is used with a Sensor object,
the callback of the Sensor object will not receive the raw acceleration data
as an argument, but only one of the orientation
constants, representing
the new orientation of the device. In case the algorithm needs calibration on the
device to be used, you must check the OrientationCalibration
variables
in the file sensor.py
.
) |
sensor_val) |
orientation
constants of this module.
) |
Derived from EventFilter.
This event filter generates events when the devices orientation changes. For example, if it is turned from the left side up position to right side up position. This sensor is resident. For example, in Nokia N95.
sensor_val) |
orientation
constants.
See About this document... for information on suggesting changes.