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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
'''
Gyroscope
============
The gyroscope measures the rate of rotation around a device's x, y,
and z axis.
The :class:`Gyroscope` provides access to public methods to
use gyroscope of your device.
Simple Examples
---------------
To enable gyroscope::
>>> from plyer import gyroscope
>>> gyroscope.enable()
To disable gyroscope::
>>> gyroscope.disable()
To get the rate of rotation along the three axes::
>>> gyroscope.rotation
(-0.0034587313421070576, -0.0073830625042319298, 0.0046892408281564713)
To get the uncalibrated rate of rotation along the three axes along with the
drift compensation::
>>> gyroscope.rotation_uncalib
()
where the first three values show the rate of rotation w/o drift
compensation and the last three show the estimated drift along the three
axes.
Supported Platforms
-------------------
Android, iOS
'''
class Gyroscope:
'''
Gyroscope facade.
.. versionadded:: 1.3.1
'''
@property
def rotation(self):
'''
Property that returns the rate of rotation around the device's local
X, Y and Z axis.
Along x-axis: angular speed around the X axis
Along y-axis: angular speed around the Y axis
Along z-axis: angular speed around the Z axis
Returns (None, None, None) if no data is currently available.
'''
return self.get_orientation()
@property
def rotation_uncalib(self):
'''
Property that returns the current rate of rotation around the X, Y and
Z axis. An estimation of the drift on each axis is reported as well.
Along x-axis: angular speed (w/o drift compensation) around the X axis
Along y-axis: angular speed (w/o drift compensation) around the Y axis
Along z-axis: angular speed (w/o drift compensation) around the Z axis
Along x-axis: estimated drift around X axis
Along y-axis: estimated drift around Y axis
Along z-axis: estimated drift around Z axis
Returns (None, None, None, None, None, None) if no data is currently
available.
'''
return self.get_rotation_uncalib()
@property
def orientation(self):
'''
WARNING:: This property is deprecated after API Level 8.
Use `gyroscope.rotation` instead.
Property that returns values of the current Gyroscope sensors, as
a (x, y, z) tuple. Returns (None, None, None) if no data is currently
available.
'''
return self.get_orientation()
def enable(self):
'''
Activate the Gyroscope sensor.
'''
self._enable()
def disable(self):
'''
Disable the Gyroscope sensor.
'''
self._disable()
def get_orientation(self):
return self._get_orientation()
def get_rotation_uncalib(self):
return self._get_rotation_uncalib()
# private
def _enable(self):
raise NotImplementedError()
def _disable(self):
raise NotImplementedError()
def _get_orientation(self):
raise NotImplementedError()
def _get_rotation_uncalib(self):
raise NotImplementedError()
|