Created
January 27, 2017 05:14
-
-
Save omz/a47ae64580439da539574b5da3c71932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `motion` module from Pythonista | |
# This is missing in the current App Store versions (in Pythonista 3.x, it's only missing in Python 2 mode). | |
# As a temporary workaround, you can put this file in the "site-packages" folder (under "Modules" or "Modules & Templates"). | |
import _motion | |
shared_manager = _motion.MotionManager() | |
def start_updates(): | |
shared_manager.start() | |
def stop_updates(): | |
shared_manager.stop() | |
def get_gravity(): | |
return shared_manager.gravity | |
def get_user_acceleration(): | |
return shared_manager.user_acceleration | |
def get_attitude(): | |
return shared_manager.attitude | |
def get_magnetic_field(): | |
return shared_manager.magnetic_field | |
class MotionUpdates (object): | |
def __enter__(self): | |
start_updates() | |
def __exit__(self, type, value, traceback): | |
stop_updates() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment