File: spatialorientation.py

package info (click to toggle)
python-plyer 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,808 kB
  • sloc: python: 13,395; sh: 217; makefile: 177
file content (54 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# coding=utf-8


class SpatialOrientation:
    '''Spatial Orientation facade.

    Computes the device's orientation based on the rotation matrix.

    .. versionadded:: 1.3.1
    '''

    @property
    def orientation(self):
        '''Property that returns values of the current device orientation
        as a (azimuth, pitch, roll) tuple.

        Azimuth, angle of rotation about the -z axis. This value represents the
        angle between the device's y axis and the magnetic north pole.
        The range of values is -π to π.

        Pitch, angle of rotation about the x axis. This value represents the
        angle between a plane parallel to the device's screen and a plane
        parallel to the ground.
        The range of values is -π to π.

        Roll, angle of rotation about the y axis. This value represents the
        angle between a plane perpendicular to the device's screen and a plane
        perpendicular to the ground.
        The range of values is -π/2 to π/2.

        Returns (None, None, None) if no data is currently available.

        Supported Platforms:: Android
        '''
        return self._get_orientation() or (None, None, None)

    def _get_orientation(self):
        raise NotImplementedError()

    def enable_listener(self):
        '''Enable the orientation sensor.
        '''
        self._enable_listener()

    def _enable_listener(self, **kwargs):
        raise NotImplementedError()

    def disable_listener(self):
        '''Disable the orientation sensor.
        '''
        self._disable_listener()

    def _disable_listener(self, **kwargs):
        raise NotImplementedError()