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
225d1d15
Commit
225d1d15
authored
5 years ago
by
olliw42
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CameraManager: add BatteryStatus handling
parent
766774c1
master
dev1
merge_branch_alt
original
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
1 deletion
+52
-1
QGCCameraControl.cc
src/Camera/QGCCameraControl.cc
+21
-0
QGCCameraControl.h
src/Camera/QGCCameraControl.h
+7
-0
QGCCameraManager.cc
src/Camera/QGCCameraManager.cc
+15
-0
QGCCameraManager.h
src/Camera/QGCCameraManager.h
+2
-1
CameraPageWidget.qml
src/FlightMap/Widgets/CameraPageWidget.qml
+7
-0
No files found.
src/Camera/QGCCameraControl.cc
View file @
225d1d15
...
...
@@ -263,6 +263,16 @@ QGCCameraControl::storageFreeStr()
return
QGCMapEngine
::
storageFreeSizeToString
(
static_cast
<
quint64
>
(
_storageFree
));
}
//-----------------------------------------------------------------------------
QString
QGCCameraControl
::
batteryRemainingStr
()
{
if
(
_batteryRemaining
>=
0
)
{
return
QGCMapEngine
::
numberToString
(
static_cast
<
quint64
>
(
_batteryRemaining
))
+
" %"
;
}
return
""
;
}
//-----------------------------------------------------------------------------
void
QGCCameraControl
::
setCameraMode
(
CameraMode
mode
)
...
...
@@ -1490,6 +1500,17 @@ QGCCameraControl::handleStorageInfo(const mavlink_storage_information_t& st)
}
}
//-----------------------------------------------------------------------------
void
QGCCameraControl
::
handleBatteryStatus
(
const
mavlink_battery_status_t
&
bs
)
{
qCDebug
(
CameraControlLog
)
<<
"handleBatteryStatus:"
<<
bs
.
battery_remaining
;
if
(
bs
.
battery_remaining
>=
0
&&
_batteryRemaining
!=
static_cast
<
int
>
(
bs
.
battery_remaining
))
{
_batteryRemaining
=
static_cast
<
int
>
(
bs
.
battery_remaining
);
emit
batteryRemainingChanged
();
}
}
//-----------------------------------------------------------------------------
void
QGCCameraControl
::
handleCaptureStatus
(
const
mavlink_camera_capture_status_t
&
cap
)
...
...
This diff is collapsed.
Click to expand it.
src/Camera/QGCCameraControl.h
View file @
225d1d15
...
...
@@ -155,6 +155,8 @@ public:
Q_PROPERTY
(
quint32
storageFree
READ
storageFree
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
QString
storageFreeStr
READ
storageFreeStr
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
quint32
storageTotal
READ
storageTotal
NOTIFY
storageTotalChanged
)
Q_PROPERTY
(
int
batteryRemaining
READ
batteryRemaining
NOTIFY
batteryRemainingChanged
)
Q_PROPERTY
(
QString
batteryRemainingStr
READ
batteryRemainingStr
NOTIFY
batteryRemainingChanged
)
Q_PROPERTY
(
bool
paramComplete
READ
paramComplete
NOTIFY
parametersReady
)
Q_PROPERTY
(
qreal
zoomLevel
READ
zoomLevel
WRITE
setZoomLevel
NOTIFY
zoomLevelChanged
)
...
...
@@ -232,6 +234,8 @@ public:
virtual
quint32
storageFree
()
{
return
_storageFree
;
}
virtual
QString
storageFreeStr
();
virtual
quint32
storageTotal
()
{
return
_storageTotal
;
}
virtual
int
batteryRemaining
()
{
return
_batteryRemaining
;
}
virtual
QString
batteryRemainingStr
();
virtual
bool
paramComplete
()
{
return
_paramComplete
;
}
virtual
qreal
zoomLevel
()
{
return
_zoomLevel
;
}
virtual
qreal
focusLevel
()
{
return
_focusLevel
;
}
...
...
@@ -273,6 +277,7 @@ public:
virtual
void
handleParamAck
(
const
mavlink_param_ext_ack_t
&
ack
);
virtual
void
handleParamValue
(
const
mavlink_param_ext_value_t
&
value
);
virtual
void
handleStorageInfo
(
const
mavlink_storage_information_t
&
st
);
virtual
void
handleBatteryStatus
(
const
mavlink_battery_status_t
&
bs
);
virtual
void
handleVideoInfo
(
const
mavlink_video_stream_information_t
*
vi
);
virtual
void
handleVideoStatus
(
const
mavlink_video_stream_status_t
*
vs
);
...
...
@@ -303,6 +308,7 @@ signals:
void
activeSettingsChanged
();
void
storageFreeChanged
();
void
storageTotalChanged
();
void
batteryRemainingChanged
();
void
dataReady
(
QByteArray
data
);
void
parametersReady
();
void
zoomLevelChanged
();
...
...
@@ -373,6 +379,7 @@ protected:
qreal
_focusLevel
=
0
.
0
;
uint32_t
_storageFree
=
0
;
uint32_t
_storageTotal
=
0
;
int
_batteryRemaining
=
-
1
;
QNetworkAccessManager
*
_netManager
=
nullptr
;
QString
_modelName
;
QString
_vendor
;
...
...
This diff is collapsed.
Click to expand it.
src/Camera/QGCCameraManager.cc
View file @
225d1d15
...
...
@@ -97,6 +97,9 @@ QGCCameraManager::_mavlinkMessageReceived(const mavlink_message_t& message)
case
MAVLINK_MSG_ID_VIDEO_STREAM_STATUS
:
_handleVideoStreamStatus
(
message
);
break
;
case
MAVLINK_MSG_ID_BATTERY_STATUS
:
_handleBatteryStatus
(
message
);
break
;
}
}
}
...
...
@@ -358,6 +361,18 @@ QGCCameraManager::_handleVideoStreamStatus(const mavlink_message_t& message)
}
}
//-----------------------------------------------------------------------------
void
QGCCameraManager
::
_handleBatteryStatus
(
const
mavlink_message_t
&
message
)
{
QGCCameraControl
*
pCamera
=
_findCamera
(
message
.
compid
);
if
(
pCamera
)
{
mavlink_battery_status_t
batteryStatus
;
mavlink_msg_battery_status_decode
(
&
message
,
&
batteryStatus
);
pCamera
->
handleBatteryStatus
(
batteryStatus
);
}
}
//-----------------------------------------------------------------------------
void
QGCCameraManager
::
_requestCameraInfo
(
int
compID
)
...
...
This diff is collapsed.
Click to expand it.
src/Camera/QGCCameraManager.h
View file @
225d1d15
...
...
@@ -35,7 +35,7 @@ public:
//-- Return a list of cameras provided by this vehicle
virtual
QmlObjectListModel
*
cameras
()
{
return
&
_cameras
;
}
//-- Camera names to show the user (for selection)
virtual
QStringList
cameraLabels
()
{
return
_cameraLabels
;
}
virtual
QStringList
cameraLabels
()
{
return
_cameraLabels
;
}
//-- Current selected camera
virtual
int
currentCamera
()
{
return
_currentCamera
;
}
virtual
QGCCameraControl
*
currentCameraInstance
();
...
...
@@ -79,6 +79,7 @@ protected:
virtual
void
_handleCaptureStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamInfo
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleBatteryStatus
(
const
mavlink_message_t
&
message
);
protected:
...
...
This diff is collapsed.
Click to expand it.
src/FlightMap/Widgets/CameraPageWidget.qml
View file @
225d1d15
...
...
@@ -45,6 +45,7 @@ Column {
property
bool
_hasModes
:
_camera
&&
_camera
&&
_camera
.
hasModes
property
bool
_videoRecording
:
_camera
&&
_camera
.
videoStatus
===
QGCCameraControl
.
VIDEO_CAPTURE_STATUS_RUNNING
property
bool
_storageReady
:
_camera
&&
_camera
.
storageStatus
===
QGCCameraControl
.
STORAGE_READY
property
bool
_batteryReady
:
_camera
&&
_camera
.
batteryRemaining
>=
0
property
bool
_storageIgnored
:
_camera
&&
_camera
.
storageStatus
===
QGCCameraControl
.
STORAGE_NOT_SUPPORTED
property
bool
_canShoot
:
!
_videoRecording
&&
_cameraPhotoIdle
&&
((
_storageReady
&&
_camera
.
storageFree
>
0
)
||
_storageIgnored
)
property
int
_curCameraIndex
:
_dynamicCameras
?
_dynamicCameras
.
currentCamera
:
0
...
...
@@ -76,6 +77,12 @@ Column {
anchors.horizontalCenter
:
parent
.
horizontalCenter
visible
:
_camera
&&
_storageReady
}
QGCLabel
{
text
:
_camera
?
qsTr
(
"
Battery:
"
)
+
_camera
.
batteryRemainingStr
:
""
font.pointSize
:
ScreenTools
.
smallFontPointSize
anchors.horizontalCenter
:
parent
.
horizontalCenter
visible
:
_camera
&&
_batteryReady
}
//-- Camera Mode (visible only if camera has modes)
Item
{
width
:
1
;
height
:
ScreenTools
.
defaultFontPixelHeight
*
0.75
;
visible
:
camMode
.
visible
;
}
Rectangle
{
...
...
This diff is collapsed.
Click to expand it.
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