Debian Codegraph @

plyer/platforms/ios/gyroscope.py

raw symbols SCIP
1 '''
2 iOS Gyroscope
3 ---------------------
4 '''
5
6 from plyer.facades import Gyroscope
7 from pyobjus import autoclass
8
9 from pyobjus.dylib_manager import load_framework
10
11 load_framework('/System/Library/Frameworks/UIKit.framework')
12 UIDevice = autoclass('UIDevice')
13
14 device = UIDevice.currentDevice()
15
16
17 class IosGyroscope(Gyroscope):
18
19 def __init__(self):
20 super().__init__()
21 self.bridge = autoclass('bridge').alloc().init()
22
23 if int(device.systemVersion.UTF8String().split('.')[0]) <= 4:
24 self.bridge.motionManager.setGyroscopeUpdateInterval_(0.1)
25 else:
26 self.bridge.motionManager.setGyroUpdateInterval_(0.1)
27
28 self.bridge.motionManager.setDeviceMotionUpdateInterval_(0.1)
29
30 def _enable(self):
31 self.bridge.startGyroscope()
32 self.bridge.startDeviceMotion()
33
34 def _disable(self):
35 self.bridge.stopGyroscope()
36 self.bridge.stopDeviceMotion()
37
38 def _get_orientation(self):
39 return (
40 self.bridge.rotation_rate_x,
41 self.bridge.rotation_rate_y,
42 self.bridge.rotation_rate_z)
43
44 def _get_rotation_uncalib(self):
45 return (
46 self.bridge.gy_x,
47 self.bridge.gy_y,
48 self.bridge.gy_z,
49 self.bridge.gy_x - self.bridge.rotation_rate_x,
50 self.bridge.gy_y - self.bridge.rotation_rate_y,
51 self.bridge.gy_z - self.bridge.rotation_rate_z)
52
53
54 def instance():
55 return IosGyroscope()