ios - Accelerometer freak out -




i testing app, , meant getting readings accelometer...pretty simple! right , code says, if acceleration above 0.005, start adding 1 value... reason, when rotate ipad, , seems 'standing on 1 of edges' diamond, value seems increasing? increases if ipad still. here code :

motionmanager.accelerometerupdateinterval = 0.02 motionmanager.startaccelerometerupdates(to: operationqueue.current!) { (data,error) in     if let mydata = data {         if mydata.acceleration.y > 0.05 {                   self.damian += 1             print(data)         } 

i'm not sure based on documentation looks you're getting gravity + useracceleration. it's pretty normal non-zero values y-axis in device positions.

the total acceleration of device equal gravity plus acceleration user imparts device ( useracceleration ).

to useracceleration should call startdevicemotionupdates(to:withhandler:) - https://developer.apple.com/documentation/coremotion/cmmotionmanager/1616048-startdevicemotionupdates





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -