title: Android Pitch and Roll Issue
body: <p>I am working on a tilt app for Android.  I am having an issue with Portrait &amp; landscape mode.  When the pitch = 90 degrees (phone on end) and even slightly before the roll value goes crazy when there has been no physical change in roll.   I have not been able to find a solution to this problem.  If anyone can point me in the right direction, it would be appreciated.</p>
  
  <p>Here’s a short code dump, so you know it is not an accelerometer error.</p>
  
  <pre><code>final SensorEventListener mEventListener = new SensorEventListener(){
       public void onAccuracyChanged(Sensor sensor, int accuracy) {}  
   public void onSensorChanged(SensorEvent event) {
       setListners(sensorManager, mEventListener);
  
        SensorManager.getRotationMatrix(mRotationMatrix, null, mValuesAccel, mValuesMagnet);
       SensorManager.getOrientation(mRotationMatrix, mValuesOrientation);
  
  
          synchronized (this) {
  
              switch (event.sensor.getType()){
                  case Sensor.TYPE_ACCELEROMETER:
  
                      System.arraycopy(event.values, 0, mValuesAccel, 0, 3);
  
                      long actualTime = System.currentTimeMillis();
  
                      //Sensitivity delay
                      if (actualTime - lastUpdate &lt; 250) {
                          return;
                          }
                      else {
                          sysAzimuth = (int)Math.toDegrees(mValuesOrientation[0]);
                          sysPitch = (int)Math.toDegrees(mValuesOrientation[1]);
                          sysRoll = (int)Math.toDegrees(mValuesOrientation[2]);
  
                          //invert direction with -1
                        pitch = (sysPitch - pitchCal)*-1;
                        roll = (sysRoll - rollCal);
                        azimuth = sysAzimuth;
  
                      lastUpdate = actualTime;
                      }
  </code></pre>