Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
61df2beb
Commit
61df2beb
authored
May 18, 2015
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1583 from dogmaphobic/batteryStatus
Adding Battery Consumption to the tool bar.
parents
d0512114
a5f2ab07
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
5 deletions
+57
-5
MavManager.cc
src/QmlControls/MavManager.cc
+12
-0
MavManager.h
src/QmlControls/MavManager.h
+5
-0
UAS.cc
src/uas/UAS.cc
+13
-0
UASInterface.h
src/uas/UASInterface.h
+1
-0
MainToolBar.qml
src/ui/toolbar/MainToolBar.qml
+26
-5
No files found.
src/QmlControls/MavManager.cc
View file @
61df2beb
...
...
@@ -57,6 +57,7 @@ MavManager::MavManager(QObject *parent)
,
_refreshTimer
(
new
QTimer
(
this
))
,
_batteryVoltage
(
0.0
)
,
_batteryPercent
(
0.0
)
,
_batteryConsumed
(
0.0
)
,
_systemArmed
(
false
)
,
_currentHeartbeatTimeout
(
0
)
,
_waypointDistance
(
0.0
)
...
...
@@ -108,6 +109,7 @@ void MavManager::_forgetUAS(UASInterface* uas)
disconnect
(
_mav
,
&
UASInterface
::
NavigationControllerDataChanged
,
this
,
&
MavManager
::
_updateNavigationControllerData
);
disconnect
(
_mav
,
&
UASInterface
::
heartbeatTimeout
,
this
,
&
MavManager
::
_heartbeatTimeout
);
disconnect
(
_mav
,
&
UASInterface
::
batteryChanged
,
this
,
&
MavManager
::
_updateBatteryRemaining
);
disconnect
(
_mav
,
&
UASInterface
::
batteryConsumedChanged
,
this
,
&
MavManager
::
_updateBatteryConsumedChanged
);
disconnect
(
_mav
,
&
UASInterface
::
modeChanged
,
this
,
&
MavManager
::
_updateMode
);
disconnect
(
_mav
,
&
UASInterface
::
nameChanged
,
this
,
&
MavManager
::
_updateName
);
disconnect
(
_mav
,
&
UASInterface
::
systemTypeSet
,
this
,
&
MavManager
::
_setSystemType
);
...
...
@@ -157,6 +159,7 @@ void MavManager::_setActiveUAS(UASInterface* uas)
connect
(
_mav
,
&
UASInterface
::
NavigationControllerDataChanged
,
this
,
&
MavManager
::
_updateNavigationControllerData
);
connect
(
_mav
,
&
UASInterface
::
heartbeatTimeout
,
this
,
&
MavManager
::
_heartbeatTimeout
);
connect
(
_mav
,
&
UASInterface
::
batteryChanged
,
this
,
&
MavManager
::
_updateBatteryRemaining
);
connect
(
_mav
,
&
UASInterface
::
batteryConsumedChanged
,
this
,
&
MavManager
::
_updateBatteryConsumedChanged
);
connect
(
_mav
,
&
UASInterface
::
modeChanged
,
this
,
&
MavManager
::
_updateMode
);
connect
(
_mav
,
&
UASInterface
::
nameChanged
,
this
,
&
MavManager
::
_updateName
);
connect
(
_mav
,
&
UASInterface
::
systemTypeSet
,
this
,
&
MavManager
::
_setSystemType
);
...
...
@@ -437,6 +440,15 @@ void MavManager::_updateBatteryRemaining(UASInterface*, double voltage, double,
}
}
void
MavManager
::
_updateBatteryConsumedChanged
(
UASInterface
*
,
double
current_consumed
)
{
if
(
_batteryConsumed
!=
current_consumed
)
{
_batteryConsumed
=
current_consumed
;
emit
batteryConsumedChanged
();
}
}
void
MavManager
::
_updateState
(
UASInterface
*
,
QString
name
,
QString
)
{
if
(
_currentState
!=
name
)
{
...
...
src/QmlControls/MavManager.h
View file @
61df2beb
...
...
@@ -76,6 +76,7 @@ public:
Q_PROPERTY
(
bool
mavPresent
READ
mavPresent
NOTIFY
mavPresentChanged
)
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
(
bool
systemArmed
READ
systemArmed
NOTIFY
systemArmedChanged
)
Q_PROPERTY
(
QString
currentMode
READ
currentMode
NOTIFY
currentModeChanged
)
Q_PROPERTY
(
QString
systemPixmap
READ
systemPixmap
NOTIFY
systemPixmapChanged
)
...
...
@@ -103,6 +104,7 @@ public:
int
satelliteCount
()
{
return
_satelliteCount
;
}
double
batteryVoltage
()
{
return
_batteryVoltage
;
}
double
batteryPercent
()
{
return
_batteryPercent
;
}
double
batteryConsumed
()
{
return
_batteryConsumed
;
}
bool
systemArmed
()
{
return
_systemArmed
;
}
QString
currentMode
()
{
return
_currentMode
;
}
QString
systemPixmap
()
{
return
_systemPixmap
;
}
...
...
@@ -130,6 +132,7 @@ signals:
void
mavPresentChanged
();
void
batteryVoltageChanged
();
void
batteryPercentChanged
();
void
batteryConsumedChanged
();
void
systemArmedChanged
();
void
heartbeatTimeoutChanged
();
void
currentModeChanged
();
...
...
@@ -158,6 +161,7 @@ private slots:
void
_setActiveUAS
(
UASInterface
*
uas
);
void
_checkUpdate
();
void
_updateBatteryRemaining
(
UASInterface
*
,
double
voltage
,
double
,
double
percent
,
int
);
void
_updateBatteryConsumedChanged
(
UASInterface
*
,
double
current_consumed
);
void
_updateArmingState
(
bool
armed
);
void
_updateState
(
UASInterface
*
system
,
QString
name
,
QString
description
);
void
_updateMode
(
int
system
,
QString
name
,
QString
description
);
...
...
@@ -197,6 +201,7 @@ private:
QList
<
int
>
_changes
;
double
_batteryVoltage
;
double
_batteryPercent
;
double
_batteryConsumed
;
bool
_systemArmed
;
QString
_currentState
;
QString
_currentMode
;
...
...
src/uas/UAS.cc
View file @
61df2beb
...
...
@@ -559,6 +559,19 @@ void UAS::receiveMessage(LinkInterface* link, 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
)
...
...
src/uas/UASInterface.h
View file @
61df2beb
...
...
@@ -488,6 +488,7 @@ 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
actuatorChanged
(
UASInterface
*
,
int
actId
,
double
value
);
void
thrustChanged
(
UASInterface
*
,
double
thrust
);
...
...
src/ui/toolbar/MainToolBar.qml
View file @
61df2beb
...
...
@@ -526,15 +526,14 @@ Rectangle {
}
Rectangle
{
id
:
battery
width
:
getProportionalDimmension
(
6
0
)
id
:
battery
Status
width
:
MavManager
.
batteryConsumed
<
0.0
?
getProportionalDimmension
(
60
)
:
getProportionalDimmension
(
8
0
)
height
:
cellHeight
visible
:
showMavStatus
()
&&
(
mainToolBar
.
showBattery
)
anchors.verticalCenter
:
parent
.
verticalCenter
color
:
getBatteryColor
();
border.color
:
"
#00000000
"
border.width
:
0
Image
{
source
:
getBatteryIcon
();
height
:
getProportionalDimmension
(
20
)
...
...
@@ -547,16 +546,38 @@ Rectangle {
}
QGCLabel
{
id
:
batteryText
visible
:
batteryStatus
.
visible
&&
MavManager
.
batteryConsumed
<
0.0
text
:
MavManager
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
;
font.pointSize
:
ScreenTools
.
fontPointFactor
*
(
11
);
font.weight
:
Font
.
DemiBold
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.right
:
parent
.
right
anchors.rightMargin
:
getProportionalDimmension
(
6
)
horizontalAlignment
:
Text
.
AlignRight
color
:
colorWhite
}
Column
{
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.right
:
parent
.
right
anchors.rightMargin
:
getProportionalDimmension
(
6
)
visible
:
batteryStatus
.
visible
&&
MavManager
.
batteryConsumed
>=
0.0
QGCLabel
{
text
:
MavManager
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
;
width
:
getProportionalDimmension
(
30
)
horizontalAlignment
:
Text
.
AlignRight
font.pointSize
:
ScreenTools
.
fontPointFactor
*
(
11
);
font.weight
:
Font
.
DemiBold
color
:
colorWhite
}
QGCLabel
{
text
:
MavManager
.
batteryConsumed
.
toFixed
(
0
)
+
'
mA
'
;
width
:
getProportionalDimmension
(
30
)
horizontalAlignment
:
Text
.
AlignRight
font.pointSize
:
ScreenTools
.
fontPointFactor
*
(
11
);
font.weight
:
Font
.
DemiBold
color
:
colorWhite
}
}
}
Column
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment