@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() != Sensor.TYPE_ORIENTATION) { return; } float roll = event.values[2]; rollFilter.pushValue(roll); if (startAngle.getCount() == 0 && rollFilter.getCount() == SETTLE_COUNT) { startAngle.pushValue(rollFilter.getValue()); } }
public float deltaAngle() { if (startAngle.getCount() == 0) { return 0; } return rollFilter.getValue() - startAngle.getValue(); }