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
b4688783
Commit
b4688783
authored
May 24, 2014
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not allow the PFD to turn QGC into a CPU hog
parent
6ba52995
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
PrimaryFlightDisplay.cc
src/ui/PrimaryFlightDisplay.cc
+57
-4
PrimaryFlightDisplay.h
src/ui/PrimaryFlightDisplay.h
+6
-0
No files found.
src/ui/PrimaryFlightDisplay.cc
View file @
b4688783
...
...
@@ -141,7 +141,9 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
instrumentOpagueBackground
(
QColor
::
fromHsvF
(
0
,
0
,
0.3
,
1.0
)),
font
(
"Bitstream Vera Sans"
),
refreshTimer
(
new
QTimer
(
this
))
refreshTimer
(
new
QTimer
(
this
)),
_valuesChanged
(
false
),
_valuesLastPainted
(
QGC
::
groundTimeMilliseconds
())
{
Q_UNUSED
(
width
);
Q_UNUSED
(
height
);
...
...
@@ -159,7 +161,7 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
// Refresh timer
refreshTimer
->
setInterval
(
updateInterval
);
// connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintHUD()));
connect
(
refreshTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
u
pdate
()));
connect
(
refreshTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
checkU
pdate
()));
}
PrimaryFlightDisplay
::~
PrimaryFlightDisplay
()
...
...
@@ -224,6 +226,15 @@ void PrimaryFlightDisplay::paintEvent(QPaintEvent *event)
doPaint
();
}
void
PrimaryFlightDisplay
::
checkUpdate
()
{
if
(
uas
&&
(
_valuesChanged
||
(
QGC
::
groundTimeMilliseconds
()
-
_valuesLastPainted
)
>
260
))
{
update
();
_valuesChanged
=
false
;
_valuesLastPainted
=
QGC
::
groundTimeMilliseconds
();
}
}
///*
// * Interface towards qgroundcontrol
// */
...
...
@@ -280,24 +291,45 @@ void PrimaryFlightDisplay::updateAttitude(UASInterface* uas, double roll, double
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
timestamp
);
// Called from UAS.cc l. 616
if
(
isinf
(
roll
))
{
this
->
roll
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
else
{
this
->
roll
=
roll
*
(
180.0
/
M_PI
);
float
rolldeg
=
roll
*
(
180.0
/
M_PI
);
if
(
fabsf
(
roll
-
rolldeg
)
>
2.5
f
)
{
_valuesChanged
=
true
;
}
this
->
roll
=
rolldeg
;
}
if
(
isinf
(
pitch
))
{
this
->
pitch
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
else
{
this
->
pitch
=
pitch
*
(
180.0
/
M_PI
);
float
pitchdeg
=
pitch
*
(
180.0
/
M_PI
);
if
(
fabsf
(
pitch
-
pitchdeg
)
>
2.5
f
)
{
_valuesChanged
=
true
;
}
this
->
pitch
=
pitchdeg
;
}
if
(
isinf
(
yaw
))
{
this
->
heading
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
else
{
yaw
=
yaw
*
(
180.0
/
M_PI
);
if
(
yaw
<
0
)
yaw
+=
360
;
if
(
fabsf
(
heading
-
yaw
)
>
10.0
f
)
{
_valuesChanged
=
true
;
}
this
->
heading
=
yaw
;
}
...
...
@@ -314,6 +346,14 @@ void PrimaryFlightDisplay::updateSpeed(UASInterface* uas, double _groundSpeed, d
Q_UNUSED
(
uas
);
Q_UNUSED
(
timestamp
);
if
(
fabsf
(
groundSpeed
-
_groundSpeed
)
>
0.5
f
)
{
_valuesChanged
=
true
;
}
if
(
fabsf
(
airSpeed
-
_airSpeed
)
>
1.0
f
)
{
_valuesChanged
=
true
;
}
groundSpeed
=
_groundSpeed
;
airSpeed
=
_airSpeed
;
}
...
...
@@ -321,6 +361,19 @@ void PrimaryFlightDisplay::updateSpeed(UASInterface* uas, double _groundSpeed, d
void
PrimaryFlightDisplay
::
updateAltitude
(
UASInterface
*
uas
,
double
_altitudeAMSL
,
double
_altitudeRelative
,
double
_climbRate
,
quint64
timestamp
)
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
timestamp
);
if
(
fabsf
(
altitudeAMSL
-
_altitudeAMSL
)
>
0.5
f
)
{
_valuesChanged
=
true
;
}
if
(
fabsf
(
altitudeRelative
-
_altitudeRelative
)
>
0.5
f
)
{
_valuesChanged
=
true
;
}
if
(
fabsf
(
climbRate
-
_climbRate
)
>
0.5
f
)
{
_valuesChanged
=
true
;
}
altitudeAMSL
=
_altitudeAMSL
;
altitudeRelative
=
_altitudeRelative
;
climbRate
=
_climbRate
;
...
...
src/ui/PrimaryFlightDisplay.h
View file @
b4688783
...
...
@@ -27,7 +27,13 @@ public slots:
void
forgetUAS
(
UASInterface
*
uas
);
void
setActiveUAS
(
UASInterface
*
uas
);
void
checkUpdate
();
protected:
bool
_valuesChanged
;
quint64
_valuesLastPainted
;
enum
Layout
{
COMPASS_INTEGRATED
,
COMPASS_SEPARATED
// For a very high container. Feature panels are at bottom.
...
...
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