Motion broken on iOS 12.2?
Hello everyone. I’m a long time lurker and thanks for all your posts. I’m developing a gps app and it appears motion on iOS 12.2 gives random results. My testflight and Pythonista versions work fine at 12.1. Google helped me find chatter on other sites saying that the privacy settings for motion are now being enforced the way location settings are.
Is anyone else having a problem? Workarounds?
As a work around, using the yaw component from motion.get_attitude works. Apple calibrates it with the magnetometer some how. Acceleration, attitude and gravity all seem to be unchanged. The attached code works in both 12.1 and 12.2.
Screenshots in the gist show the magnetometer results for 12.1 at N,E,S and W.
For 12.2 the magnetometer results appear to be random.
The device orientation comes from ui.WebView (Thanks @JonB https://forum.omz-software.com/topic/997/get-current-screen-or-orientation-width).
In portrait mode when the screen is held high (or low) enough to be face down, yaw and roll flip 180deg. This can be detected by the sign of a gravity component. The original Swift example (https://medium.com/swiftly-swift/how-to-build-a-compass-app-in-swift-2b6647ae25e8) uses a CoreMotion component not easily obtained by Pythonista to flag a face down orientation.
edit: By face down I mean past vertical. The pitch component must be in the range [+90,-90]
@njm Link https://github.com/njmcn/Pythonista/blob/master/mag_test.py gives error 404 😢
@njm, repository not public?
repository now public
@njm test this
from objc_util import * UIDevice = ObjCClass('UIDevice').currentDevice() print(UIDevice.orientation()) # https://developer.apple.com/documentation/uikit/uideviceorientation?language=objc # 6 = UIDeviceOrientationFaceDown
If it prints 6, your iDevice is face down
The 6 only comes up when completely upside down. The transition from flat to "vertical" happens near a pitch or roll of 30deg. Still not as reliable as the gravity term and ui.WebView