blob: 6e5c9350b4b304a5f0d4b08b20094463d178a964 (
plain) (
blame)
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
|
'''
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()
|