ios - CMDeviceMotion returns 0 values for magnetic field -


i developing ios app compass functionality. have tried use cmmagnetometerdata updates give uncalibrated, normal results.

after tried cmdevicemotion updates turned out give 0 magnetic field cmmagneticfieldcalibrationaccuracyuncalibrated accuracy. device have ipad, can't test on others.

may field 0 because sensor not calibrated, not find way perform calibration.

how fix that?

update:

here suggested use startdevicemotionupdatesusingreferenceframe:toqueue:withhandler:, didn't work me.

here suggested set showsdevicemovementdisplay true. didn't work either, calibration windows not popping up.

finally, solved. according observations:

1) use startdevicemotionupdatesusingreferenceframe:toqueue:withhandler: referenceframe not equal allzeros or xarbitraryzvertical.

2) set showsdevicemovementdisplay true.

after few zero-value updates accuracy cmmagneticfieldcalibrationaccuracyuncalibrated normalise.

code:

... motionmanager.devicemotionupdateinterval = 0.05 motionmanager.showsdevicemovementdisplay = true  motionmanager.startdevicemotionupdatesusingreferenceframe(cmattitudereferenceframe.xarbitrarycorrectedzvertical, toqueue: nsoperationqueue.mainqueue(), withhandler:handleupdate) ... private func handleupdate(data: cmdevicemotion!, error: nserror!) {     if data != nil {         let field = data.magneticfield.field         println("\(field.x), \(field.y), \(field.z)")     } } 

finally, according own observations:

1) use startdevicemotionupdatesusingreferenceframe:toqueue:withhandler:with referenceframe not equal allzeros or xarbitraryzvertical.

2) set showsdevicemovementdisplay true.

after few zero-value updates accuracy cmmagneticfieldcalibrationaccuracyuncalibrated normalise.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -