Commit c2f9b562 authored by Don Gagne's avatar Don Gagne

Vehicle.battery FactGroup

Removed incorrect Vehicle.altitudeWGS84
parent 58181a8a
......@@ -55,7 +55,7 @@ QGCView {
readonly property real _defaultRoll: 0
readonly property real _defaultPitch: 0
readonly property real _defaultHeading: 0
readonly property real _defaultAltitudeWGS84: 0
readonly property real _defaultAltitudeAMSL: 0
readonly property real _defaultGroundSpeed: 0
readonly property real _defaultAirSpeed: 0
......@@ -75,7 +75,7 @@ QGCView {
property Fact _emptyFact: Fact { }
property Fact _groundSpeedFact: _activeVehicle ? _activeVehicle.groundSpeed : _emptyFact
property Fact _airSpeedFact: _activeVehicle ? _activeVehicle.airSpeed : _emptyFact
property Fact _altitudeWGS84Fact: _activeVehicle ? _activeVehicle.altitudeWGS84 : _emptyFact
property Fact _altitudeAMSLFact: _activeVehicle ? _activeVehicle.altitudeAMSL : _emptyFact
property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false
......
......@@ -100,7 +100,7 @@ Item {
heading: _heading
rollAngle: _roll
pitchAngle: _pitch
altitudeFact: _altitudeWGS84Fact
altitudeFact: _altitudeAMSLFact
groundSpeedFact: _groundSpeedFact
airSpeedFact: _airSpeedFact
isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true
......@@ -124,7 +124,7 @@ Item {
spacing: ScreenTools.defaultFontPixelSize * 0.33
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: _altitudeWGS84Fact.shortDescription + "(" + _altitudeWGS84Fact.units + ")"
text: _altitudeAMSLFact.shortDescription + "(" + _altitudeAMSLFact.units + ")"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width
height: ScreenTools.defaultFontPixelSize * 0.75
......@@ -132,7 +132,7 @@ Item {
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: _altitudeWGS84Fact.valueString
text: _altitudeAMSLFact.valueString
font.pixelSize: ScreenTools.defaultFontPixelSize * 1.5
font.weight: Font.DemiBold
width: parent.width
......
......@@ -36,9 +36,17 @@ ValuesWidgetController::ValuesWidgetController(void)
settings.beginGroup(_groupKey);
largeDefaults << "Vehicle.altitudeWGS84" << "Vehicle.groundSpeed";
largeDefaults << "Vehicle.altitudeRelative" << "Vehicle.groundSpeed";
_largeValues = settings.value(_largeValuesKey, largeDefaults).toStringList();
_smallValues = settings.value(_smallValuesKey, QStringList()).toStringList();
// Keep back compat for removed WGS84 value
if (_largeValues.contains ("Vehicle.altitudeWGS84")) {
setLargeValues(_largeValues.replaceInStrings("Vehicle.altitudeWGS84", "Vehicle.altitudeRelative"));
}
if (_smallValues.contains ("Vehicle.altitudeWGS84")) {
setSmallValues(_largeValues.replaceInStrings("Vehicle.altitudeWGS84", "Vehicle.altitudeRelative"));
}
}
void ValuesWidgetController::setLargeValues(const QStringList& values)
......
......@@ -3,67 +3,45 @@
"properties": [
{
"name": "roll",
"shortDescription": "Roll",
"name": "voltage",
"shortDescription": "Voltage",
"type": "double",
"decimalPlaces": 1,
"units": "degrees"
"decimalPlaces": 2,
"units": "v"
},
{
"name": "pitch",
"shortDescription": "Pitch",
"type": "double",
"decimalPlaces": 1,
"units": "degrees"
},
{
"name": "heading",
"shortDescription": "Heading",
"type": "double",
"name": "percentRemaining",
"shortDescription": "Percent",
"type": "int32",
"decimalPlaces": 0,
"units": "degrees"
},
{
"name": "groundSpeed",
"shortDescription": "Ground Speed",
"type": "double",
"decimalPlaces": 1,
"units": "m/s"
},
{
"name": "airSpeed",
"shortDescription": "Air Speed",
"type": "double",
"decimalPlaces": 1,
"units": "m/s"
"units": "%"
},
{
"name": "climbRate",
"shortDescription": "Climb Rate",
"type": "double",
"decimalPlaces": 1,
"units": "m/s"
"name": "mahConsumed",
"shortDescription": "Consumed",
"type": "int32",
"decimalPlaces": 0,
"units": "mAh"
},
{
"name": "altitudeRelative",
"shortDescription": "Altitude",
"type": "double",
"decimalPlaces": 1,
"units": "m"
"name": "current",
"shortDescription": "Current",
"type": "int32",
"decimalPlaces": 0,
"units": "mA"
},
{
"name": "altitudeQGS84",
"shortDescription": "Altitude",
"type": "double",
"decimalPlaces": 1,
"units": "m"
"name": "temperature",
"shortDescription": "Temperature",
"type": "int32",
"decimalPlaces": 2,
"units": "C"
},
{
"name": "altitudeAMSL",
"shortDescription": "Altitude",
"type": "double",
"decimalPlaces": 1,
"units": "m"
"name": "cellCount",
"shortDescription": "Cell Count",
"type": "int32",
"decimalPlaces": 0
}
]
}
This diff is collapsed.
......@@ -74,6 +74,12 @@ public:
void setVehicle(Vehicle* vehicle);
static const char* _hdopFactName;
static const char* _vdopFactName;
static const char* _courseOverGroundFactName;
static const char* _countFactName;
static const char* _lockFactName;
private slots:
void _setSatelliteCount(double val, QString);
void _setSatRawHDOP(double val);
......@@ -88,12 +94,53 @@ private:
Fact _courseOverGroundFact;
Fact _countFact;
Fact _lockFact;
};
static const char* _hdopFactName;
static const char* _vdopFactName;
static const char* _courseOverGroundFactName;
static const char* _countFactName;
static const char* _lockFactName;
class VehicleBatteryFactGroup : public FactGroup
{
Q_OBJECT
public:
VehicleBatteryFactGroup(QObject* parent = NULL);
Q_PROPERTY(Fact* voltage READ voltage CONSTANT)
Q_PROPERTY(Fact* percentRemaining READ percentRemaining CONSTANT)
Q_PROPERTY(Fact* mahConsumed READ mahConsumed CONSTANT)
Q_PROPERTY(Fact* current READ current CONSTANT)
Q_PROPERTY(Fact* temperature READ temperature CONSTANT)
Q_PROPERTY(Fact* cellCount READ cellCount CONSTANT)
Fact* voltage(void) { return &_voltageFact; }
Fact* percentRemaining(void) { return &_percentRemainingFact; }
Fact* mahConsumed(void) { return &_mahConsumedFact; }
Fact* current(void) { return &_currentFact; }
Fact* temperature(void) { return &_temperatureFact; }
Fact* cellCount(void) { return &_cellCountFact; }
void setVehicle(Vehicle* vehicle);
static const char* _voltageFactName;
static const char* _percentRemainingFactName;
static const char* _mahConsumedFactName;
static const char* _currentFactName;
static const char* _temperatureFactName;
static const char* _cellCountFactName;
static const double _voltageUnavailable;
static const int _percentRemainingUnavailable;
static const int _mahConsumedUnavailable;
static const int _currentUnavailable;
static const double _temperatureUnavailable;
static const int _cellCountUnavailable;
private:
Vehicle* _vehicle;
Fact _voltageFact;
Fact _percentRemainingFact;
Fact _mahConsumedFact;
Fact _currentFact;
Fact _temperatureFact;
Fact _cellCountFact;
};
class Vehicle : public FactGroup
......@@ -126,9 +173,6 @@ public:
Q_PROPERTY(QmlObjectListModel* trajectoryPoints READ trajectoryPoints CONSTANT)
Q_PROPERTY(float latitude READ latitude NOTIFY coordinateChanged)
Q_PROPERTY(float longitude READ longitude NOTIFY coordinateChanged)
Q_PROPERTY(double batteryVoltage READ batteryVoltage NOTIFY batteryVoltageChanged)
Q_PROPERTY(double batteryPercent READ batteryPercent NOTIFY batteryPercentChanged)
Q_PROPERTY(double batteryConsumed READ batteryConsumed NOTIFY batteryConsumedChanged)
Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged)
Q_PROPERTY(QmlObjectListModel* missionItems READ missionItemsModel CONSTANT)
Q_PROPERTY(bool messageTypeNone READ messageTypeNone NOTIFY messageTypeChanged)
......@@ -167,10 +211,10 @@ public:
Q_PROPERTY(Fact* airSpeed READ airSpeed CONSTANT)
Q_PROPERTY(Fact* climbRate READ climbRate CONSTANT)
Q_PROPERTY(Fact* altitudeRelative READ altitudeRelative CONSTANT)
Q_PROPERTY(Fact* altitudeWGS84 READ altitudeWGS84 CONSTANT)
Q_PROPERTY(Fact* altitudeAMSL READ altitudeAMSL CONSTANT)
Q_PROPERTY(FactGroup* gps READ gpsFactGroup CONSTANT)
Q_PROPERTY(FactGroup* gps READ gpsFactGroup CONSTANT)
Q_PROPERTY(FactGroup* battery READ batteryFactGroup CONSTANT)
/// Resets link status counters
Q_INVOKABLE void resetCounters ();
......@@ -298,9 +342,6 @@ public:
float latitude () { return _coordinate.latitude(); }
float longitude () { return _coordinate.longitude(); }
bool mavPresent () { return _mav != NULL; }
double batteryVoltage () { return _batteryVoltage; }
double batteryPercent () { return _batteryPercent; }
double batteryConsumed () { return _batteryConsumed; }
QString currentState () { return _currentState; }
int rcRSSI () { return _rcRSSI; }
bool px4Firmware () { return _firmwareType == MAV_AUTOPILOT_PX4; }
......@@ -319,10 +360,10 @@ public:
Fact* groundSpeed (void) { return &_groundSpeedFact; }
Fact* climbRate (void) { return &_climbRateFact; }
Fact* altitudeRelative (void) { return &_altitudeRelativeFact; }
Fact* altitudeWGS84 (void) { return &_altitudeWGS84Fact; }
Fact* altitudeAMSL (void) { return &_altitudeAMSLFact; }
FactGroup* gpsFactGroup(void) { return &_gpsFactGroup; }
FactGroup* gpsFactGroup (void) { return &_gpsFactGroup; }
FactGroup* batteryFactGroup (void) { return &_batteryFactGroup; }
void setConnectionLostEnabled(bool connectionLostEnabled);
......@@ -369,9 +410,6 @@ signals:
void formatedMessageChanged ();
void latestErrorChanged ();
void longitudeChanged ();
void batteryVoltageChanged ();
void batteryPercentChanged ();
void batteryConsumedChanged ();
void currentConfigChanged ();
void currentStateChanged ();
void flowImageIndexChanged ();
......@@ -407,12 +445,10 @@ private slots:
/** @brief Attitude from one specific component / redundant autopilot */
void _updateAttitude (UASInterface* uas, int component, double roll, double pitch, double yaw, quint64 timestamp);
void _updateSpeed (UASInterface* uas, double _groundSpeed, double _airSpeed, quint64 timestamp);
void _updateAltitude (UASInterface* uas, double _altitudeAMSL, double _altitudeWGS84, double _altitudeRelative, double _climbRate, quint64 timestamp);
void _updateAltitude (UASInterface* uas, double _altitudeAMSL, double _altitudeRelative, double _climbRate, quint64 timestamp);
void _updateNavigationControllerErrors (UASInterface* uas, double altitudeError, double speedError, double xtrackError);
void _updateNavigationControllerData (UASInterface *uas, float navRoll, float navPitch, float navBearing, float targetBearing, float targetDistance);
void _checkUpdate ();
void _updateBatteryRemaining (UASInterface*, double voltage, double, double percent, int);
void _updateBatteryConsumedChanged (UASInterface*, double current_consumed);
void _updateState (UASInterface* system, QString name, QString description);
/** @brief A new camera image has arrived */
void _imageReady (UASInterface* uas);
......@@ -428,6 +464,8 @@ private:
void _handleHeartbeat(mavlink_message_t& message);
void _handleRCChannels(mavlink_message_t& message);
void _handleRCChannelsRaw(mavlink_message_t& message);
void _handleBatteryStatus(mavlink_message_t& message);
void _handleSysStatus(mavlink_message_t& message);
void _missionManagerError(int errorCode, const QString& errorMsg);
void _mapTrajectoryStart(void);
void _mapTrajectoryStop(void);
......@@ -470,9 +508,6 @@ private:
float _navigationCrosstrackError;
float _navigationTargetBearing;
QTimer* _refreshTimer;
double _batteryVoltage;
double _batteryPercent;
double _batteryConsumed;
QString _currentState;
int _updateCount;
QString _formatedMessage;
......@@ -539,10 +574,10 @@ private:
Fact _airSpeedFact;
Fact _climbRateFact;
Fact _altitudeRelativeFact;
Fact _altitudeWGS84Fact;
Fact _altitudeAMSLFact;
VehicleGPSFactGroup _gpsFactGroup;
VehicleGPSFactGroup _gpsFactGroup;
VehicleBatteryFactGroup _batteryFactGroup;
static const char* _rollFactName;
static const char* _pitchFactName;
......@@ -551,9 +586,9 @@ private:
static const char* _airSpeedFactName;
static const char* _climbRateFactName;
static const char* _altitudeRelativeFactName;
static const char* _altitudeWGS84FactName;
static const char* _altitudeAMSLFactName;
static const char* _gpsFactGroupName;
static const char* _batteryFactGroupName;
static const int _vehicleUIUpdateRateMSecs = 100;
......
......@@ -46,14 +46,7 @@
},
{
"name": "altitudeRelative",
"shortDescription": "Altitude",
"type": "double",
"decimalPlaces": 1,
"units": "m"
},
{
"name": "altitudeWGS84",
"shortDescription": "Altitude",
"shortDescription": "Altitude (home)",
"type": "double",
"decimalPlaces": 1,
"units": "m"
......
......@@ -92,7 +92,6 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle, FirmwarePluginManager * fi
longitude(0.0),
altitudeAMSL(0.0),
altitudeAMSLFT(0.0),
altitudeWGS84(0.0),
altitudeRelative(0.0),
satRawHDOP(1e10f),
......@@ -355,18 +354,6 @@ void UAS::receiveMessage(mavlink_message_t message)
break;
case MAVLINK_MSG_ID_BATTERY_STATUS:
{
if (multiComponentSourceDetected && wrongComponent)
{
break;
}
mavlink_battery_status_t bat_status;
mavlink_msg_battery_status_decode(&message, &bat_status);
emit batteryConsumedChanged(this, (double)bat_status.current_consumed);
}
break;
case MAVLINK_MSG_ID_SYS_STATUS:
{
if (multiComponentSourceDetected && wrongComponent)
......@@ -391,6 +378,8 @@ void UAS::receiveMessage(mavlink_message_t message)
emit loadChanged(this,state.load/10.0f);
emit valueChanged(uasId, name.arg("load"), "%", state.load/10.0f, time);
currentVoltage = state.voltage_battery/1000.0f;
if (state.voltage_battery > 0.0f && state.voltage_battery != UINT16_MAX) {
// Battery charge/time remaining/voltage calculations
currentVoltage = state.voltage_battery/1000.0f;
......@@ -572,7 +561,7 @@ void UAS::receiveMessage(mavlink_message_t message)
if (!isnan(hud.airspeed))
setAirSpeed(hud.airspeed);
speedZ = -hud.climb;
emit altitudeChanged(this, altitudeAMSL, altitudeWGS84, altitudeRelative, -speedZ, time);
emit altitudeChanged(this, altitudeAMSL, altitudeRelative, -speedZ, time);
emit speedChanged(this, groundSpeed, airSpeed, time);
}
break;
......@@ -614,7 +603,6 @@ void UAS::receiveMessage(mavlink_message_t message)
setLatitude(pos.lat/(double)1E7);
setLongitude(pos.lon/(double)1E7);
setAltitudeWGS84(pos.alt/1000.0);
setAltitudeRelative(pos.relative_alt/1000.0);
globalEstimatorActive = true;
......@@ -623,8 +611,8 @@ void UAS::receiveMessage(mavlink_message_t message)
speedY = pos.vy/100.0;
speedZ = pos.vz/100.0;
emit globalPositionChanged(this, getLatitude(), getLongitude(), getAltitudeAMSL(), getAltitudeWGS84(), time);
emit altitudeChanged(this, altitudeAMSL, altitudeWGS84, altitudeRelative, -speedZ, time);
emit globalPositionChanged(this, getLatitude(), getLongitude(), getAltitudeAMSL(), time);
emit altitudeChanged(this, altitudeAMSL, altitudeRelative, -speedZ, time);
// We had some frame mess here, global and local axes were mixed.
emit velocityChanged_NED(this, speedX, speedY, speedZ, time);
......@@ -661,9 +649,8 @@ void UAS::receiveMessage(mavlink_message_t message)
if (!globalEstimatorActive) {
setLatitude(latitude_gps);
setLongitude(longitude_gps);
setAltitudeWGS84(altitude_gps);
emit globalPositionChanged(this, getLatitude(), getLongitude(), getAltitudeAMSL(), getAltitudeWGS84(), time);
emit altitudeChanged(this, altitudeAMSL, altitudeWGS84, altitudeRelative, -speedZ, time);
emit globalPositionChanged(this, getLatitude(), getLongitude(), getAltitudeAMSL(), time);
emit altitudeChanged(this, altitudeAMSL, altitudeRelative, -speedZ, time);
float vel = pos.vel/100.0f;
// Smaller than threshold and not NaN
......
......@@ -93,7 +93,6 @@ public:
Q_PROPERTY(double bearingToWaypoint READ getBearingToWaypoint WRITE setBearingToWaypoint NOTIFY bearingToWaypointChanged)
Q_PROPERTY(double altitudeAMSL READ getAltitudeAMSL WRITE setAltitudeAMSL NOTIFY altitudeAMSLChanged)
Q_PROPERTY(double altitudeAMSLFT READ getAltitudeAMSLFT NOTIFY altitudeAMSLFTChanged)
Q_PROPERTY(double altitudeWGS84 READ getAltitudeWGS84 WRITE setAltitudeWGS84 NOTIFY altitudeWGS84Changed)
Q_PROPERTY(double altitudeRelative READ getAltitudeRelative WRITE setAltitudeRelative NOTIFY altitudeRelativeChanged)
Q_PROPERTY(double satRawHDOP READ getSatRawHDOP NOTIFY satRawHDOPChanged)
Q_PROPERTY(double satRawVDOP READ getSatRawVDOP NOTIFY satRawVDOPChanged)
......@@ -203,19 +202,6 @@ public:
return altitudeAMSLFT;
}
void setAltitudeWGS84(double val)
{
altitudeWGS84 = val;
emit altitudeWGS84Changed(val, "altitudeWGS84");
emit valueChanged(this->uasId,"altitudeWGS84","m",QVariant(val),getUnixTime());
}
double getAltitudeWGS84() const
{
return altitudeWGS84;
}
void setAltitudeRelative(double val)
{
altitudeRelative = val;
......@@ -431,7 +417,6 @@ protected: //COMMENTS FOR TEST UNIT
double longitude; ///< Global longitude as estimated by position estimator
double altitudeAMSL; ///< Global altitude as estimated by position estimator, AMSL
double altitudeAMSLFT; ///< Global altitude as estimated by position estimator, AMSL
double altitudeWGS84; ///< Global altitude as estimated by position estimator, WGS84
double altitudeRelative; ///< Altitude above home as estimated by position estimator
double satRawHDOP;
......@@ -614,7 +599,6 @@ signals:
void latitudeChanged(double val,QString name);
void altitudeAMSLChanged(double val,QString name);
void altitudeAMSLFTChanged(double val,QString name);
void altitudeWGS84Changed(double val,QString name);
void altitudeRelativeChanged(double val,QString name);
void satRawHDOPChanged (double value);
......
......@@ -253,7 +253,6 @@ signals:
* @param seconds estimated remaining flight time in seconds
*/
void batteryChanged(UASInterface* uas, double voltage, double current, double percent, int seconds);
void batteryConsumedChanged(UASInterface* uas, double current_consumed);
void statusChanged(UASInterface* uas, QString status);
void thrustChanged(UASInterface*, double thrust);
void attitudeChanged(UASInterface*, double roll, double pitch, double yaw, quint64 usec);
......@@ -264,8 +263,8 @@ signals:
void positionSetPointsChanged(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired, quint64 usec);
/** @brief A user (or an autonomous mission or obstacle avoidance planner) requested to set a new setpoint */
void userPositionSetPointsChanged(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired);
void globalPositionChanged(UASInterface*, double lat, double lon, double altAMSL, double altWGS84, quint64 usec);
void altitudeChanged(UASInterface*, double altitudeAMSL, double altitudeWGS84, double altitudeRelative, double climbRate, quint64 usec);
void globalPositionChanged(UASInterface*, double lat, double lon, double altAMSL, quint64 usec);
void altitudeChanged(UASInterface*, double altitudeAMSL, double altitudeRelative, double climbRate, quint64 usec);
/** @brief Update the status of one satellite used for localization */
void gpsSatelliteStatusChanged(int uasid, int satid, float azimuth, float direction, float snr, bool used);
......
......@@ -165,13 +165,13 @@ Rectangle {
function getBatteryColor() {
if(activeVehicle) {
if(activeVehicle.batteryPercent > 75) {
if(activeVehicle.battery.percentRemaining.value > 75) {
return colorGreen
}
if(activeVehicle.batteryPercent > 50) {
if(activeVehicle.battery.percentRemaining.value > 50) {
return colorOrange
}
if(activeVehicle.batteryPercent > 0.1) {
if(activeVehicle.battery.percentRemaining.value > 0.1) {
return colorRed
}
}
......@@ -276,27 +276,29 @@ Rectangle {
// Battery Info
Component {
id: batteryInfo
Rectangle {
color: Qt.rgba(0,0,0,0.75)
width: battCol.width + ScreenTools.defaultFontPixelWidth * 3
height: battCol.height + ScreenTools.defaultFontPixelHeight * 2
radius: ScreenTools.defaultFontPixelHeight * 0.5
Column {
id: battCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: Math.max(battGrid.width, battLabel.width)
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
id: battLabel
text: (activeVehicle && (activeVehicle.batteryVoltage > 0)) ? "Battery Status" : "Battery Data Unavailable"
text: "Battery Status"
color: colorWhite
font.weight:Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter
}
GridLayout {
id: battGrid
visible: (activeVehicle && (activeVehicle.batteryVoltage > 0))
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
......@@ -306,29 +308,20 @@ Rectangle {
color: colorWhite
}
QGCLabel {
text: activeVehicle ? (activeVehicle.batteryVoltage.toFixed(1) + " V") : "N/A"
text: (activeVehicle && activeVehicle.battery.voltage.value != -1) ? (activeVehicle.battery.voltage.valueString + " " + activeVehicle.battery.voltage.units) : "N/A"
color: getBatteryColor()
}
// TODO: What "controller" provides "Facts"?
/*
QGCLabel {
text: "Cell Voltage:"
}
QGCLabel {
text: (activeVehicle.batteryVoltage / controller.getParameterFact(-1, "BAT_N_CELLS").value) + "V"
color: getBatteryColor()
}
*/
QGCLabel {
text: "Accumulated Consumption:"
color: colorWhite
}
QGCLabel {
text: activeVehicle ? (activeVehicle.batteryConsumed + " mA") : "N/A"
text: (activeVehicle && activeVehicle.battery.mahConsumed.value != -1) ? (activeVehicle.battery.mahConsumed.valueString + " " + activeVehicle.battery.mahConsumed.units) : "N/A"
color: getBatteryColor()
}
}
}
Component.onCompleted: {
var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
x = pos.x
......
......@@ -65,27 +65,22 @@ Row {
}
function getBatteryVoltageText() {
if (activeVehicle.batteryVoltage > 0) {
//-- TODO: Need number of cells so I can show cell voltage instead of total voltage
//if (battNumCells && battNumCells.value) {
// return (activeVehicle.batteryVoltage / battNumCells.value).toFixed(2) + 'V'
//} else {
return activeVehicle.batteryVoltage.toFixed(1) + 'V'
//}
if (activeVehicle.battery.voltage.value >= 0) {
return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units
}
return 'N/A';
}
function getBatteryPercentageText() {
if(activeVehicle) {
if(activeVehicle.batteryPercent > 98.9) {
if(activeVehicle.battery.percentRemaining.value > 98.9) {
return "100%"
}
if(activeVehicle.batteryPercent > 0.1) {
return activeVehicle.batteryPercent.toFixed(0) + "%"
if(activeVehicle.battery.percentRemaining.value > 0.1) {
return activeVehicle.battery.percentRemaining.valueString + activeVehicle.battery.percentRemaining.units
}
if(activeVehicle.batteryVoltage > 0) {
return activeVehicle.batteryVoltage.toFixed(1) + "V"
if(activeVehicle.battery.voltage.value >= 0) {
return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units
}
}
return "N/A"
......@@ -276,7 +271,7 @@ Row {
id: batteryStatus
width: battRow.width * 1.1
height: mainWindow.tbCellHeight
opacity: activeVehicle ? ((activeVehicle.batteryVoltage > 0) ? 1 : 0.5) : 0.5
opacity: (activeVehicle && activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5
Row {
id: battRow
height: mainWindow.tbCellHeight
......@@ -299,8 +294,10 @@ Row {
MouseArea {
anchors.fill: parent
onClicked: {
var centerX = mapToItem(toolBar, x, y).x + (width / 2)
mainWindow.showPopUp(batteryInfo, centerX)
if (activeVehicle) {
var centerX = mapToItem(toolBar, x, y).x + (width / 2)
mainWindow.showPopUp(batteryInfo, centerX)
}
}
}
}
......
......@@ -33,7 +33,6 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent),
{
valueEnabled("altitudeAMSL");
valueEnabled("altitudeAMSLFT");
valueEnabled("altitudeWGS84");
valueEnabled("altitudeRelative");
valueEnabled("groundSpeed");
valueEnabled("distToWaypoint");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment