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
3ff23278
Commit
3ff23278
authored
Mar 03, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2921 from DonLakeFlyer/TalkingBattery
Talking battery, plus other stuff
parents
859f08c9
7285dfb5
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
311 additions
and
292 deletions
+311
-292
qgroundcontrol.pro
qgroundcontrol.pro
+0
-4
FactTextField.qml
src/FactSystem/FactControls/FactTextField.qml
+1
-1
FactGroup.cc
src/FactSystem/FactGroup.cc
+15
-2
FactGroup.h
src/FactSystem/FactGroup.h
+3
-0
QGCInstrumentWidget.qml
src/FlightMap/Widgets/QGCInstrumentWidget.qml
+1
-2
ValuesWidget.qml
src/FlightMap/Widgets/ValuesWidget.qml
+1
-2
VibrationWidget.qml
src/FlightMap/Widgets/VibrationWidget.qml
+1
-2
GAudioOutput.cc
src/GAudioOutput.cc
+3
-4
GAudioOutput.h
src/GAudioOutput.h
+3
-3
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+1
-1
BatteryFact.json
src/Vehicle/BatteryFact.json
+10
-0
MultiVehicleManager.cc
src/Vehicle/MultiVehicleManager.cc
+3
-0
MultiVehicleManager.h
src/Vehicle/MultiVehicleManager.h
+4
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+176
-49
Vehicle.h
src/Vehicle/Vehicle.h
+53
-29
QGCAudioWorker.cpp
src/audio/QGCAudioWorker.cpp
+1
-31
QGCAudioWorker.h
src/audio/QGCAudioWorker.h
+2
-11
UAS.cc
src/uas/UAS.cc
+5
-129
UAS.h
src/uas/UAS.h
+0
-22
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+28
-0
No files found.
qgroundcontrol.pro
View file @
3ff23278
...
...
@@ -92,10 +92,6 @@ QT += \
bluetooth
\
}
contains
(
DEFINES
,
QGC_NOTIFY_TUNES_ENABLED
)
{
QT
+=
multimedia
}
#
testlib
is
needed
even
in
release
flavor
for
QSignalSpy
support
QT
+=
testlib
...
...
src/FactSystem/FactControls/FactTextField.qml
View file @
3ff23278
...
...
@@ -23,7 +23,7 @@ QGCTextField {
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
onEditingFinished
:
{
if
(
qgcView
)
{
if
(
typeof
qgcView
!==
'
undefined
'
&&
qgcView
)
{
var
errorString
=
fact
.
validate
(
text
,
false
/* convertOnly */
)
if
(
errorString
==
""
)
{
fact
.
value
=
text
...
...
src/FactSystem/FactGroup.cc
View file @
3ff23278
...
...
@@ -40,6 +40,9 @@ const char* FactGroup::_versionJsonKey = "version";
const
char
*
FactGroup
::
_typeJsonKey
=
"type"
;
const
char
*
FactGroup
::
_shortDescriptionJsonKey
=
"shortDescription"
;
const
char
*
FactGroup
::
_unitsJsonKey
=
"units"
;
const
char
*
FactGroup
::
_defaultValueJsonKey
=
"defaultValue"
;
const
char
*
FactGroup
::
_minJsonKey
=
"min"
;
const
char
*
FactGroup
::
_maxJsonKey
=
"max"
;
FactGroup
::
FactGroup
(
int
updateRateMsecs
,
const
QString
&
metaDataFile
,
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -187,8 +190,8 @@ void FactGroup::_loadMetaData(const QString& jsonFilename)
QStringList
keys
;
QList
<
QJsonValue
::
Type
>
types
;
keys
<<
_nameJsonKey
<<
_decimalPlacesJsonKey
;
types
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
;
keys
<<
_nameJsonKey
<<
_decimalPlacesJsonKey
<<
_typeJsonKey
<<
_shortDescriptionJsonKey
<<
_unitsJsonKey
<<
_defaultValueJsonKey
<<
_minJsonKey
<<
_maxJsonKey
;
types
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
;
if
(
!
JsonHelper
::
validateKeyTypes
(
jsonObject
,
keys
,
types
,
errorString
))
{
qWarning
()
<<
errorString
;
return
;
...
...
@@ -219,6 +222,16 @@ void FactGroup::_loadMetaData(const QString& jsonFilename)
metaData
->
setShortDescription
(
jsonObject
.
value
(
_shortDescriptionJsonKey
).
toString
());
metaData
->
setRawUnits
(
jsonObject
.
value
(
_unitsJsonKey
).
toString
());
if
(
jsonObject
.
contains
(
_defaultValueJsonKey
))
{
metaData
->
setRawDefaultValue
(
jsonObject
.
value
(
_defaultValueJsonKey
).
toDouble
());
}
if
(
jsonObject
.
contains
(
_minJsonKey
))
{
metaData
->
setRawMin
(
jsonObject
.
value
(
_minJsonKey
).
toDouble
());
}
if
(
jsonObject
.
contains
(
_maxJsonKey
))
{
metaData
->
setRawMax
(
jsonObject
.
value
(
_maxJsonKey
).
toDouble
());
}
for
(
int
i
=
0
;
i
<
enumValues
.
count
();
i
++
)
{
QVariant
enumVariant
;
QString
errorString
;
...
...
src/FactSystem/FactGroup.h
View file @
3ff23278
...
...
@@ -78,6 +78,9 @@ private:
static
const
char
*
_versionJsonKey
;
static
const
char
*
_shortDescriptionJsonKey
;
static
const
char
*
_unitsJsonKey
;
static
const
char
*
_defaultValueJsonKey
;
static
const
char
*
_minJsonKey
;
static
const
char
*
_maxJsonKey
;
};
#endif
src/FlightMap/Widgets/QGCInstrumentWidget.qml
View file @
3ff23278
...
...
@@ -131,7 +131,7 @@ Item {
Rectangle
{
anchors.fill
:
_valuesWidget
color
:
_backgroundColor
visible
:
!
_showCompass
&&
_activeVehicle
visible
:
!
_showCompass
radius
:
_spacing
}
...
...
@@ -145,7 +145,6 @@ Item {
}
}
Rectangle
{
id
:
_spacer2
height
:
1
...
...
src/FlightMap/Widgets/ValuesWidget.qml
View file @
3ff23278
...
...
@@ -33,7 +33,6 @@ import QGroundControl 1.0
QGCFlickable
{
id
:
_root
visible
:
_activeVehicle
height
:
Math
.
min
(
maxHeight
,
_smallFlow
.
y
+
_smallFlow
.
height
)
contentHeight
:
_smallFlow
.
y
+
_smallFlow
.
height
flickableDirection
:
Flickable
.
VerticalFlick
...
...
@@ -43,7 +42,7 @@ QGCFlickable {
property
color
textColor
property
var
maxHeight
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
?
QGroundControl
.
multiVehicleManager
.
activeVehicle
:
QGroundControl
.
multiVehicleManager
.
disconnectedVehicle
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
true
}
...
...
src/FlightMap/Widgets/VibrationWidget.qml
View file @
3ff23278
...
...
@@ -33,7 +33,6 @@ import QGroundControl 1.0
QGCFlickable
{
id
:
_root
visible
:
_activeVehicle
height
:
Math
.
min
(
maxHeight
,
innerItem
.
height
)
contentHeight
:
innerItem
.
height
flickableDirection
:
Flickable
.
VerticalFlick
...
...
@@ -43,7 +42,7 @@ QGCFlickable {
property
color
backgroundColor
property
var
maxHeight
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
?
QGroundControl
.
multiVehicleManager
.
activeVehicle
:
QGroundControl
.
multiVehicleManager
.
disconnectedVehicle
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
property
real
_barWidth
:
Math
.
round
(
ScreenTools
.
defaultFontPixelWidth
*
3
)
...
...
src/GAudioOutput.cc
View file @
3ff23278
...
...
@@ -88,12 +88,11 @@ bool GAudioOutput::isMuted()
return
muted
;
}
bool
GAudioOutput
::
say
(
const
QString
&
inText
,
int
severity
)
bool
GAudioOutput
::
say
(
const
QString
&
inText
)
{
if
(
!
muted
)
{
if
(
!
muted
&&
!
qgcApp
()
->
runningUnitTests
()
)
{
#if defined __android__
#if defined QGC_SPEECH_ENABLED
Q_UNUSED
(
severity
);
static
const
char
V_jniClassName
[]
{
"org/qgroundcontrol/qgchelper/UsbDeviceJNI"
};
QAndroidJniEnvironment
env
;
if
(
env
->
ExceptionCheck
())
{
...
...
@@ -105,7 +104,7 @@ bool GAudioOutput::say(const QString& inText, int severity)
QAndroidJniObject
::
callStaticMethod
<
void
>
(
V_jniClassName
,
"say"
,
"(Ljava/lang/String;)V"
,
javaMessage
.
object
<
jstring
>
());
#endif
#else
emit
textToSpeak
(
inText
,
severity
);
emit
textToSpeak
(
inText
);
#endif
}
return
true
;
...
...
src/GAudioOutput.h
View file @
3ff23278
...
...
@@ -79,14 +79,14 @@ public:
bool
isMuted
();
public
slots
:
/** @brief Say this text
if current output priority matches
*/
bool
say
(
const
QString
&
text
,
int
severity
=
6
);
/** @brief Say this text */
bool
say
(
const
QString
&
text
);
/** @brief Mute/unmute sound */
void
mute
(
bool
mute
);
signals:
void
mutedChanged
(
bool
);
bool
textToSpeak
(
QString
text
,
int
severity
=
1
);
bool
textToSpeak
(
QString
text
);
void
beepOnce
();
protected:
...
...
src/QmlControls/QGroundControlQmlGlobal.h
View file @
3ff23278
...
...
@@ -55,7 +55,7 @@ public:
Q_PROPERTY
(
LinkManager
*
linkManager
READ
linkManager
CONSTANT
)
Q_PROPERTY
(
MissionCommands
*
missionCommands
READ
missionCommands
CONSTANT
)
Q_PROPERTY
(
MultiVehicleManager
*
multiVehicleManager
READ
multiVehicleManager
CONSTANT
)
Q_PROPERTY
(
QGCMapEngineManager
*
mapEngineManager
READ
mapEngineManager
CONSTANT
)
Q_PROPERTY
(
QGCMapEngineManager
*
mapEngineManager
READ
mapEngineManager
CONSTANT
)
Q_PROPERTY
(
qreal
zOrderTopMost
READ
zOrderTopMost
CONSTANT
)
///< z order for top most items, toolbar, main window sub view
Q_PROPERTY
(
qreal
zOrderWidgets
READ
zOrderWidgets
CONSTANT
)
///< z order value to widgets, for example: zoom controls, hud widgetss
...
...
src/Vehicle/BatteryFact.json
View file @
3ff23278
...
...
@@ -16,6 +16,16 @@
"decimalPlaces"
:
0
,
"units"
:
"%"
},
{
"name"
:
"percentRemainingAnnounce"
,
"shortDescription"
:
"Percent"
,
"type"
:
"int32"
,
"decimalPlaces"
:
0
,
"units"
:
"%"
,
"defaultValue"
:
30
,
"min"
:
0
,
"max"
:
100
},
{
"name"
:
"mahConsumed"
,
"shortDescription"
:
"Consumed"
,
...
...
src/Vehicle/MultiVehicleManager.cc
View file @
3ff23278
...
...
@@ -50,6 +50,7 @@ MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
,
_activeVehicleAvailable
(
false
)
,
_parameterReadyVehicleAvailable
(
false
)
,
_activeVehicle
(
NULL
)
,
_disconnectedVehicle
(
NULL
)
,
_firmwarePluginManager
(
NULL
)
,
_autopilotPluginManager
(
NULL
)
,
_joystickManager
(
NULL
)
...
...
@@ -66,6 +67,8 @@ MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
if
(
_gcsHeartbeatEnabled
)
{
_gcsHeartbeatTimer
.
start
();
}
_disconnectedVehicle
=
new
Vehicle
(
this
);
}
void
MultiVehicleManager
::
setToolbox
(
QGCToolbox
*
toolbox
)
...
...
src/Vehicle/MultiVehicleManager.h
View file @
3ff23278
...
...
@@ -57,6 +57,9 @@ public:
Q_PROPERTY
(
QmlObjectListModel
*
vehicles
READ
vehicles
CONSTANT
)
Q_PROPERTY
(
bool
gcsHeartBeatEnabled
READ
gcsHeartbeatEnabled
WRITE
setGcsHeartbeatEnabled
NOTIFY
gcsHeartBeatEnabledChanged
)
/// A disconnected vehicle is used to access FactGroup information for the Vehicle object when no active vehicle is available
Q_PROPERTY
(
Vehicle
*
disconnectedVehicle
MEMBER
_disconnectedVehicle
CONSTANT
)
// Methods
Q_INVOKABLE
Vehicle
*
getVehicleById
(
int
vehicleId
);
...
...
@@ -104,6 +107,7 @@ private:
bool
_activeVehicleAvailable
;
///< true: An active vehicle is available
bool
_parameterReadyVehicleAvailable
;
///< true: An active vehicle with ready parameters is available
Vehicle
*
_activeVehicle
;
///< Currently active vehicle from a ui perspective
Vehicle
*
_disconnectedVehicle
;
///< Disconnected vechicle for FactGroup access
QList
<
Vehicle
*>
_vehiclesBeingDeleted
;
///< List of Vehicles being deleted in queued phases
Vehicle
*
_vehicleBeingSetActive
;
///< Vehicle being set active in queued phases
...
...
src/Vehicle/Vehicle.cc
View file @
3ff23278
This diff is collapsed.
Click to expand it.
src/Vehicle/Vehicle.h
View file @
3ff23278
...
...
@@ -29,6 +29,7 @@
#include <QObject>
#include <QGeoCoordinate>
#include <QElapsedTimer>
#include "FactGroup.h"
#include "LinkInterface.h"
...
...
@@ -36,6 +37,7 @@
#include "QmlObjectListModel.h"
#include "MAVLinkProtocol.h"
#include "UASMessageHandler.h"
#include "SettingsFact.h"
class
UAS
;
class
UASInterface
;
...
...
@@ -66,12 +68,12 @@ public:
Q_PROPERTY
(
Fact
*
clipCount2
READ
clipCount2
CONSTANT
)
Q_PROPERTY
(
Fact
*
clipCount3
READ
clipCount3
CONSTANT
)
Fact
*
xAxis
(
void
)
{
return
&
_xAxisFact
;
}
Fact
*
yAxis
(
void
)
{
return
&
_yAxisFact
;
}
Fact
*
zAxis
(
void
)
{
return
&
_zAxisFact
;
}
Fact
*
clipCount1
(
void
)
{
return
&
_clipCount1Fact
;
}
Fact
*
clipCount2
(
void
)
{
return
&
_clipCount2Fact
;
}
Fact
*
clipCount3
(
void
)
{
return
&
_clipCount3Fact
;
}
Fact
*
xAxis
(
void
)
{
return
&
_xAxisFact
;
}
Fact
*
yAxis
(
void
)
{
return
&
_yAxisFact
;
}
Fact
*
zAxis
(
void
)
{
return
&
_zAxisFact
;
}
Fact
*
clipCount1
(
void
)
{
return
&
_clipCount1Fact
;
}
Fact
*
clipCount2
(
void
)
{
return
&
_clipCount2Fact
;
}
Fact
*
clipCount3
(
void
)
{
return
&
_clipCount3Fact
;
}
void
setVehicle
(
Vehicle
*
vehicle
);
...
...
@@ -103,9 +105,9 @@ public:
Q_PROPERTY
(
Fact
*
speed
READ
speed
CONSTANT
)
Q_PROPERTY
(
Fact
*
verticalSpeed
READ
verticalSpeed
CONSTANT
)
Fact
*
direction
(
void
)
{
return
&
_directionFact
;
}
Fact
*
speed
(
void
)
{
return
&
_speedFact
;
}
Fact
*
verticalSpeed
(
void
)
{
return
&
_verticalSpeedFact
;
}
Fact
*
direction
(
void
)
{
return
&
_directionFact
;
}
Fact
*
speed
(
void
)
{
return
&
_speedFact
;
}
Fact
*
verticalSpeed
(
void
)
{
return
&
_verticalSpeedFact
;
}
void
setVehicle
(
Vehicle
*
vehicle
);
...
...
@@ -133,11 +135,11 @@ public:
Q_PROPERTY
(
Fact
*
count
READ
count
CONSTANT
)
Q_PROPERTY
(
Fact
*
lock
READ
lock
CONSTANT
)
Fact
*
hdop
(
void
)
{
return
&
_hdopFact
;
}
Fact
*
vdop
(
void
)
{
return
&
_vdopFact
;
}
Fact
*
courseOverGround
(
void
)
{
return
&
_courseOverGroundFact
;
}
Fact
*
count
(
void
)
{
return
&
_countFact
;
}
Fact
*
lock
(
void
)
{
return
&
_lockFact
;
}
Fact
*
hdop
(
void
)
{
return
&
_hdopFact
;
}
Fact
*
vdop
(
void
)
{
return
&
_vdopFact
;
}
Fact
*
courseOverGround
(
void
)
{
return
&
_courseOverGroundFact
;
}
Fact
*
count
(
void
)
{
return
&
_countFact
;
}
Fact
*
lock
(
void
)
{
return
&
_lockFact
;
}
void
setVehicle
(
Vehicle
*
vehicle
);
...
...
@@ -175,24 +177,33 @@ public:
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
)
Q_PROPERTY
(
Fact
*
cellCount
READ
cellCount
CONSTANT
)
/// If percentRemaining falls below this value, warning will be output through speech
Q_PROPERTY
(
Fact
*
percentRemainingAnnounce
READ
percentRemainingAnnounce
CONSTANT
)
Fact
*
voltage
(
void
)
{
return
&
_voltageFact
;
}
Fact
*
percentRemaining
(
void
)
{
return
&
_percentRemainingFact
;
}
Fact
*
percentRemainingAnnounce
(
void
)
{
return
&
_percentRemainingAnnounceFact
;
}
Fact
*
mahConsumed
(
void
)
{
return
&
_mahConsumedFact
;
}
Fact
*
current
(
void
)
{
return
&
_currentFact
;
}
Fact
*
temperature
(
void
)
{
return
&
_temperatureFact
;
}
Fact
*
cellCount
(
void
)
{
return
&
_cellCountFact
;
}
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
*
_percentRemainingAnnounceFactName
;
static
const
char
*
_mahConsumedFactName
;
static
const
char
*
_currentFactName
;
static
const
char
*
_temperatureFactName
;
static
const
char
*
_cellCountFactName
;
static
const
char
*
_settingsGroup
;
static
const
int
_percentRemainingAnnounceDefault
;
static
const
double
_voltageUnavailable
;
static
const
int
_percentRemainingUnavailable
;
static
const
int
_mahConsumedUnavailable
;
...
...
@@ -201,13 +212,15 @@ public:
static
const
int
_cellCountUnavailable
;
private:
Vehicle
*
_vehicle
;
Fact
_voltageFact
;
Fact
_percentRemainingFact
;
Fact
_mahConsumedFact
;
Fact
_currentFact
;
Fact
_temperatureFact
;
Fact
_cellCountFact
;
Vehicle
*
_vehicle
;
Fact
_voltageFact
;
Fact
_percentRemainingFact
;
Fact
_mahConsumedFact
;
Fact
_currentFact
;
Fact
_temperatureFact
;
Fact
_cellCountFact
;
static
SettingsFact
_percentRemainingAnnounceFact
;
};
class
Vehicle
:
public
FactGroup
...
...
@@ -222,6 +235,11 @@ public:
FirmwarePluginManager
*
firmwarePluginManager
,
AutoPilotPluginManager
*
autopilotPluginManager
,
JoystickManager
*
joystickManager
);
// The following is used to create a disconnected Vehicle. A disconnected vehicle is primarily used to access FactGroup information
// without needing a real connection.
Vehicle
(
QObject
*
parent
=
NULL
);
~
Vehicle
();
Q_PROPERTY
(
int
id
READ
id
CONSTANT
)
...
...
@@ -505,6 +523,7 @@ private slots:
void
_addNewMapTrajectoryPoint
(
void
);
void
_parametersReady
(
bool
parametersReady
);
void
_remoteControlRSSIChanged
(
uint8_t
rssi
);
void
_announceflightModeChanged
(
const
QString
&
flightMode
);
void
_handleTextMessage
(
int
newCount
);
void
_handletextMessageReceived
(
UASMessage
*
message
);
...
...
@@ -540,11 +559,13 @@ private:
void
_mapTrajectoryStart
(
void
);
void
_mapTrajectoryStop
(
void
);
void
_connectionActive
(
void
);
void
_say
(
const
QString
&
text
,
int
severity
);
void
_say
(
const
QString
&
text
);
QString
_vehicleIdSpeech
(
void
);
private:
int
_id
;
///< Mavlink system id
bool
_active
;
bool
_disconnectedVehicle
;
///< This Vehicle is a "disconnected" vehicle for ui use when no active vehicle is available
MAV_AUTOPILOT
_firmwareType
;
MAV_TYPE
_vehicleType
;
...
...
@@ -635,6 +656,9 @@ private:
uint8_t
_compID
;
bool
_heardFrom
;
static
const
int
_lowBatteryAnnounceRepeatMSecs
;
// Amount of time in between each low battery announcement
QElapsedTimer
_lowBatteryAnnounceTimer
;
// FactGroup facts
Fact
_rollFact
;
...
...
src/audio/QGCAudioWorker.cpp
View file @
3ff23278
...
...
@@ -76,9 +76,6 @@ QGCAudioWorker::QGCAudioWorker(QObject *parent) :
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
pVoice
(
NULL
),
#endif
#ifdef QGC_NOTIFY_TUNES_ENABLED
sound
(
NULL
),
#endif
emergency
(
false
),
muted
(
false
)
{
...
...
@@ -89,10 +86,6 @@ QGCAudioWorker::QGCAudioWorker(QObject *parent) :
void
QGCAudioWorker
::
init
()
{
#ifdef QGC_NOTIFY_TUNES_ENABLED
sound
=
new
QSound
(
":/res/Alert"
);
#endif
#if defined Q_OS_LINUX && !defined __android__ && defined QGC_SPEECH_ENABLED
espeak_Initialize
(
AUDIO_OUTPUT_SYNCH_PLAYBACK
,
500
,
NULL
,
0
);
// initialize for playback with 500ms buffer and no options (see speak_lib.h)
espeak_VOICE
*
espeak_voice
=
espeak_GetCurrentVoice
();
...
...
@@ -135,11 +128,10 @@ QGCAudioWorker::~QGCAudioWorker()
#endif
}
void
QGCAudioWorker
::
say
(
QString
inText
,
int
severity
)
void
QGCAudioWorker
::
say
(
QString
inText
)
{
#ifdef __android__
Q_UNUSED
(
inText
);
Q_UNUSED
(
severity
);
#else
static
bool
threadInit
=
false
;
if
(
!
threadInit
)
{
...
...
@@ -150,17 +142,6 @@ void QGCAudioWorker::say(QString inText, int severity)
if
(
!
muted
)
{
QString
text
=
fixTextMessageForAudio
(
inText
);
// Prepend high priority text with alert beep
if
(
severity
<
GAudioOutput
::
AUDIO_SEVERITY_CRITICAL
)
{
beep
();
}
#ifdef QGC_NOTIFY_TUNES_ENABLED
// Wait for the last sound to finish
while
(
!
sound
->
isFinished
())
{
QGC
::
SLEEP
::
msleep
(
100
);
}
#endif
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
HRESULT
hr
=
pVoice
->
Speak
(
text
.
toStdWString
().
c_str
(),
SPF_DEFAULT
,
NULL
);
...
...
@@ -195,17 +176,6 @@ void QGCAudioWorker::mute(bool mute)
}
}
void
QGCAudioWorker
::
beep
()
{
if
(
!
muted
)
{
#ifdef QGC_NOTIFY_TUNES_ENABLED
sound
->
play
(
":/res/Alert"
);
#endif
}
}
bool
QGCAudioWorker
::
isMuted
()
{
return
this
->
muted
;
...
...
src/audio/QGCAudioWorker.h
View file @
3ff23278
...
...
@@ -3,9 +3,6 @@
#include <QObject>
#include <QTimer>
#ifdef QGC_NOTIFY_TUNES_ENABLED
#include <QSound>
#endif
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
// Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx
...
...
@@ -29,19 +26,13 @@ public:
signals:
public
slots
:
/** @brief Say this text if current output priority matches */
void
say
(
QString
text
,
int
severity
=
1
);
/** @brief Sound a single beep */
void
beep
();
/** @brief Say this text */
void
say
(
QString
text
);
protected:
int
voiceIndex
;
///< The index of the flite voice to use (awb, slt, rms)
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
ISpVoice
*
pVoice
;
#endif
#ifdef QGC_NOTIFY_TUNES_ENABLED
QSound
*
sound
;
#endif
bool
emergency
;
///< Emergency status flag
QTimer
*
emergencyTimer
;
...
...
src/uas/UAS.cc
View file @
3ff23278
...
...
@@ -41,8 +41,6 @@
QGC_LOGGING_CATEGORY
(
UASLog
,
"UASLog"
)
#define UAS_DEFAULT_BATTERY_WARNLEVEL 20
/**
* Gets the settings from the previous UAS (name, airframe, autopilot, battery specs)
* by calling readSettings. This means the new UAS will have the same settings
...
...
@@ -63,17 +61,6 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle, FirmwarePluginManager * fi
custom_mode
(
0
),
status
(
-
1
),
startVoltage
(
-
1.0
f
),
tickVoltage
(
10.5
f
),
lastTickVoltageValue
(
13.0
f
),
tickLowpassVoltage
(
12.0
f
),
warnLevelPercent
(
UAS_DEFAULT_BATTERY_WARNLEVEL
),
currentVoltage
(
12.6
f
),
lpVoltage
(
-
1.0
f
),
currentCurrent
(
0.4
f
),
chargeLevel
(
-
1
),
lowBattAlarm
(
false
),
startTime
(
QGC
::
groundTimeMilliseconds
()),
onboardTimeOffset
(
0
),
...
...
@@ -294,12 +281,8 @@ void UAS::receiveMessage(mavlink_message_t message)
QString
audiostring
=
QString
(
"System %1"
).
arg
(
uasId
);
QString
stateAudio
=
""
;
QString
modeAudio
=
""
;
QString
navModeAudio
=
""
;
bool
statechanged
=
false
;
bool
modechanged
=
false
;
QString
audiomodeText
=
_firmwarePluginManager
->
firmwarePluginForAutopilot
((
MAV_AUTOPILOT
)
state
.
autopilot
,
(
MAV_TYPE
)
state
.
type
)
->
flightMode
(
state
.
base_mode
,
state
.
custom_mode
);
if
((
state
.
system_status
!=
this
->
status
)
&&
state
.
system_status
!=
MAV_STATE_UNINIT
)
{
...
...
@@ -318,27 +301,14 @@ void UAS::receiveMessage(mavlink_message_t message)
stateAudio
=
uasState
;
}
if
(
this
->
base_mode
!=
state
.
base_mode
||
this
->
custom_mode
!=
state
.
custom_mode
)
{
modechanged
=
true
;
this
->
base_mode
=
state
.
base_mode
;
this
->
custom_mode
=
state
.
custom_mode
;
modeAudio
=
" is now in "
+
audiomodeText
+
" flight mode"
;
}
// We got the mode
receivedMode
=
true
;
// AUDIO
if
(
modechanged
&&
statechanged
)
{
// Output both messages
audiostring
+=
modeAudio
+
" and "
+
stateAudio
;
}
else
if
(
modechanged
||
statechanged
)
if
(
statechanged
)
{
// Output the one message
audiostring
+=
modeAudio
+
stateAudio
;
audiostring
+=
stateAudio
;
}
if
(
statechanged
&&
((
int
)
state
.
system_status
==
(
int
)
MAV_STATE_CRITICAL
||
state
.
system_status
==
(
int
)
MAV_STATE_EMERGENCY
))
...
...
@@ -346,7 +316,7 @@ void UAS::receiveMessage(mavlink_message_t message)
_say
(
QString
(
"Emergency for system %1"
).
arg
(
this
->
getUASID
()),
GAudioOutput
::
AUDIO_SEVERITY_EMERGENCY
);
QTimer
::
singleShot
(
3000
,
qgcApp
()
->
toolbox
()
->
audioOutput
(),
SLOT
(
startEmergency
()));
}
else
if
(
modechanged
||
statechanged
)
else
if
(
statechanged
)
{
_say
(
audiostring
.
toLower
());
}
...
...
@@ -378,62 +348,6 @@ void UAS::receiveMessage(mavlink_message_t message)
emit
loadChanged
(
this
,
state
.
load
/
10.0
f
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"load"
),
"%"
,
state
.
load
/
10.0
f
,
time
);
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
if
(
state
.
voltage_battery
>
0.0
f
&&
state
.
voltage_battery
!=
UINT16_MAX
)
{
// Battery charge/time remaining/voltage calculations
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
filterVoltage
(
currentVoltage
);
tickLowpassVoltage
=
tickLowpassVoltage
*
0.8
f
+
0.2
f
*
currentVoltage
;
// We don't want to tick above the threshold
if
(
tickLowpassVoltage
>
tickVoltage
)
{
lastTickVoltageValue
=
tickLowpassVoltage
;
}
if
((
startVoltage
>
0.0
f
)
&&
(
tickLowpassVoltage
<
tickVoltage
)
&&
(
fabs
(
lastTickVoltageValue
-
tickLowpassVoltage
)
>
0.1
f
)
/* warn if lower than treshold */
&&
(
lpVoltage
<
tickVoltage
)
/* warn only if we have at least the voltage of an empty LiPo cell, else we're sampling something wrong */
&&
(
currentVoltage
>
3.3
f
)
/* warn only if current voltage is really still lower by a reasonable amount */
&&
((
currentVoltage
-
0.2
f
)
<
tickVoltage
)
/* warn only every 20 seconds */
&&
(
QGC
::
groundTimeUsecs
()
-
lastVoltageWarning
)
>
20000000
)
{
_say
(
QString
(
"Low battery system %1: %2 volts"
).
arg
(
getUASID
()).
arg
(
lpVoltage
,
0
,
'f'
,
1
,
QChar
(
' '
)));
lastVoltageWarning
=
QGC
::
groundTimeUsecs
();
lastTickVoltageValue
=
tickLowpassVoltage
;
}
if
(
startVoltage
==
-
1.0
f
&&
currentVoltage
>
0.1
f
)
startVoltage
=
currentVoltage
;
chargeLevel
=
state
.
battery_remaining
;
emit
batteryChanged
(
this
,
lpVoltage
,
currentCurrent
,
getChargeLevel
(),
0
);
}
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_remaining"
),
"%"
,
getChargeLevel
(),
time
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_voltage"
),
"V"
,
currentVoltage
,
time
);
// And if the battery current draw is measured, log that also.
if
(
state
.
current_battery
!=
-
1
)
{
currentCurrent
=
((
double
)
state
.
current_battery
)
/
100.0
f
;
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_current"
),
"A"
,
currentCurrent
,
time
);
}
// LOW BATTERY ALARM
if
(
chargeLevel
>=
0
&&
(
getChargeLevel
()
<
warnLevelPercent
))
{
// An audio alarm. Does not generate any signals.
startLowBattAlarm
();
}
else
{
stopLowBattAlarm
();
}
// control_sensors_enabled:
// relevant bits: 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control
emit
attitudeControlEnabled
(
state
.
onboard_control_sensors_enabled
&
(
1
<<
11
));
...
...
@@ -1178,19 +1092,6 @@ quint64 UAS::getUnixTime(quint64 time)
return
ret
;
}
/**
* @param value battery voltage
*/
float
UAS
::
filterVoltage
(
float
value
)
{
if
(
lpVoltage
<
0.0
f
)
{
lpVoltage
=
value
;
}
lpVoltage
=
lpVoltage
*
0.6
f
+
value
*
0.4
f
;
return
lpVoltage
;
}
/**
* Get the status of the code and a description of the status.
* Status can be unitialized, booting up, calibrating sensors, active
...
...
@@ -2077,31 +1978,6 @@ QMap<int, QString> UAS::getComponents()
return
components
;
}
/**
* @return charge level in percent - 0 - 100
*/
float
UAS
::
getChargeLevel
()
{
return
chargeLevel
;
}
void
UAS
::
startLowBattAlarm
()
{
if
(
!
lowBattAlarm
)
{
_say
(
tr
(
"System %1 has low battery"
).
arg
(
getUASID
()));
lowBattAlarm
=
true
;
}
}
void
UAS
::
stopLowBattAlarm
()
{
if
(
lowBattAlarm
)
{
lowBattAlarm
=
false
;
}
}
void
UAS
::
sendMapRCToParam
(
QString
param_id
,
float
scale
,
float
value0
,
quint8
param_rc_channel_index
,
float
valueMin
,
float
valueMax
)
{
if
(
!
_vehicle
)
{
...
...
@@ -2164,8 +2040,8 @@ void UAS::unsetRCToParameterMap()
void
UAS
::
_say
(
const
QString
&
text
,
int
severity
)
{
if
(
!
qgcApp
()
->
runningUnitTests
())
qgcApp
()
->
toolbox
()
->
audioOutput
()
->
say
(
text
,
severity
);
Q_UNUSED
(
severity
);
qgcApp
()
->
toolbox
()
->
audioOutput
()
->
say
(
text
);
}
void
UAS
::
shutdownVehicle
(
void
)
...
...
src/uas/UAS.h
View file @
3ff23278
...
...
@@ -77,8 +77,6 @@ public:
/** @brief The time interval the robot is switched on */
quint64
getUptime
()
const
;
/** @brief Add one measurement and get low-passed voltage */
float
filterVoltage
(
float
value
);
Q_PROPERTY
(
double
latitude
READ
getLatitude
WRITE
setLatitude
NOTIFY
latitudeChanged
)
Q_PROPERTY
(
double
longitude
READ
getLongitude
WRITE
setLongitude
NOTIFY
longitudeChanged
)
...
...
@@ -376,21 +374,6 @@ protected: //COMMENTS FOR TEST UNIT
uint32_t
custom_mode
;
///< The current mode of the MAV
int
status
;
///< The current status of the MAV
// dongfang: This looks like a candidate for being moved off to a separate class.
/// BATTERY / ENERGY
float
startVoltage
;
///< Voltage at system start
float
tickVoltage
;
///< Voltage where 0.1 V ticks are told
float
lastTickVoltageValue
;
///< The last voltage where a tick was announced
float
tickLowpassVoltage
;
///< Lowpass-filtered voltage for the tick announcement
float
warnLevelPercent
;
///< Warning level, in percent
double
currentVoltage
;
///< Voltage currently measured
float
lpVoltage
;
///< Low-pass filtered voltage
double
currentCurrent
;
///< Battery current currently measured
bool
batteryRemainingEstimateEnabled
;
///< If the estimate is enabled, QGC will try to estimate the remaining battery life
float
chargeLevel
;
///< Charge level of battery, in percent
bool
lowBattAlarm
;
///< Switch if battery is low
/// TIMEKEEPING
quint64
startTime
;
///< The time the UAS was switched on
quint64
onboardTimeOffset
;
...
...
@@ -486,8 +469,6 @@ protected: //COMMENTS FOR TEST UNIT
#endif
public:
/** @brief Get the current charge level */
float
getChargeLevel
();
/** @brief Get the human-readable status message for this code */
void
getStatusForCode
(
int
statusCode
,
QString
&
uasState
,
QString
&
stateDescription
);
...
...
@@ -559,9 +540,6 @@ public slots:
void
stopHil
();
#endif
void
startLowBattAlarm
();
void
stopLowBattAlarm
();
/** @brief Set the values for the manual control of the vehicle */
void
setExternalControlSetpoint
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
quint16
buttons
,
int
joystickMode
);
...
...
src/ui/preferences/GeneralSettings.qml
View file @
3ff23278
...
...
@@ -40,6 +40,8 @@ Rectangle {
anchors.fill
:
parent
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
property
Fact
_percentRemainingAnnounce
:
QGroundControl
.
multiVehicleManager
.
disconnectedVehicle
.
battery
.
percentRemainingAnnounce
QGCPalette
{
id
:
qgcPal
colorGroupEnabled
:
enabled
...
...
@@ -127,6 +129,32 @@ Rectangle {
}
}
}
//-----------------------------------------------------------------
//-- Battery talker
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCCheckBox
{
id
:
announcePercentCheckbox
anchors.baseline
:
announcePercent
.
baseline
text
:
"
Announce battery percent lower than:
"
checked
:
_percentRemainingAnnounce
.
value
!=
0
onClicked
:
{
if
(
checked
)
{
_percentRemainingAnnounce
.
value
=
_percentRemainingAnnounce
.
defaultValueString
}
else
{
_percentRemainingAnnounce
.
value
=
0
}
}
}
FactTextField
{
id
:
announcePercent
fact
:
_percentRemainingAnnounce
enabled
:
announcePercentCheckbox
.
checked
}
}
Item
{
height
:
ScreenTools
.
defaultFontPixelHeight
/
2
...
...
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