@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_base);

    // compass stuff
    compassManager = new CompassManager(this);
    // register for rotation updates
    compassManager.registerRotationListener(this);
    azimuthBuffer = new ArrayList<>();

    devices =
        (ArrayList<BluetoothDevice>)
            getIntent().getSerializableExtra(StartMenuActivity.EXTRA_DEVICES);

    measureFragment = MeasureFragment.getInstance(devices.size());
    resultFragment = new ResultFragment();

    // activate the measure fragment
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.main_container, measureFragment);
    fragmentTransaction.commit();
    currentFragment = measureFragment;
    // as long as the app is measuring, the screen should not turn off
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }
  public void restartMeasure(View view) {
    Log.d("iris", "restart measurement");
    measureFragment = MeasureFragment.getInstance(devices.size());
    // activate the measure fragment
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.main_container, measureFragment);
    fragmentTransaction.commit();
    // as long as the app is measuring, the screen should not turn off
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    startMeasurement();
  }
  @Override
  public void onAzimuthChange(float newAzimuth) {
    azimuth = newAzimuth;

    smoothAzimuth = calculateSmoothAzimuth(newAzimuth);

    if (measureFragment != null) {
      measureFragment.rotateView(360 - (float) CircleUtils.radiansToDegree(smoothAzimuth));
    }
    if (currentFragment == resultFragment) {
      resultFragment.onSmoothAzimuthChange(smoothAzimuth);
    }
  }