private void updateFlightModeButtons() {
    resetFlightModeButtons();

    final Drone drone = getDrone();
    final State droneState = drone.getAttribute(AttributeType.STATE);
    final VehicleMode flightMode = droneState.getVehicleMode();
    if (flightMode != null) {
      switch (flightMode) {
        case PLANE_AUTO:
          autoBtn.setActivated(true);
          break;

        case PLANE_GUIDED:
          final GuidedState guidedState = drone.getAttribute(AttributeType.GUIDED_STATE);
          final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
          if (guidedState.isInitialized() && !followState.isEnabled()) {
            pauseBtn.setActivated(true);
          }
          break;

        case PLANE_RTL:
          homeBtn.setActivated(true);
          break;
      }
    }
  }
示例#2
0
 /** @return Vehicle flight time in seconds. */
 public long getFlightTime() {
   State droneState = getAttribute(AttributeType.STATE);
   if (droneState != null && droneState.isFlying()) {
     // calc delta time since last checked
     elapsedFlightTime += SystemClock.elapsedRealtime() - startTime;
     startTime = SystemClock.elapsedRealtime();
   }
   return elapsedFlightTime / 1000;
 }
 private void setupButtonsByFlightState() {
   final State droneState = getDrone().getAttribute(AttributeType.STATE);
   if (droneState != null && droneState.isConnected()) {
     if (droneState.isArmed()) {
       if (droneState.isFlying()) {
         setupButtonsForFlying();
       } else {
         setupButtonsForArmed();
       }
     } else {
       setupButtonsForDisarmed();
     }
   } else {
     setupButtonsForDisconnected();
   }
 }
 @Override
 public boolean isSlidingUpPanelEnabled(Drone drone) {
   final State droneState = drone.getAttribute(AttributeType.STATE);
   return droneState.isConnected() && droneState.isArmed() && droneState.isFlying();
 }
示例#5
0
 public boolean isConnected() {
   final IDroneApi droneApi = droneApiRef.get();
   State droneState = getAttribute(AttributeType.STATE);
   return isStarted(droneApi) && droneState.isConnected();
 }