Debian Codegraph @

plyer/facades/accelerometer.py

raw symbols SCIP
1 '''
2 Accelerometer
3 ============
4
5 The accelerometer is a motion sensor that detects the change (delta) in
6 movement relative to the current device orientation, in three dimensions
7 along the x, y, and z axis.
8
9 The :class:`Accelerometer` provides access to public methods to
10 use accelerometer of your device.
11
12 Simple Examples
13 ---------------
14
15 To enable accelerometer::
16
17 >>> from plyer import accelerometer
18 >>> accelerometer.enable()
19
20 To disable accelerometer::
21
22 >>> accelerometer.disable()
23
24 To get the acceleration::
25
26 >>> accelerometer.acceleration
27 (-10.048464775085449, 6.825869083404541, 7.7260890007019043)
28
29 Supported Plaforms
30 ------------------
31 Android, iOS, OS X, Linux
32
33 '''
34
35
36 class Accelerometer:
37 '''
38 Accelerometer facade.
39 '''
40
41 @property
42 def acceleration(self):
43 '''
44 Property that returns values of the current acceleration
45 sensors, as a (x, y, z) tuple. Returns (None, None, None)
46 if no data is currently available.
47 '''
48 return self.get_acceleration()
49
50 def enable(self):
51 '''
52 Activate the accelerometer sensor. Throws an error if the
53 hardware is not available or not implemented on.
54 '''
55 self._enable()
56
57 def disable(self):
58 '''
59 Disable the accelerometer sensor.
60 '''
61 self._disable()
62
63 def get_acceleration(self):
64 return self._get_acceleration()
65
66 # private
67
68 def _enable(self):
69 raise NotImplementedError()
70
71 def _disable(self):
72 raise NotImplementedError()
73
74 def _get_acceleration(self):
75 raise NotImplementedError()