1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge remote-tracking branch 'origin/laurent/OP-1814_Battery_reset_mAh' into next

This commit is contained in:
Laurent Lalanne 2015-04-20 14:35:08 +02:00
commit f2a431aceb
6 changed files with 44 additions and 0 deletions

View File

@ -138,6 +138,13 @@ static void onTimer(__attribute__((unused)) UAVObjEvent *ev)
const float dT = SAMPLE_PERIOD_MS / 1000.0f;
float energyRemaining;
// Reset ConsumedEnergy counter
if (batterySettings.ResetConsumedEnergy) {
flightBatteryData.ConsumedEnergy = 0;
batterySettings.ResetConsumedEnergy = false;
FlightBatterySettingsSet(&batterySettings);
}
// calculate the battery parameters
if (voltageADCPin >= 0) {
flightBatteryData.Voltage = (PIOS_ADC_PinGetVolt(voltageADCPin) - batterySettings.SensorCalibrations.VoltageZero) * batterySettings.SensorCalibrations.VoltageFactor; // in Volts

View File

@ -354,6 +354,13 @@ Item {
Rectangle {
anchors.fill: parent
MouseArea {
id: reset_consumed_energy_mouseArea;
anchors.fill: parent;
cursorShape: Qt.PointingHandCursor;
onClicked: qmlWidget.resetConsumedEnergy();
}
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[SystemAlarms.Alarm_Battery]))

View File

@ -480,6 +480,13 @@ Item {
Rectangle {
anchors.fill: parent
MouseArea {
id: reset_panel_consumed_energy_mouseArea;
anchors.fill: parent;
cursorShape: Qt.PointingHandCursor;
onClicked: qmlWidget.resetConsumedEnergy();
}
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[SystemAlarms.Alarm_Battery]))
@ -526,6 +533,13 @@ Item {
anchors.fill: parent
//color: panels.batColors[SystemAlarms.Alarm_Battery]
MouseArea {
id: reset_panel_consumed_energy_mouseArea2;
anchors.fill: parent;
cursorShape: Qt.PointingHandCursor;
onClicked: qmlWidget.resetConsumedEnergy();
}
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[SystemAlarms.Alarm_Battery]))

View File

@ -18,6 +18,7 @@
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include "flightbatterysettings.h"
#include "utils/svgimageprovider.h"
#ifdef USE_OSG
#include "osgearth.h"
@ -81,6 +82,8 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWindow *parent) :
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
m_uavoManager = pm->getObject<UAVObjectManager>();
Q_ASSERT(m_uavoManager);
foreach(const QString &objectName, objectsToExport) {
UAVObject *object = objManager->getObject(objectName);
@ -124,6 +127,14 @@ void PfdQmlGadgetWidget::setQmlFile(QString fn)
}
}
void PfdQmlGadgetWidget::resetConsumedEnergy()
{
FlightBatterySettings *mBatterySettings = FlightBatterySettings::GetInstance(m_uavoManager);
mBatterySettings->setResetConsumedEnergy(true);
mBatterySettings->setData(mBatterySettings->getData());
}
void PfdQmlGadgetWidget::setEarthFile(QString arg)
{
if (m_earthFile != arg) {

View File

@ -18,6 +18,7 @@
#define PFDQMLGADGETWIDGET_H_
#include "pfdqmlgadgetconfiguration.h"
#include "uavobjectmanager.h"
#include <QQuickView>
class PfdQmlGadgetWidget : public QQuickView {
@ -84,6 +85,8 @@ public:
return m_altitude;
}
Q_INVOKABLE void resetConsumedEnergy();
public slots:
void setEarthFile(QString arg);
void setTerrainEnabled(bool arg);
@ -119,6 +122,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
private:
UAVObjectManager *m_uavoManager;
QString m_qmlFileName;
QString m_earthFile;
bool m_openGLEnabled;

View File

@ -7,6 +7,7 @@
<field name="Capacity" units="mAh" type="uint32" elements="1" defaultvalue="2200"/>
<field name="CellVoltageThresholds" units="V" type="float" elementnames="Warning, Alarm" defaultvalue="3.4,3.1"/>
<field name="SensorCalibrations" units="" type="float" elementnames="VoltageFactor, CurrentFactor, VoltageZero, CurrentZero" defaultvalue="1.0, 1.0, 0.0, 0.0"/>
<field name="ResetConsumedEnergy" units="bool" type="enum" elements="1" options="false,true" defaultvalue="false"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>