| 1 | ''' |
| 2 | iOS Gravity |
| 3 | ----------- |
| 4 | |
| 5 | ''' |
| 6 | |
| 7 | from plyer.facades import Gravity |
| 8 | from pyobjus import autoclass |
| 9 | |
| 10 | |
| 11 | class iOSGravity(Gravity): |
| 12 | |
| 13 | def __init__(self): |
| 14 | self.bridge = autoclass('bridge').alloc().init() |
| 15 | self.bridge.motionManager.setDeviceMotionUpdateInterval_(0.1) |
| 16 | |
| 17 | def _enable(self): |
| 18 | self.bridge.startDeviceMotion() |
| 19 | |
| 20 | def _disable(self): |
| 21 | self.bridge.stopDeviceMotion() |
| 22 | |
| 23 | def _get_gravity(self): |
| 24 | return ( |
| 25 | self.bridge.g_x, |
| 26 | self.bridge.g_y, |
| 27 | self.bridge.g_z) |
| 28 | |
| 29 | |
| 30 | def instance(): |
| 31 | return iOSGravity() |