Commit 7285dfb5 authored by Don Gagne's avatar Don Gagne

Talking battery and flight modes

parent 33edc725
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
"decimalPlaces": 0, "decimalPlaces": 0,
"units": "%" "units": "%"
}, },
{
"name": "percentRemainingAnnounce",
"shortDescription": "Percent",
"type": "int32",
"decimalPlaces": 0,
"units": "%",
"defaultValue": 30,
"min": 0,
"max": 100
},
{ {
"name": "mahConsumed", "name": "mahConsumed",
"shortDescription": "Consumed", "shortDescription": "Consumed",
......
This diff is collapsed.
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <QObject> #include <QObject>
#include <QGeoCoordinate> #include <QGeoCoordinate>
#include <QElapsedTimer>
#include "FactGroup.h" #include "FactGroup.h"
#include "LinkInterface.h" #include "LinkInterface.h"
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
#include "QmlObjectListModel.h" #include "QmlObjectListModel.h"
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
#include "UASMessageHandler.h" #include "UASMessageHandler.h"
#include "SettingsFact.h"
class UAS; class UAS;
class UASInterface; class UASInterface;
...@@ -66,12 +68,12 @@ public: ...@@ -66,12 +68,12 @@ public:
Q_PROPERTY(Fact* clipCount2 READ clipCount2 CONSTANT) Q_PROPERTY(Fact* clipCount2 READ clipCount2 CONSTANT)
Q_PROPERTY(Fact* clipCount3 READ clipCount3 CONSTANT) Q_PROPERTY(Fact* clipCount3 READ clipCount3 CONSTANT)
Fact* xAxis(void) { return &_xAxisFact; } Fact* xAxis (void) { return &_xAxisFact; }
Fact* yAxis(void) { return &_yAxisFact; } Fact* yAxis (void) { return &_yAxisFact; }
Fact* zAxis(void) { return &_zAxisFact; } Fact* zAxis (void) { return &_zAxisFact; }
Fact* clipCount1(void) { return &_clipCount1Fact; } Fact* clipCount1 (void) { return &_clipCount1Fact; }
Fact* clipCount2(void) { return &_clipCount2Fact; } Fact* clipCount2 (void) { return &_clipCount2Fact; }
Fact* clipCount3(void) { return &_clipCount3Fact; } Fact* clipCount3 (void) { return &_clipCount3Fact; }
void setVehicle(Vehicle* vehicle); void setVehicle(Vehicle* vehicle);
...@@ -103,9 +105,9 @@ public: ...@@ -103,9 +105,9 @@ public:
Q_PROPERTY(Fact* speed READ speed CONSTANT) Q_PROPERTY(Fact* speed READ speed CONSTANT)
Q_PROPERTY(Fact* verticalSpeed READ verticalSpeed CONSTANT) Q_PROPERTY(Fact* verticalSpeed READ verticalSpeed CONSTANT)
Fact* direction(void) { return &_directionFact; } Fact* direction (void) { return &_directionFact; }
Fact* speed(void) { return &_speedFact; } Fact* speed (void) { return &_speedFact; }
Fact* verticalSpeed(void) { return &_verticalSpeedFact; } Fact* verticalSpeed (void) { return &_verticalSpeedFact; }
void setVehicle(Vehicle* vehicle); void setVehicle(Vehicle* vehicle);
...@@ -133,11 +135,11 @@ public: ...@@ -133,11 +135,11 @@ public:
Q_PROPERTY(Fact* count READ count CONSTANT) Q_PROPERTY(Fact* count READ count CONSTANT)
Q_PROPERTY(Fact* lock READ lock CONSTANT) Q_PROPERTY(Fact* lock READ lock CONSTANT)
Fact* hdop(void) { return &_hdopFact; } Fact* hdop (void) { return &_hdopFact; }
Fact* vdop(void) { return &_vdopFact; } Fact* vdop (void) { return &_vdopFact; }
Fact* courseOverGround(void) { return &_courseOverGroundFact; } Fact* courseOverGround (void) { return &_courseOverGroundFact; }
Fact* count(void) { return &_countFact; } Fact* count (void) { return &_countFact; }
Fact* lock(void) { return &_lockFact; } Fact* lock (void) { return &_lockFact; }
void setVehicle(Vehicle* vehicle); void setVehicle(Vehicle* vehicle);
...@@ -175,24 +177,33 @@ public: ...@@ -175,24 +177,33 @@ public:
Q_PROPERTY(Fact* mahConsumed READ mahConsumed CONSTANT) Q_PROPERTY(Fact* mahConsumed READ mahConsumed CONSTANT)
Q_PROPERTY(Fact* current READ current CONSTANT) Q_PROPERTY(Fact* current READ current CONSTANT)
Q_PROPERTY(Fact* temperature READ temperature 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); void setVehicle(Vehicle* vehicle);
static const char* _voltageFactName; static const char* _voltageFactName;
static const char* _percentRemainingFactName; static const char* _percentRemainingFactName;
static const char* _percentRemainingAnnounceFactName;
static const char* _mahConsumedFactName; static const char* _mahConsumedFactName;
static const char* _currentFactName; static const char* _currentFactName;
static const char* _temperatureFactName; static const char* _temperatureFactName;
static const char* _cellCountFactName; static const char* _cellCountFactName;
static const char* _settingsGroup;
static const int _percentRemainingAnnounceDefault;
static const double _voltageUnavailable; static const double _voltageUnavailable;
static const int _percentRemainingUnavailable; static const int _percentRemainingUnavailable;
static const int _mahConsumedUnavailable; static const int _mahConsumedUnavailable;
...@@ -201,13 +212,15 @@ public: ...@@ -201,13 +212,15 @@ public:
static const int _cellCountUnavailable; static const int _cellCountUnavailable;
private: private:
Vehicle* _vehicle; Vehicle* _vehicle;
Fact _voltageFact; Fact _voltageFact;
Fact _percentRemainingFact; Fact _percentRemainingFact;
Fact _mahConsumedFact; Fact _mahConsumedFact;
Fact _currentFact; Fact _currentFact;
Fact _temperatureFact; Fact _temperatureFact;
Fact _cellCountFact; Fact _cellCountFact;
static SettingsFact _percentRemainingAnnounceFact;
}; };
class Vehicle : public FactGroup class Vehicle : public FactGroup
...@@ -222,6 +235,11 @@ public: ...@@ -222,6 +235,11 @@ public:
FirmwarePluginManager* firmwarePluginManager, FirmwarePluginManager* firmwarePluginManager,
AutoPilotPluginManager* autopilotPluginManager, AutoPilotPluginManager* autopilotPluginManager,
JoystickManager* joystickManager); 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(); ~Vehicle();
Q_PROPERTY(int id READ id CONSTANT) Q_PROPERTY(int id READ id CONSTANT)
...@@ -505,6 +523,7 @@ private slots: ...@@ -505,6 +523,7 @@ private slots:
void _addNewMapTrajectoryPoint(void); void _addNewMapTrajectoryPoint(void);
void _parametersReady(bool parametersReady); void _parametersReady(bool parametersReady);
void _remoteControlRSSIChanged(uint8_t rssi); void _remoteControlRSSIChanged(uint8_t rssi);
void _announceflightModeChanged(const QString& flightMode);
void _handleTextMessage (int newCount); void _handleTextMessage (int newCount);
void _handletextMessageReceived (UASMessage* message); void _handletextMessageReceived (UASMessage* message);
...@@ -540,11 +559,13 @@ private: ...@@ -540,11 +559,13 @@ private:
void _mapTrajectoryStart(void); void _mapTrajectoryStart(void);
void _mapTrajectoryStop(void); void _mapTrajectoryStop(void);
void _connectionActive(void); void _connectionActive(void);
void _say(const QString& text, int severity); void _say(const QString& text);
QString _vehicleIdSpeech(void);
private: private:
int _id; ///< Mavlink system id int _id; ///< Mavlink system id
bool _active; bool _active;
bool _disconnectedVehicle; ///< This Vehicle is a "disconnected" vehicle for ui use when no active vehicle is available
MAV_AUTOPILOT _firmwareType; MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType; MAV_TYPE _vehicleType;
...@@ -635,6 +656,9 @@ private: ...@@ -635,6 +656,9 @@ private:
uint8_t _compID; uint8_t _compID;
bool _heardFrom; bool _heardFrom;
static const int _lowBatteryAnnounceRepeatMSecs; // Amount of time in between each low battery announcement
QElapsedTimer _lowBatteryAnnounceTimer;
// FactGroup facts // FactGroup facts
Fact _rollFact; Fact _rollFact;
......
...@@ -40,6 +40,8 @@ Rectangle { ...@@ -40,6 +40,8 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
property Fact _percentRemainingAnnounce: QGroundControl.multiVehicleManager.disconnectedVehicle.battery.percentRemainingAnnounce
QGCPalette { QGCPalette {
id: qgcPal id: qgcPal
colorGroupEnabled: enabled colorGroupEnabled: enabled
...@@ -127,6 +129,32 @@ Rectangle { ...@@ -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 { Item {
height: ScreenTools.defaultFontPixelHeight / 2 height: ScreenTools.defaultFontPixelHeight / 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment