• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Battery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.o3dr.services.android.lib.drone.property.Battery的典型用法代码示例。如果您正苦于以下问题:Java Battery类的具体用法?Java Battery怎么用?Java Battery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Battery类属于com.o3dr.services.android.lib.drone.property包,在下文中一共展示了Battery类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDroneVariable

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
protected void getDroneVariable(Drone mDrone, CheckListItem mListItem) {
	String sys_tag = mListItem.getSys_tag();

       final Battery droneBattery = mDrone.getAttribute(AttributeType.BATTERY);
	if (sys_tag.equalsIgnoreCase("SYS_BATTREM_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryRemain());
	} else if (sys_tag.equalsIgnoreCase("SYS_BATTVOL_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryVoltage());
	} else if (sys_tag.equalsIgnoreCase("SYS_BATTCUR_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryCurrent());
	}

       final Gps droneGps = mDrone.getAttribute(AttributeType.GPS);
       if (sys_tag.equalsIgnoreCase("SYS_GPS3D_LVL")) {
		mListItem.setSys_value(droneGps.getSatellitesCount());
	}

       final State droneState = mDrone.getAttribute(AttributeType.STATE);
       if (sys_tag.equalsIgnoreCase("SYS_ARM_STATE")) {
		mListItem.setSys_activated(droneState.isArmed());
	} else if (sys_tag.equalsIgnoreCase("SYS_FAILSAFE_STATE")) {
		mListItem.setSys_activated(droneState.isWarning());
	} else if (sys_tag.equalsIgnoreCase("SYS_CONNECTION_STATE")) {
		mListItem.setSys_activated(droneState.isConnected());
	}
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:27,代码来源:ListRow.java


示例2: speakPeriodic

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void speakPeriodic(Drone drone) {
    // Drop the message if the previous one is not done yet.
    if (mIsPeriodicStatusStarted.compareAndSet(false, true)) {
        final Map<String, Boolean> speechPrefs = mAppPrefs.getPeriodicSpeechPrefs();

        mMessageBuilder.setLength(0);
        if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_BAT_VOLT)) {
            final Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
            mMessageBuilder.append(context.getString(R.string.periodic_status_bat_volt,
                    droneBattery.getBatteryVoltage()));
        }

        if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_ALT)) {
            final Altitude altitude = drone.getAttribute(AttributeType.ALTITUDE);
            mMessageBuilder.append(context.getString(R.string.periodic_status_altitude, (int) (altitude.getAltitude())));
        }

        if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_AIRSPEED)) {
            final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
            mMessageBuilder.append(context.getString(R.string.periodic_status_airspeed, (int) (droneSpeed.getAirSpeed())));
        }

        if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_RSSI)) {
            final Signal signal = drone.getAttribute(AttributeType.SIGNAL);
            mMessageBuilder.append(context.getString(R.string.periodic_status_rssi, (int) signal.getRssi()));
        }

        speak(mMessageBuilder.toString(), true, PERIODIC_STATUS_UTTERANCE_ID);
    }
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:31,代码来源:TTSNotificationProvider.java


