summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/ios/compass.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/plyer/platforms/ios/compass.py')
-rw-r--r--external/plyer/platforms/ios/compass.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/external/plyer/platforms/ios/compass.py b/external/plyer/platforms/ios/compass.py
new file mode 100644
index 0000000..6e5c935
--- /dev/null
+++ b/external/plyer/platforms/ios/compass.py
@@ -0,0 +1,31 @@
+'''
+iOS Compass
+---------------------
+'''
+
+from plyer.facades import Compass
+from pyobjus import autoclass
+
+
+class IosCompass(Compass):
+
+ def __init__(self):
+ super(IosCompass, self).__init__()
+ self.bridge = autoclass('bridge').alloc().init()
+ self.bridge.motionManager.setMagnetometerUpdateInterval_(0.1)
+
+ def _enable(self):
+ self.bridge.startMagnetometer()
+
+ def _disable(self):
+ self.bridge.stopMagnetometer()
+
+ def _get_orientation(self):
+ return (
+ self.bridge.mg_x,
+ self.bridge.mg_y,
+ self.bridge.mg_z)
+
+
+def instance():
+ return IosCompass()