dgelessus last edited by
Settings app > Privacy > Location Services > turn on the switch for Pythonista
Omega0 last edited by
Enabled location services for Pythonista, still not working.
Some more data points. I get (0.0, 0.0,0.0,0) before enabling updates as above, then (0.0,0.0,0.0,-1) using beta 1.6 on a Ipad Air 2. ioS 8.1.1.
Other motion.get_* calls work just fine.
The motion request preferences does not include Pythonista as an application requesting access.
OMZ needs to work on this. Not fixable by mere mortals.
omz last edited by
For 1.6 beta users: Could you try moving your device after enabling updates to calibrate the compass?
import motion import time try: motion.start_updates() while True: print motion.get_magnetic_field() # if you get (0, 0, 0,...) here, try moving your device in circles... like you would in the Compass app time.sleep(0.5) finally: motion.stop_updates()
After ~10 (0,0,0,-1) returns, it starts to give real values for x,y,z and 1 for the last parameter.
omz last edited by
Okay, I don't think there's more I can do. If you want to use the magnetometer data, you might want to check if the compass is calibrated first, and wait for calibration before using the data otherwise, something like this:
import motion import time motion.start_updates() while True: m = motion.get_magnetic_field() if m != -1: break print 'Please calibrate the compass by moving the device...' time.sleep(0.5) print 'Magnetometer successfully calibrated' print 'Data:', motion.get_magnetic_field() motion.stop_updates()
zencuke last edited by
Just tried again. I get (0,0, 0.0, 0.0, -1) forever, i.e hundreds of iterations regardless of motion. Just as I did when I tried 4 days ago. I have calibrated the compass with the compass app. I can switch between Pythonista and the compass app seeing the compass app working but Pythonista still giving the same empty results.
I'm using iPhone 6 with iOS 8.1.1. As far as I remember I haven't been able to make get_magnetic_field to work since I upgraded from iPhone 5 to iPhone 6 several days ago. I'm pretty sure it worked on the iPhone 5 but I don't have it anymore to test.
Note: I just updated the infinite loop in my test script to print all 4 motion.get_<> function results. Everything prints normal (at least non zero and changing as the iPhone is rotated and tilted) except get_magnetic_field(); all this while jumping back and forth between Pythionista and the compass app.
I don't think it is a calibration problem. Also since the compass app works it is hard to imagine that it is a problem with my new iPhone 6 either. Note: I just downloaded 4 of the free compass apps. They all work; even while switching between them and the failing Pythonista script. So far 5 compass apps work every time and my Pythonista script fails every time.
I don't know if this helps but I did notice a repeatable state change. When I run the script from a cold start get_magnetic_fileld() reports 0 accuracy before the call to start_updates() and for the first call after the call to start_updates. Then it switches to -1. Rerunning the script always sees accuracy of -1 even after a call to stop_updates(). The only way I can get an accuracy of 0 again is to kill Pythonista and start over.
brumm last edited by
hi, I tried the same (iphone 6 + pythonista 1.5). Compass app works, but in pythonista I only got (0.0, 0.0, 0.0, -1).
import motion import time t1 = time.time() run = True motion.get_magnetic_field() motion.start_updates() while run: m = motion.get_magnetic_field() t2 = time.time() if (t2 - t1) > 5.0: run = False else: print m motion.stop_updates()
JonB last edited by
Ipad 2 has the same issue, w/ 1.5.
zencuke last edited by
@dgelessus - Sorry I wasn't clear. I know how to turn on Location services in general. I just don't see Pythonista in the list when I go there.
Edit: When a script imports location a dialog pops up. After that Pythonista is in the location services list. Hmm. I wonder if this the normal behavior for all apps. I've never noticed it before but this may be the first time I checked location settings before attempting to use the app location functionality.
ashook last edited by
Does anyone know of a workaround or fix for this problem? motion.get_magnetic_field() fails on both of my iOS devices: iPad mini 9.02, iPhone 5 9.02.