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 a device's acceleration sensor.
In case different filters should 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 pass
this Sensor object's event filter first.
If the connection was 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, i.e. 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 should
call self.callback, which by default takes one argument.
| ) |
Derived from EventFilter.
This event filter is meant to be used together with the device's acceleration
sensors. Note that it does not make sense to use it with any other sensor
type. It generates events when the devices orientation changes, e.g. if it
is turned from the upright position to lying on the back side.
If an OrientationEventFiler is used with a Sensor object,
the Sensor object's callback will not receive the raw acceleration data
as an argument, but only one of the orientation constants, representing
the device's new orientation. In case the algorithm needs calibration on the
device to be used, please check the OrientationCalibration variables
in the file sensor.py.
| ) |
| sensor_val) |
orientation constants.
| ) |
Derived from EventFilter.
This event filter generates events when the devices orientation changes, e.g. if it is turned from the left side up position to right side up position. This sensor is resident e.g. in Nokia N95.
| sensor_val) |
orientation constants.
See About this document... for information on suggesting changes.