Debian Codegraph @

plyer/facades/compass.py

raw symbols SCIP
1 '''
2 Compass
3 =======
4
5 The :class:`Compass` provides access to public methods to use compass of your
6 device.
7
8 Simple Examples
9 ---------------
10
11 To enable compass::
12
13 >>> from plyer import compass
14 >>> compass.enable()
15
16 To disable compass::
17
18 >>> compass.disable()
19
20 To get the field::
21
22 >>> compass.field()
23 (-23.721826553344727, -5.7114701271057129, -36.749668121337891)
24
25 To get the uncalibrated field along with iron bias estimation::
26
27 >>> compass.field_uncalib()
28 (a,b,c,x,y,z)
29 # a,b,c denote the Geomagnetic field strength
30 # (without hard iron calibration) along the three axes.
31 # x,y,z denote the Iron bias estimation along the three axes.
32
33 Supported Platforms
34 -------------------
35 Android, iOS
36
37 '''
38
39
40 class Compass:
41 '''Compass facade.
42
43 .. versionadded:: 1.2.0
44 '''
45
46 @property
47 def orientation(self):
48 '''
49 WARNING:: This property is deprecated after API level 8.
50 Use `compass.field` instead.
51
52 Property that returns values of the current compass
53 (magnetic field) sensors, as a (x, y, z) tuple.
54 Returns (None, None, None) if no data is currently available.
55 '''
56 return self.get_orientation()
57
58 @property
59 def field(self):
60 '''
61 .. versionadded:: 1.3.1
62
63 Property that returns values of the current compass
64 (magnetic field) sensors, as a (x, y, z) tuple.
65 Returns (None, None, None) if no data is currently available.
66 '''
67 return self.get_orientation()
68
69 @property
70 def field_uncalib(self):
71 '''
72 .. versionadded:: 1.3.1
73
74 Property that returns the current value of Uncalibrated Magnetic Field
75 (without hard iron calibration) along with the iron bias estimation
76 along the three axes.
77 '''
78 return self.get_field_uncalib()
79
80 def enable(self):
81 '''
82 Activate the compass sensor.
83 '''
84 self._enable()
85
86 def disable(self):
87 '''
88 Disable the compass sensor.
89 '''
90 self._disable()
91
92 def get_orientation(self):
93 return self._get_orientation()
94
95 def get_field_uncalib(self):
96 '''
97 .. versionadded:: 1.3.1
98 '''
99 return self._get_field_uncalib()
100
101 # private
102
103 def _enable(self):
104 raise NotImplementedError()
105
106 def _disable(self):
107 raise NotImplementedError()
108
109 def _get_orientation(self):
110 raise NotImplementedError()
111
112 def _get_field_uncalib(self):
113 raise NotImplementedError()