示例3: updateBattery

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void updateBattery(Drone drone) {
    if (mInboxBuilder == null)
        return;

    Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
    String update = droneBattery == null ? "--" : String.format(
            "%2.1fv (%2.0f%%)", droneBattery.getBatteryVoltage(),
            droneBattery.getBatteryRemain());

    mInboxBuilder.setLine(3, SpannableUtils.normal("Battery:   ", SpannableUtils.bold(update)));
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:12,代码来源:StatusBarNotificationProvider.java


示例4: getSystemData

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
public void getSystemData(CheckListItem mListItem, String mSysTag) {
	if (mSysTag == null)
		return;

	Battery batt = drone.getAttribute(AttributeType.BATTERY);
	if (batt != null) {
		if (mSysTag.equalsIgnoreCase("SYS_BATTREM_LVL")) {
			mListItem.setSys_value(batt.getBatteryRemain());
		} else if (mSysTag.equalsIgnoreCase("SYS_BATTVOL_LVL")) {
			mListItem.setSys_value(batt.getBatteryVoltage());
		} else if (mSysTag.equalsIgnoreCase("SYS_BATTCUR_LVL")) {
			mListItem.setSys_value(batt.getBatteryCurrent());
		}
	}

	Gps gps = drone.getAttribute(AttributeType.GPS);
	if (gps != null) {
		if (mSysTag.equalsIgnoreCase("SYS_GPS3D_LVL")) {
			mListItem.setSys_value(gps.getSatellitesCount());
		}
	}

	State state = drone.getAttribute(AttributeType.STATE);
	if (state != null) {
		if (mSysTag.equalsIgnoreCase("SYS_ARM_STATE")) {
			mListItem.setSys_activated(state.isArmed());
		} else if (mSysTag.equalsIgnoreCase("SYS_FAILSAFE_STATE")) {
			mListItem.setSys_activated(state.isWarning());
		}
	}

	if (mSysTag.equalsIgnoreCase("SYS_CONNECTION_STATE")) {
		mListItem.setSys_activated(drone.isConnected());
	}
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:36,代码来源:CheckListSysLink.java


示例5: updateBattery

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void updateBattery(Drone drone) {
	if (mInboxBuilder == null)
		return;

       Battery droneBattery = drone.getBattery();
       String update = droneBattery == null ? "--" : String.format(
               "%2.1fv (%2.0f%%)", droneBattery.getBatteryVoltage(),
               droneBattery.getBatteryRemain());

	mInboxBuilder.setLine(3, SpannableUtils.normal("Battery:   ", SpannableUtils.bold(update)));
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:12,代码来源:StatusBarNotificationProvider.java


示例6: updateItemView

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
@Override
public void updateItemView(Context context, Drone drone) {

	if (mItemView == null)
		return;

	String infoUpdate;
          Battery droneBattery;
	if (drone == null || !drone.isConnected() || ((droneBattery = drone.getBattery()) ==
                  null)) {
		infoUpdate = sDefaultValue;
		currentView.setText(sDefaultValue);
		mAhView.setText(sDefaultValue);
	} else {

              Double discharge = droneBattery.getBatteryDischarge();
              String dischargeText;
              if (discharge == null) {
                  dischargeText = sDefaultValue;
              }else{
                  dischargeText = String.format(Locale.ENGLISH, "%2.0f mAh", discharge);
              }

              mAhView.setText(String.format(Locale.ENGLISH,"Remaining %2.0f%%", droneBattery.getBatteryRemain()));
              currentView.setText(String.format("Current %2.1f A", droneBattery.getBatteryCurrent()));

              infoUpdate = String.format(Locale.ENGLISH,"%2.1fv\n", droneBattery.getBatteryVoltage());
              infoUpdate = infoUpdate.concat(dischargeText);
	}

	mPopup.update();
	((TextView) mItemView).setText(infoUpdate);
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:34,代码来源:InfoBarItem.java


示例7: getSystemData

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
public void getSystemData(CheckListItem mListItem, String mSysTag) {
	if (mSysTag == null)
		return;

	Battery batt = drone.getBattery();
	if (batt != null) {
		if (mSysTag.equalsIgnoreCase("SYS_BATTREM_LVL")) {
			mListItem.setSys_value(batt.getBatteryRemain());
		} else if (mSysTag.equalsIgnoreCase("SYS_BATTVOL_LVL")) {
			mListItem.setSys_value(batt.getBatteryVoltage());
		} else if (mSysTag.equalsIgnoreCase("SYS_BATTCUR_LVL")) {
			mListItem.setSys_value(batt.getBatteryCurrent());
		}
	}

	Gps gps = drone.getGps();
	if (gps != null) {
		if (mSysTag.equalsIgnoreCase("SYS_GPS3D_LVL")) {
			mListItem.setSys_value(gps.getSatellitesCount());
		}
	}

	State state = drone.getState();
	if (state != null) {
		if (mSysTag.equalsIgnoreCase("SYS_ARM_STATE")) {
			mListItem.setSys_activated(state.isArmed());
		} else if (mSysTag.equalsIgnoreCase("SYS_FAILSAFE_STATE")) {
			mListItem.setSys_activated(state.isWarning());
		}
	}

	if (mSysTag.equalsIgnoreCase("SYS_CONNECTION_STATE")) {
		mListItem.setSys_activated(drone.isConnected());
	}
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:36,代码来源:CheckListSysLink.java


示例8: speakPeriodic

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void speakPeriodic(Drone drone) {
	// Drop the message if the previous one is not done yet.
	if (mIsPeriodicStatusStarted.compareAndSet(false, true)) {
		final SparseBooleanArray speechPrefs = mAppPrefs.getPeriodicSpeechPrefs();

		mMessageBuilder.setLength(0);
		if (speechPrefs.get(R.string.pref_tts_periodic_bat_volt_key)) {
                  final Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
			mMessageBuilder.append(String.format("battery %2.1f volts. ", droneBattery.getBatteryVoltage()));
		}

		if (speechPrefs.get(R.string.pref_tts_periodic_alt_key)) {
                  final Altitude altitude = drone.getAttribute(AttributeType.ALTITUDE);
			mMessageBuilder.append("altitude, ").append((int) (altitude.getAltitude())).append(" meters. ");
		}

		if (speechPrefs.get(R.string.pref_tts_periodic_airspeed_key)) {
                  final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
			mMessageBuilder.append("airspeed, ").append((int) (droneSpeed.getAirSpeed()))
                          .append(" meters per second. ");
		}

		if (speechPrefs.get(R.string.pref_tts_periodic_rssi_key)) {
                  final Signal signal = drone.getAttribute(AttributeType.SIGNAL);
			mMessageBuilder.append("r s s i, ").append((int) signal.getRssi()).append(" decibels");
		}

		speak(mMessageBuilder.toString(), true, PERIODIC_STATUS_UTTERANCE_ID);
	}
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:31,代码来源:TTSNotificationProvider.java


示例9: updateBattery

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void updateBattery(Drone drone) {
	if (mInboxBuilder == null)
		return;

       Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
       String update = droneBattery == null ? "--" : String.format(
               "%2.1fv (%2.0f%%)", droneBattery.getBatteryVoltage(),
               droneBattery.getBatteryRemain());

	mInboxBuilder.setLine(3, SpannableUtils.normal("Battery:   ", SpannableUtils.bold(update)));
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:12,代码来源:StatusBarNotificationProvider.java


示例10: updateBatteryTelem

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void updateBatteryTelem() {
    final Drone drone = getDrone();

    final View batteryPopupView = batteryPopup.getContentView();
    final TextView dischargeView = (TextView) batteryPopupView.findViewById(R.id.bar_power_discharge);
    final TextView currentView = (TextView) batteryPopupView.findViewById(R.id.bar_power_current);
    final TextView mAhView = (TextView) batteryPopupView.findViewById(R.id.bar_power_mAh);

    String update;
    Battery droneBattery;
    final int batteryIcon;
    if (!drone.isConnected() || ((droneBattery = drone.getAttribute(AttributeType.BATTERY)) == null)) {
        update = emptyString;
        dischargeView.setText("D: " + emptyString);
        currentView.setText("C: " + emptyString);
        mAhView.setText("R: " + emptyString);
        batteryIcon = R.drawable.ic_battery_unknown_black_24dp;
    } else {
        Double discharge = droneBattery.getBatteryDischarge();
        String dischargeText;
        if (discharge == null) {
            dischargeText = "D: " + emptyString;
        } else {
            dischargeText = "D: " + electricChargeToString(discharge);
        }

        dischargeView.setText(dischargeText);
        mAhView.setText(String.format(Locale.ENGLISH, "R: %2.0f %%", droneBattery.getBatteryRemain()));
        currentView.setText(String.format("C: %2.1f A", droneBattery.getBatteryCurrent()));

        update = String.format(Locale.ENGLISH, "%2.1f V", droneBattery.getBatteryVoltage());
        batteryIcon = R.drawable.ic_battery_std_black_24dp;
    }

    batteryPopup.update();
    batteryTelem.setText(update);
    batteryTelem.setCompoundDrawablesWithIntrinsicBounds(batteryIcon, 0, 0, 0);
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:39,代码来源:ActionBarTelemFragment.java


示例11: updateBatteryTelem

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void updateBatteryTelem() {
    final Drone drone = getDrone();

    final View batteryPopupView = batteryPopup.getContentView();
    final TextView dischargeView = (TextView) batteryPopupView.findViewById(R.id.bar_power_discharge);
    final TextView currentView = (TextView) batteryPopupView.findViewById(R.id.bar_power_current);
    final TextView remainView = (TextView) batteryPopupView.findViewById(R.id.bar_power_remain);

    String update;
    Battery droneBattery;
    final int batteryIcon;
    if (!drone.isConnected() || ((droneBattery = drone.getAttribute(AttributeType.BATTERY)) == null)) {
        update = emptyString;
        dischargeView.setText("D: " + emptyString);
        currentView.setText("C: " + emptyString);
        remainView.setText("R: " + emptyString);
        batteryIcon = R.drawable.ic_battery_circle_0_24dp;
    } else {
        Double discharge = droneBattery.getBatteryDischarge();
        String dischargeText;
        if (discharge == null) {
            dischargeText = "D: " + emptyString;
        } else {
            dischargeText = "D: " + electricChargeToString(discharge);
        }

        dischargeView.setText(dischargeText);

        final double battRemain = droneBattery.getBatteryRemain();
        remainView.setText(String.format(Locale.ENGLISH, "R: %2.0f %%", battRemain));
        currentView.setText(String.format("C: %2.1f A", droneBattery.getBatteryCurrent()));


        update = String.format(Locale.ENGLISH, "%2.1fV", droneBattery.getBatteryVoltage());

        if (battRemain >= 100) {
            batteryIcon = R.drawable.ic_battery_circle_8_24dp;
        } else if (battRemain >= 87.5) {
            batteryIcon = R.drawable.ic_battery_circle_7_24dp;
        } else if (battRemain >= 75) {
            batteryIcon = R.drawable.ic_battery_circle_6_24dp;
        } else if (battRemain >= 62.5) {
            batteryIcon = R.drawable.ic_battery_circle_5_24dp;
        } else if (battRemain >= 50) {
            batteryIcon = R.drawable.ic_battery_circle_4_24dp;
        } else if (battRemain >= 37.5) {
            batteryIcon = R.drawable.ic_battery_circle_3_24dp;
        } else if (battRemain >= 25) {
            batteryIcon = R.drawable.ic_battery_circle_2_24dp;
        } else if (battRemain >= 12.5) {
            batteryIcon = R.drawable.ic_battery_circle_1_24dp;
        } else {
            batteryIcon = R.drawable.ic_battery_circle_0_24dp;
        }
    }

    batteryPopup.update();
    batteryTelem.setText(update);
    batteryTelem.setCompoundDrawablesWithIntrinsicBounds(batteryIcon, 0, 0, 0);
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:61,代码来源:ActionBarTelemFragment.java


示例12: handleBatteryStateChange

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private void handleBatteryStateChange() {
    Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
    batteryState = droneStateMapper.getBatteryState(droneBattery);
    notifyBatteryStateListeners();
}
 
开发者ID:Project-Helin,项目名称:drone-onboard-app,代码行数:6,代码来源:DroneConnectionService.java


示例13: onReceive

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	if (tts == null)
		return;

	final String action = intent.getAction();
          State droneState = drone.getState();

	if (AttributeEvent.STATE_ARMING.equals(action)) {
              if(droneState != null)
		    speakArmedState(droneState.isArmed());
	} else if (AttributeEvent.BATTERY_UPDATED.equals(action)) {
              Battery droneBattery = drone.getBattery();
              if(droneBattery != null)
		    batteryDischargeNotification(droneBattery.getBatteryRemain());
	} else if (AttributeEvent.STATE_VEHICLE_MODE.equals(action)) {
              if(droneState != null)
		    speakMode(droneState.getVehicleMode());
	} else if (AttributeEvent.MISSION_SENT.equals(action)) {
		Toast.makeText(context, "Waypoints sent", Toast.LENGTH_SHORT).show();
		speak("Waypoints saved to Drone");
	} else if (AttributeEvent.GPS_FIX.equals(action)) {
              Gps droneGps = drone.getGps();
              if(droneGps != null)
		    speakGpsMode(droneGps.getFixType());
	} else if (AttributeEvent.MISSION_RECEIVED.equals(action)) {
		Toast.makeText(context, "Waypoints received from Drone", Toast.LENGTH_SHORT).show();
		speak("Waypoints received");
	} else if (AttributeEvent.HEARTBEAT_FIRST.equals(action)) {
		watchdogCallback.setDrone(drone);
		scheduleWatchdog();
		speak("Connected");
	} else if (AttributeEvent.HEARTBEAT_TIMEOUT.equals(action)) {
		if (mAppPrefs.getWarningOnLostOrRestoredSignal()) {
			speak("Data link lost, check connection.");
			handler.removeCallbacks(watchdogCallback);
		}
	}
          else if(AttributeEvent.HEARTBEAT_RESTORED.equals(action)){
              watchdogCallback.setDrone(drone);
              scheduleWatchdog();
              if (mAppPrefs.getWarningOnLostOrRestoredSignal()) {
                  speak("Data link restored");
              }
          }
          else if(AttributeEvent.STATE_DISCONNECTED.equals(action)){
              handler.removeCallbacks(watchdogCallback);
          }
          else if(AttributeEvent.MISSION_ITEM_UPDATED.equals(action)){
              int currentWaypoint = intent.getIntExtra(AttributeEventExtra.EXTRA_MISSION_CURRENT_WAYPOINT, 0);
              speak("Going for waypoint " + currentWaypoint);
          }
          else if(AttributeEvent.FOLLOW_START.equals(action)){
              speak("Following");
          }
          else if(AttributeEvent.ALTITUDE_400FT_EXCEEDED.equals(action)){
              if (mAppPrefs.getWarningOn400ftExceeded()) {
                  speak("warning, 400 feet exceeded");
              }
          }
          else if(AttributeEvent.AUTOPILOT_FAILSAFE.equals(action)){
              String warning = intent.getStringExtra(AttributeEventExtra.EXTRA_AUTOPILOT_FAILSAFE_MESSAGE);
              if (!TextUtils.isEmpty(warning) && mAppPrefs.getWarningOnAutopilotWarning()) {
                  speak(warning);
              }
          }
          else if(AttributeEvent.SIGNAL_WEAK.equals(action)){
              if (mAppPrefs.getWarningOnLowSignalStrength()) {
                  speak("Warning, weak signal");
              }
          }
          else if(AttributeEvent.WARNING_NO_GPS.equals(action)){
              speak("Error, no gps lock yet");
          }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:76,代码来源:TTSNotificationProvider.java


示例14: getBattery

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
private Battery getBattery() {
    org.droidplanner.core.drone.variables.Battery droneBattery = this.droneMgr.getDrone().getBattery();
    return new Battery(droneBattery.getBattVolt(), droneBattery.getBattRemain(),
            droneBattery.getBattCurrent(), droneBattery.getBattDischarge());
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:6,代码来源:DroneApi.java


示例15: getBattery

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
public Battery getBattery() {
    Battery battery = getAttribute(AttributeType.BATTERY, Battery.class.getClassLoader());
    return battery == null ? new Battery() : battery;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:5,代码来源:Drone.java


示例16: onDroneEvent

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
@Override
public void onDroneEvent(String event, Bundle extras) {
    switch (event) {
        case AttributeEvent.STATE_CONNECTED:
            TextView connectionStatusTextView = (TextView)findViewById(R.id.connectionStatus);
            connectionStatusTextView.setText("Connected");
            startVideoFeed();
            break;

        case AttributeEvent.STATE_DISCONNECTED:
            connectionStatusTextView = (TextView)findViewById(R.id.connectionStatus);
            connectionStatusTextView.setText("Disconnected");
            stopVideoFeed();
            break;

        case AttributeEvent.ALTITUDE_UPDATED:
            TextView altitudeTextView = (TextView)findViewById(R.id.altitudeTextView);
            Altitude droneAltitude = this.drone.getAttribute(AttributeType.ALTITUDE);
            altitudeTextView.setText(String.format("Alt: %3.1f", droneAltitude.getAltitude()) + "m");
            break;

        case AttributeEvent.BATTERY_UPDATED:
            TextView batteryTextView = (TextView)findViewById(R.id.batteryTextView);
            Battery batt = this.drone.getAttribute(AttributeType.BATTERY);
            batteryTextView.setText(String.format("Batt: %3.1f", batt.getBatteryRemain()) + "%");
            break;

        case AttributeEvent.GPS_COUNT:
            TextView satelliteTextView = (TextView)findViewById(R.id.satelliteTextView);
            Gps gps = this.drone.getAttribute(AttributeType.GPS);
            satelliteTextView.setText(String.format("Sats: %3.1f", gps.getSatellitesCount()));
            break;

        case AttributeEvent.STATE_VEHICLE_MODE:
            State vehicleState = this.drone.getAttribute(AttributeType.STATE);
            VehicleMode vehicleMode = vehicleState.getVehicleMode();
            TextView flightModeTextView = (TextView)findViewById(R.id.flightModeTextView);
            flightModeTextView.setText("Mode: " + vehicleMode.getLabel());

            // If the mode is switched and the pano is in progress let's release gimbal control
            if(vehicleMode.getLabel() != "Guided" && panoInProgress) {
                panoInProgress = false;
                GimbalApi.getApi(this.drone).stopGimbalControl(gimbalListener);
            }
            break;

        default:
            break;
    }
}
 
开发者ID:dbaldwin,项目名称:DronePan-Solo,代码行数:51,代码来源:MainActivity.java


示例17: sendDataToWatchNow

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
/**
 * Sends a full dictionary with updated information when called. If no
 * pebble is present, the watchapp isn't installed, or the watchapp isn't
 * running, nothing will happen.
 *
 * @param drone
 */
private void sendDataToWatchNow(Drone drone) {
    final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
    final State droneState = drone.getAttribute(AttributeType.STATE);
    if (followState == null || droneState == null)
        return;

    PebbleDictionary data = new PebbleDictionary();

    VehicleMode mode = droneState.getVehicleMode();
    if (mode == null)
        return;

    final GuidedState guidedState = drone.getAttribute(AttributeType.GUIDED_STATE);
    String modeLabel = mode.getLabel();
    if (!droneState.isArmed())
        modeLabel = "Disarmed";
    else if (followState.isEnabled())
        modeLabel = "Follow";
    else if (guidedState.isInitialized() && !followState.isEnabled())
        modeLabel = "Paused";

    data.addString(KEY_MODE, modeLabel);

    FollowType type = followState.getMode();
    if (type != null) {
        data.addString(KEY_FOLLOW_TYPE, type.getTypeLabel());
    } else
        data.addString(KEY_FOLLOW_TYPE, "none");

    final Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
    Double battVoltage = droneBattery.getBatteryVoltage();
    if (battVoltage == null)
        battVoltage = 0.0;
    String bat = "Bat: " + Double.toString((double) Math.round(battVoltage * 10) / 10) + "V";

    final Altitude droneAltitude = drone.getAttribute(AttributeType.ALTITUDE);
    String altitude = "Alt: " + roundToTwoDigits(droneAltitude.getAltitude()) + "m";
    String telem = bat + "\n" + altitude;
    data.addString(KEY_TELEM, telem);

    data.addString(KEY_APP_VERSION, EXPECTED_APP_VERSION);

    PebbleKit.sendDataToPebble(applicationContext, DP_UUID, data);
}
 
开发者ID:DroidPlanner,项目名称:tower-pebble,代码行数:52,代码来源:PebbleCommunicatorService.java


示例18: onVehicleDataUpdated

import com.o3dr.services.android.lib.drone.property.Battery; //导入依赖的package包/类
@Override
protected void onVehicleDataUpdated(String dataType, byte[] eventData) {
    switch (dataType) {
        case AttributeType.STATE:
            State vehicleState = eventData == null ? null : ParcelableUtils.unmarshall(eventData, State.CREATOR);
            final boolean isConnected = vehicleState != null && vehicleState.isConnected();
            activityLayout.setKeepScreenOn(isConnected && appPrefs.keepScreenBright());

            final CharSequence connectionLabel;
            if (isConnected) {
                VehicleMode flightMode = vehicleState.getVehicleMode();
                final int color = Color.rgb(34, 139, 34);
                if (flightMode == null)
                    connectionLabel = SpannableUtils.color(color, "connected");
                else {
                    final int droneType = flightMode.getDroneType();
                    final String typeLabel;
                    switch(droneType){
                        case Type.TYPE_COPTER:
                            typeLabel = "Copter:  ";
                            break;

                        case Type.TYPE_PLANE:
                            typeLabel = "Plane:  ";
                            break;

                        case Type.TYPE_ROVER:
                            typeLabel = "Rover:  ";
                            break;

                        default:
                            typeLabel = "";
                            break;
                    }

                    connectionLabel = SpannableUtils.normal(typeLabel, SpannableUtils.color(color,
                            flightMode.getLabel()));
                }
            } else {
                connectionLabel = SpannableUtils.color(Color.RED, "disconnected");
            }
            connectionStatus.setText(connectionLabel);
            break;

        case AttributeType.GPS:
            droneGps = eventData == null ? null : ParcelableUtils.unmarshall(eventData, Gps.CREATOR);
            updateGpsStatus();
            break;

        case AttributeType.BATTERY:
            Battery battery = eventData == null ? null : ParcelableUtils.unmarshall(eventData, Battery.CREATOR);
            if (battery == null)
                batteryStatus.setText(R.string.empty_content);
            else {
                batteryStatus.setText(String.format(Locale.ENGLISH, "%2.1fv", battery.getBatteryVoltage()));
            }
            break;

        case AttributeType.SIGNAL:
            Signal signal = eventData == null ? null : ParcelableUtils.unmarshall(eventData, Signal.CREATOR);
            if (signal == null || !signal.isValid()) {
                signalStatus.setText(R.string.empty_content);
            } else {
                final int signalStrength = MathUtils.getSignalStrength(signal.getFadeMargin(),
                        signal.getRemFadeMargin());
                signalStatus.setText(signalStrength + "%");
            }
            break;

        case AttributeType.HOME:
            droneHome = eventData == null ? null : ParcelableUtils.unmarshall(eventData, Home.CREATOR);
            updateHomeStatus();
            break;
    }
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:76,代码来源:ContextStreamActivity.java



注:本文中的com.o3dr.services.android.lib.drone.property.Battery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SupportMenu类代码示例发布时间:2022-05-22
下一篇:
Java ExitTarget类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap