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
Oct 30, 2019
by
olliw42
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CameraManager: add BatteryStatus handling
parent
766774c1
Changes
5
Show 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()
...
@@ -263,6 +263,16 @@ QGCCameraControl::storageFreeStr()
return
QGCMapEngine
::
storageFreeSizeToString
(
static_cast
<
quint64
>
(
_storageFree
));
return
QGCMapEngine
::
storageFreeSizeToString
(
static_cast
<
quint64
>
(
_storageFree
));
}
}
//-----------------------------------------------------------------------------
QString
QGCCameraControl
::
batteryRemainingStr
()
{
if
(
_batteryRemaining
>=
0
)
{
return
QGCMapEngine
::
numberToString
(
static_cast
<
quint64
>
(
_batteryRemaining
))
+
" %"
;
}
return
""
;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
void
QGCCameraControl
::
setCameraMode
(
CameraMode
mode
)
QGCCameraControl
::
setCameraMode
(
CameraMode
mode
)
...
@@ -1490,6 +1500,17 @@ QGCCameraControl::handleStorageInfo(const mavlink_storage_information_t& st)
...
@@ -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
void
QGCCameraControl
::
handleCaptureStatus
(
const
mavlink_camera_capture_status_t
&
cap
)
QGCCameraControl
::
handleCaptureStatus
(
const
mavlink_camera_capture_status_t
&
cap
)
...
...
src/Camera/QGCCameraControl.h
View file @
225d1d15
...
@@ -155,6 +155,8 @@ public:
...
@@ -155,6 +155,8 @@ public:
Q_PROPERTY
(
quint32
storageFree
READ
storageFree
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
quint32
storageFree
READ
storageFree
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
QString
storageFreeStr
READ
storageFreeStr
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
QString
storageFreeStr
READ
storageFreeStr
NOTIFY
storageFreeChanged
)
Q_PROPERTY
(
quint32
storageTotal
READ
storageTotal
NOTIFY
storageTotalChanged
)
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
(
bool
paramComplete
READ
paramComplete
NOTIFY
parametersReady
)
Q_PROPERTY
(
qreal
zoomLevel
READ
zoomLevel
WRITE
setZoomLevel
NOTIFY
zoomLevelChanged
)
Q_PROPERTY
(
qreal
zoomLevel
READ
zoomLevel
WRITE
setZoomLevel
NOTIFY
zoomLevelChanged
)
...
@@ -232,6 +234,8 @@ public:
...
@@ -232,6 +234,8 @@ public:
virtual
quint32
storageFree
()
{
return
_storageFree
;
}
virtual
quint32
storageFree
()
{
return
_storageFree
;
}
virtual
QString
storageFreeStr
();
virtual
QString
storageFreeStr
();
virtual
quint32
storageTotal
()
{
return
_storageTotal
;
}
virtual
quint32
storageTotal
()
{
return
_storageTotal
;
}
virtual
int
batteryRemaining
()
{
return
_batteryRemaining
;
}
virtual
QString
batteryRemainingStr
();
virtual
bool
paramComplete
()
{
return
_paramComplete
;
}
virtual
bool
paramComplete
()
{
return
_paramComplete
;
}
virtual
qreal
zoomLevel
()
{
return
_zoomLevel
;
}
virtual
qreal
zoomLevel
()
{
return
_zoomLevel
;
}
virtual
qreal
focusLevel
()
{
return
_focusLevel
;
}
virtual
qreal
focusLevel
()
{
return
_focusLevel
;
}
...
@@ -273,6 +277,7 @@ public:
...
@@ -273,6 +277,7 @@ public:
virtual
void
handleParamAck
(
const
mavlink_param_ext_ack_t
&
ack
);
virtual
void
handleParamAck
(
const
mavlink_param_ext_ack_t
&
ack
);
virtual
void
handleParamValue
(
const
mavlink_param_ext_value_t
&
value
);
virtual
void
handleParamValue
(
const
mavlink_param_ext_value_t
&
value
);
virtual
void
handleStorageInfo
(
const
mavlink_storage_information_t
&
st
);
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
handleVideoInfo
(
const
mavlink_video_stream_information_t
*
vi
);
virtual
void
handleVideoStatus
(
const
mavlink_video_stream_status_t
*
vs
);
virtual
void
handleVideoStatus
(
const
mavlink_video_stream_status_t
*
vs
);
...
@@ -303,6 +308,7 @@ signals:
...
@@ -303,6 +308,7 @@ signals:
void
activeSettingsChanged
();
void
activeSettingsChanged
();
void
storageFreeChanged
();
void
storageFreeChanged
();
void
storageTotalChanged
();
void
storageTotalChanged
();
void
batteryRemainingChanged
();
void
dataReady
(
QByteArray
data
);
void
dataReady
(
QByteArray
data
);
void
parametersReady
();
void
parametersReady
();
void
zoomLevelChanged
();
void
zoomLevelChanged
();
...
@@ -373,6 +379,7 @@ protected:
...
@@ -373,6 +379,7 @@ protected:
qreal
_focusLevel
=
0
.
0
;
qreal
_focusLevel
=
0
.
0
;
uint32_t
_storageFree
=
0
;
uint32_t
_storageFree
=
0
;
uint32_t
_storageTotal
=
0
;
uint32_t
_storageTotal
=
0
;
int
_batteryRemaining
=
-
1
;
QNetworkAccessManager
*
_netManager
=
nullptr
;
QNetworkAccessManager
*
_netManager
=
nullptr
;
QString
_modelName
;
QString
_modelName
;
QString
_vendor
;
QString
_vendor
;
...
...
src/Camera/QGCCameraManager.cc
View file @
225d1d15
...
@@ -97,6 +97,9 @@ QGCCameraManager::_mavlinkMessageReceived(const mavlink_message_t& message)
...
@@ -97,6 +97,9 @@ QGCCameraManager::_mavlinkMessageReceived(const mavlink_message_t& message)
case
MAVLINK_MSG_ID_VIDEO_STREAM_STATUS
:
case
MAVLINK_MSG_ID_VIDEO_STREAM_STATUS
:
_handleVideoStreamStatus
(
message
);
_handleVideoStreamStatus
(
message
);
break
;
break
;
case
MAVLINK_MSG_ID_BATTERY_STATUS
:
_handleBatteryStatus
(
message
);
break
;
}
}
}
}
}
}
...
@@ -358,6 +361,18 @@ QGCCameraManager::_handleVideoStreamStatus(const mavlink_message_t& message)
...
@@ -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
void
QGCCameraManager
::
_requestCameraInfo
(
int
compID
)
QGCCameraManager
::
_requestCameraInfo
(
int
compID
)
...
...
src/Camera/QGCCameraManager.h
View file @
225d1d15
...
@@ -79,6 +79,7 @@ protected:
...
@@ -79,6 +79,7 @@ protected:
virtual
void
_handleCaptureStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleCaptureStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamInfo
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamInfo
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleVideoStreamStatus
(
const
mavlink_message_t
&
message
);
virtual
void
_handleBatteryStatus
(
const
mavlink_message_t
&
message
);
protected:
protected:
...
...
src/FlightMap/Widgets/CameraPageWidget.qml
View file @
225d1d15
...
@@ -45,6 +45,7 @@ Column {
...
@@ -45,6 +45,7 @@ Column {
property
bool
_hasModes
:
_camera
&&
_camera
&&
_camera
.
hasModes
property
bool
_hasModes
:
_camera
&&
_camera
&&
_camera
.
hasModes
property
bool
_videoRecording
:
_camera
&&
_camera
.
videoStatus
===
QGCCameraControl
.
VIDEO_CAPTURE_STATUS_RUNNING
property
bool
_videoRecording
:
_camera
&&
_camera
.
videoStatus
===
QGCCameraControl
.
VIDEO_CAPTURE_STATUS_RUNNING
property
bool
_storageReady
:
_camera
&&
_camera
.
storageStatus
===
QGCCameraControl
.
STORAGE_READY
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
_storageIgnored
:
_camera
&&
_camera
.
storageStatus
===
QGCCameraControl
.
STORAGE_NOT_SUPPORTED
property
bool
_canShoot
:
!
_videoRecording
&&
_cameraPhotoIdle
&&
((
_storageReady
&&
_camera
.
storageFree
>
0
)
||
_storageIgnored
)
property
bool
_canShoot
:
!
_videoRecording
&&
_cameraPhotoIdle
&&
((
_storageReady
&&
_camera
.
storageFree
>
0
)
||
_storageIgnored
)
property
int
_curCameraIndex
:
_dynamicCameras
?
_dynamicCameras
.
currentCamera
:
0
property
int
_curCameraIndex
:
_dynamicCameras
?
_dynamicCameras
.
currentCamera
:
0
...
@@ -76,6 +77,12 @@ Column {
...
@@ -76,6 +77,12 @@ Column {
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
visible
:
_camera
&&
_storageReady
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)
//-- Camera Mode (visible only if camera has modes)
Item
{
width
:
1
;
height
:
ScreenTools
.
defaultFontPixelHeight
*
0.75
;
visible
:
camMode
.
visible
;
}
Item
{
width
:
1
;
height
:
ScreenTools
.
defaultFontPixelHeight
*
0.75
;
visible
:
camMode
.
visible
;
}
Rectangle
{
Rectangle
{
...
...
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