aeyrium / aeyrium-sensor

A Flutter sensor plugin which provide easy access to the Pitch and Roll on Android and iOS devices.
https://aeyrium.com
MIT License
57 stars 33 forks source link

Roll sensor value jumps from 0 to ~ 2*pi on iPhone 8 when the phone lays flat. #6

Open FrankenApps opened 5 years ago

FrankenApps commented 5 years ago

I have used this library on android (emulator and real device without any problems), however on the iPhone 8 (physical device) the roll sensor value jumps from 0 to approximately 2*pi or 6.28... when the phone lays flat. Whereas on android it changes from 1 to 0 to -1 for example, when i rotate the device. I think, the library should give consistent results on android and iOS. I would prefer it the android way. In the meantime I use this workaraound:

if(Platform.isIOS){
  if(event.roll < (-1)*pi){
    sensorValue = 2*pi+event.roll;
  } 
  else{         
    sensorValue = event.roll;
  }
} 
else{
  sensorValue = event.roll;     //roll in radians for android 
}