Pythonista-Issues
Pythonista-Issues copied to clipboard
Motion module doesn’t work on iPod touch
I’m using the latest TestFlight Pythonista beta (311016) on iOS 11.2.1.
After calling motion.start_updates()
any motion.get_
function just returns (0.0, 0.0, 0.0)
.
@Ivoah, I am using same beta and iOS as you. I am on latest iPad Pro 12.9' The below works for me
import ui
import motion
class MyClass(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.make_view()
self.update_interval = 1
def make_view(self):
motion.start_updates()
def will_close(self):
motion.stop_updates()
def update(self):
print(motion.get_gravity())
if __name__ == '__main__':
f = (0, 0, 300, 400)
v = MyClass(frame=f)
v.present(style='sheet', animated=False)
I think the problem may be that the iPod touch doesn't have a magnetometer. At least that's what this StackOverflow post is suggesting, and it makes sense to me.
@omz But the accelerometer and gyroscope should still be usable, right? As I understand it, currently all the functions are returning zeros, not just the one for the magnetic field.
@dgelessus Core Motion combines the data of different sensors. The culprit seems to be the reference frame that is used for initializing the motion manager.
@omz It would be nice to have this bug fixed. I especially bought an ipod touch 6 to enjoy pythonista... Until then, as little consolation we can use objc_util module to get discrete device orientation... https://github.com/njmcn/Pythonista/blob/master/facedown.py