Commit d98b1a80 authored by dogmaphobic's avatar dogmaphobic

Initial Battery Config

parent 94e718b6
......@@ -742,6 +742,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
src/AutoPilotPlugins/PX4/PowerComponent.h \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \
SOURCES += \
......@@ -764,6 +765,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
src/AutoPilotPlugins/PX4/PowerComponent.cc \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \
# Fact System code
......
......@@ -247,13 +247,11 @@
<qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file>
<file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
<file alias="QGroundControl/FactControls/qmldir">src/FactSystem/FactControls/qmldir</file>
<file alias="QGroundControl/FactControls/FactLabel.qml">src/FactSystem/FactControls/FactLabel.qml</file>
<file alias="QGroundControl/FactControls/FactTextField.qml">src/FactSystem/FactControls/FactTextField.qml</file>
<file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
<file alias="QGroundControl/FactControls/FactComboBox.qml">src/FactSystem/FactControls/FactComboBox.qml</file>
<file alias="QGroundControl/Controls/qmldir">src/QmlControls/qmldir</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
......@@ -263,30 +261,26 @@
<file alias="QGroundControl/Controls/QGCComboBox.qml">src/QmlControls/QGCComboBox.qml</file>
<file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
<file alias="QGroundControl/Controls/QGCToolBarButton.qml">src/QmlControls/QGCToolBarButton.qml</file>
<file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<file alias="QGroundControl/Controls/arrow-down.png">src/QmlControls/arrow-down.png</file>
<file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
<file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
<file alias="SetupViewButtons.qml">src/VehicleSetup/SetupViewButtons.qml</file>
<file alias="VehicleSummary.qml">src/VehicleSetup/VehicleSummary.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
<file alias="PowerComponent.qml">src/AutoPilotPlugins/PX4/PowerComponent.qml</file>
<file alias="SensorsComponent.qml">src/AutoPilotPlugins/PX4/SensorsComponent.qml</file>
<file alias="FlightModesComponent.qml">src/AutoPilotPlugins/PX4/FlightModesComponent.qml</file>
<file alias="SafetyComponentSummary.qml">src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml</file>
<file alias="PowerComponentSummary.qml">src/AutoPilotPlugins/PX4/PowerComponentSummary.qml</file>
<file alias="SensorsComponentSummary.qml">src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml</file>
<file alias="SensorsComponentSummaryFixedWing.qml">src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml</file>
<file alias="RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/RadioComponentSummary.qml</file>
<file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
<file alias="AirframeComponentSummary.qml">src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml</file>
<file alias="SafetyComponentTree.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png</file>
<file alias="SafetyComponentHome.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentHome.png</file>
<file alias="SafetyComponentArrowDown.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentArrowDown.png</file>
......@@ -297,16 +291,15 @@
<file alias="VehicleRight.png">src/AutoPilotPlugins/PX4/Images/VehicleRight.png</file>
<file alias="VehicleNoseDown.png">src/AutoPilotPlugins/PX4/Images/VehicleNoseDown.png</file>
<file alias="VehicleTailDown.png">src/AutoPilotPlugins/PX4/Images/VehicleTailDown.png</file>
<file alias="QGroundControl/Controls/subMenuButtonImage.png">files/Setup/cogwheels.png</file>
<file alias="QGroundControl/Controls/SensorsComponentIcon.png">src/AutoPilotPlugins/PX4/Images/SensorsComponentIcon.png</file>
<file alias="QGroundControl/Controls/RadioComponentIcon.png">src/AutoPilotPlugins/PX4/Images/RadioComponentIcon.png</file>
<file alias="QGroundControl/Controls/FlightModesComponentIcon.png">src/AutoPilotPlugins/PX4/Images/FlightModesComponentIcon.png</file>
<file alias="QGroundControl/Controls/AirframeComponentIcon.png">src/AutoPilotPlugins/PX4/Images/AirframeComponentIcon.png</file>
<file alias="QGroundControl/Controls/SafetyComponentIcon.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentIcon.png</file>
<file alias="QGroundControl/Controls/PowerComponentIcon.png">src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png</file>
<file alias="QGroundControl/Controls/FirmwareUpgradeIcon.png">src/VehicleSetup/FirmwareUpgradeIcon.png</file>
<file alias="QGroundControl/Controls/VehicleSummaryIcon.png">src/VehicleSetup/VehicleSummaryIcon.png</file>
<file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
......
......@@ -70,6 +70,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
_flightModesComponent(NULL),
_sensorsComponent(NULL),
_safetyComponent(NULL),
_powerComponent(NULL),
_incorrectParameterVersion(false)
{
Q_ASSERT(uas);
......@@ -214,6 +215,10 @@ const QVariantList& PX4AutoPilotPlugin::components(void)
Q_CHECK_PTR(_sensorsComponent);
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
_powerComponent = new PowerComponent(_uas, this);
Q_CHECK_PTR(_powerComponent);
_components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
_safetyComponent = new SafetyComponent(_uas, this);
Q_CHECK_PTR(_safetyComponent);
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));
......
......@@ -33,6 +33,7 @@
#include "FlightModesComponent.h"
#include "SensorsComponent.h"
#include "SafetyComponent.h"
#include "PowerComponent.h"
#include <QImage>
......@@ -64,7 +65,8 @@ public:
FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; }
PowerComponent* powerComponent(void) { return _powerComponent; }
private slots:
void _checkForIncorrectParameterVersion(void);
......@@ -76,6 +78,7 @@ private:
FlightModesComponent* _flightModesComponent;
SensorsComponent* _sensorsComponent;
SafetyComponent* _safetyComponent;
PowerComponent* _powerComponent;
bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed
};
......
......@@ -5,17 +5,20 @@
<short_desc>Empty cell voltage</short_desc>
<long_desc>Defines the voltage where a single cell of the battery is considered empty.</long_desc>
<default>3.4</default>
<unit>V</unit>
</parameter>
<parameter name="BAT_V_CHARGED" type="FLOAT">
<short_desc>Full cell voltage</short_desc>
<long_desc>Defines the voltage where a single cell of the battery is considered full.</long_desc>
<default>4.2</default>
<unit>V</unit>
</parameter>
<parameter name="BAT_V_LOAD_DROP" type="FLOAT">
<short_desc>Voltage drop per cell on 100% load</short_desc>
<long_desc>This implicitely defines the internal resistance
to maximum current ratio and assumes linearity.</long_desc>
<default>0.07</default>
<unit>V</unit>
</parameter>
<parameter name="BAT_N_CELLS" type="INT32">
<short_desc>Number of cells</short_desc>
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Gus Grubba <mavlink@grubba.com>
#include "PowerComponent.h"
#include "PX4RCCalibration.h"
#include "QGCQmlWidgetHolder.h"
#include "PX4AutoPilotPlugin.h"
PowerComponent::PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Power"))
{
}
QString PowerComponent::name(void) const
{
return _name;
}
QString PowerComponent::description(void) const
{
return tr("The Power Component is used to setup battery parameters as well as advanced settings for propellers and magnetometer.");
}
QString PowerComponent::iconResource(void) const
{
return "PowerComponentIcon.png";
}
bool PowerComponent::requiresSetup(void) const
{
return true;
}
bool PowerComponent::setupComplete(void) const
{
QVariant cvalue, evalue, nvalue;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_CHARGED", cvalue)) {
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_EMPTY", evalue)) {
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_N_CELLS", nvalue)) {
return (cvalue.toFloat() > 0.1f) && (evalue.toFloat() > 0.1f) && (nvalue.toInt() > 0);
}
}
}
Q_ASSERT(false);
return false;
}
QString PowerComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires setup";
} else {
stateDescription = "Setup complete";
}
return QString(stateDescription);
}
QStringList PowerComponent::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}
QStringList PowerComponent::paramFilterList(void) const
{
QStringList list;
return list;
}
QWidget* PowerComponent::setupWidget(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/PowerComponent.qml"));
return holder;
}
QUrl PowerComponent::summaryQmlSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/PowerComponentSummary.qml");
}
QString PowerComponent::prerequisiteSetup(void) const
{
PX4AutoPilotPlugin* plugin = dynamic_cast<PX4AutoPilotPlugin*>(_autopilot);
Q_ASSERT(plugin);
if (!plugin->airframeComponent()->setupComplete()) {
return plugin->airframeComponent()->name();
}
return QString();
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef PowerComponent_H
#define PowerComponent_H
#include "PX4Component.h"
/// @file
/// @brief Battery, propeller and magnetometer settings
/// @author Gus Grubba <mavlink@grubba.com>
class PowerComponent : public PX4Component
{
Q_OBJECT
public:
PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name (void) const;
virtual QString description (void) const;
virtual QString iconResource (void) const;
virtual bool requiresSetup (void) const;
virtual bool setupComplete (void) const;
virtual QString setupStateDescription (void) const;
virtual QWidget* setupWidget (void) const;
virtual QStringList paramFilterList (void) const;
virtual QUrl summaryQmlSource (void) const;
virtual QString prerequisiteSetup (void) const;
private:
const QString _name;
QVariantList _summaryItems;
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @brief Battery, propeller and magnetometer settings
/// @author Gus Grubba <mavlink@grubba.com>
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
Rectangle {
QGCPalette { id: palette; colorGroupEnabled: true }
width: 600
height: 600
color: palette.window
property int firstColumnWidth: 220
Column {
anchors.fill: parent
spacing: 10
QGCLabel {
text: "POWER CONFIG"
font.pointSize: 20
}
Item { height: 1; width: 10 }
QGCLabel {
text: "Battery"
color: palette.text
font.pointSize: 20
}
Rectangle {
width: parent.width
height: 160
color: palette.windowShade
Column {
id: batteryColumn
spacing: 10
anchors.verticalCenter: parent.verticalCenter
x: (parent.x + 20)
Row {
spacing: 10
QGCLabel { text: "Number of Cells"; width: firstColumnWidth; anchors.baseline: cellsField.baseline}
FactTextField {
id: cellsField
fact: Fact { name: "BAT_N_CELLS" }
showUnits: true
}
}
Row {
spacing: 10
QGCLabel { text: "Full Voltage (per cell)"; width: firstColumnWidth; anchors.baseline: battHighField.baseline}
FactTextField {
id: battHighField
fact: Fact { name: "BAT_V_CHARGED" }
showUnits: true
}
}
Row {
spacing: 10
QGCLabel { text: "Empty Voltage (per cell)"; width: firstColumnWidth; anchors.baseline: battLowField.baseline}
FactTextField {
id: battLowField
fact: Fact { name: "BAT_V_EMPTY" }
showUnits: true
}
}
Row {
spacing: 10
QGCLabel { text: "Voltage Drop on Full Load (per cell)"; width: firstColumnWidth; anchors.baseline: battDropField.baseline}
FactTextField {
id: battDropField
fact: Fact { name: "BAT_V_LOAD_DROP" }
showUnits: true
}
}
}
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @brief Battery, propeller and magnetometer summary
/// @author Gus Grubba <mavlink@grubba.com>
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0
Column {
anchors.fill: parent
anchors.margins: 8
Row {
width: parent.width
QGCLabel { id: battFull; text: "Battery Full:" }
FactLabel {
fact: Fact { name: "BAT_V_CHARGED" }
horizontalAlignment: Text.AlignRight;
width: parent.width - battFull.contentWidth;
}
}
Row {
width: parent.width
QGCLabel { id: battEmpty; text: "Battery Empty:" }
FactLabel {
fact: Fact { name: "BAT_V_EMPTY" }
horizontalAlignment: Text.AlignRight;
width: parent.width - battEmpty.contentWidth;
}
}
Row {
width: parent.width
QGCLabel { id: battCells; text: "Number of Cells:" }
FactLabel {
fact: Fact { name: "BAT_N_CELLS" }
horizontalAlignment: Text.AlignRight;
width: parent.width - battCells.contentWidth;
}
}
Row {
width: parent.width
QGCLabel { id: battDrop; text: "Voltage Drop:" }
FactLabel {
fact: Fact { name: "BAT_V_LOAD_DROP" }
horizontalAlignment: Text.AlignRight;
width: parent.width - battDrop.contentWidth;
}
}
}
import QtQuick 2.2
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
......@@ -17,6 +17,7 @@ Item {
property alias paintedWidth: image.paintedWidth
property alias progress: image.progress
property alias smooth: image.smooth
property alias mipmap: image.mipmap
property alias source: image.source
property alias sourceSize: image.sourceSize
property alias status: image.status
......@@ -28,6 +29,7 @@ Item {
Image {
id: image
smooth: true
mipmap: true
visible: false
anchors.fill: parent
}
......@@ -37,4 +39,4 @@ Item {
source: image
color: parent.color
}
}
\ No newline at end of file
}
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