Sideband/sbapp/plyer/platforms/ios/gravity.py

32 lines
588 B
Python
Raw Normal View History

2022-09-16 10:07:57 -06:00
'''
iOS Gravity
-----------
'''
2024-06-02 10:31:58 -06:00
from sbapp.plyer.facades import Gravity
2022-09-16 10:07:57 -06:00
from pyobjus import autoclass
class iOSGravity(Gravity):
def __init__(self):
self.bridge = autoclass('bridge').alloc().init()
self.bridge.motionManager.setDeviceMotionUpdateInterval_(0.1)
def _enable(self):
self.bridge.startDeviceMotion()
def _disable(self):
self.bridge.stopDeviceMotion()
def _get_gravity(self):
return (
self.bridge.g_x,
self.bridge.g_y,
self.bridge.g_z)
def instance():
return iOSGravity()