1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Added BatterySettings UAVObject in preparation for updates to PowerSensor code.

As this changes UAVObjects both flight and GCS software will need to be recompiled to stay in sync.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2303 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
andrew 2010-12-28 05:13:19 +00:00 committed by andrew
parent 76be2b991b
commit eda227ec8b
11 changed files with 634 additions and 3 deletions

View File

@ -185,6 +185,7 @@ SRC += $(OPUAVOBJ)/firmwareiapobj.c
SRC += $(OPUAVOBJ)/ratedesired.c
SRC += $(OPUAVOBJ)/pipxtrememodemsettings.c
SRC += $(OPUAVOBJ)/pipxtrememodemstatus.c
SRC += $(OPUAVOBJ)/batterysettings.c
endif
## PIOS Hardware (STM32F10x)

View File

@ -0,0 +1,116 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup BatterySettings BatterySettings
* @brief Battery configuration information.
*
* Autogenerated files and functions for BatterySettings Object
* @{
*
* @file batterysettings.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the BatterySettings object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: batterysettings.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include "batterysettings.h"
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
* \return 0 Success
* \return -1 Failure
*/
int32_t BatterySettingsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(BATTERYSETTINGS_OBJID, BATTERYSETTINGS_NAME, BATTERYSETTINGS_METANAME, 0,
BATTERYSETTINGS_ISSINGLEINST, BATTERYSETTINGS_ISSETTINGS, BATTERYSETTINGS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
BatterySettingsData data;
UAVObjMetadata metadata;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(BatterySettingsData));
data.BatteryVoltage = 11.1;
data.BatteryCapacity = 2200;
data.BatteryType = 0;
data.Calibrations[0] = 1;
data.Calibrations[1] = 1;
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.access = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
metadata.telemetryUpdatePeriod = 0;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(obj, &metadata);
}
/**
* Get object handle
*/
UAVObjHandle BatterySettingsHandle()
{
return handle;
}
/**
* @}
*/

View File

@ -0,0 +1,103 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup BatterySettings BatterySettings
* @brief Battery configuration information.
*
* Autogenerated files and functions for BatterySettings Object
* @{
*
* @file batterysettings.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the BatterySettings object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: batterysettings.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BATTERYSETTINGS_H
#define BATTERYSETTINGS_H
// Object constants
#define BATTERYSETTINGS_OBJID 2784959898U
#define BATTERYSETTINGS_NAME "BatterySettings"
#define BATTERYSETTINGS_METANAME "BatterySettingsMeta"
#define BATTERYSETTINGS_ISSINGLEINST 1
#define BATTERYSETTINGS_ISSETTINGS 1
#define BATTERYSETTINGS_NUMBYTES sizeof(BatterySettingsData)
// Object access macros
/**
* @function BatterySettingsGet(dataOut)
* @brief Populate a BatterySettingsData object
* @param[out] dataOut
*/
#define BatterySettingsGet(dataOut) UAVObjGetData(BatterySettingsHandle(), dataOut)
#define BatterySettingsSet(dataIn) UAVObjSetData(BatterySettingsHandle(), dataIn)
#define BatterySettingsInstGet(instId, dataOut) UAVObjGetInstanceData(BatterySettingsHandle(), instId, dataOut)
#define BatterySettingsInstSet(instId, dataIn) UAVObjSetInstanceData(BatterySettingsHandle(), instId, dataIn)
#define BatterySettingsConnectQueue(queue) UAVObjConnectQueue(BatterySettingsHandle(), queue, EV_MASK_ALL_UPDATES)
#define BatterySettingsConnectCallback(cb) UAVObjConnectCallback(BatterySettingsHandle(), cb, EV_MASK_ALL_UPDATES)
#define BatterySettingsCreateInstance() UAVObjCreateInstance(BatterySettingsHandle())
#define BatterySettingsRequestUpdate() UAVObjRequestUpdate(BatterySettingsHandle())
#define BatterySettingsRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(BatterySettingsHandle(), instId)
#define BatterySettingsUpdated() UAVObjUpdated(BatterySettingsHandle())
#define BatterySettingsInstUpdated(instId) UAVObjUpdated(BatterySettingsHandle(), instId)
#define BatterySettingsGetMetadata(dataOut) UAVObjGetMetadata(BatterySettingsHandle(), dataOut)
#define BatterySettingsSetMetadata(dataIn) UAVObjSetMetadata(BatterySettingsHandle(), dataIn)
#define BatterySettingsReadOnly(dataIn) UAVObjReadOnly(BatterySettingsHandle())
// Object data
typedef struct {
float BatteryVoltage;
uint32_t BatteryCapacity;
uint8_t BatteryType;
float Calibrations[2];
} __attribute__((packed)) BatterySettingsData;
// Field information
// Field BatteryVoltage information
// Field BatteryCapacity information
// Field BatteryType information
/* Enumeration options for field BatteryType */
typedef enum { BATTERYSETTINGS_BATTERYTYPE_LIPO=0, BATTERYSETTINGS_BATTERYTYPE_A123=1, BATTERYSETTINGS_BATTERYTYPE_LICO=2, BATTERYSETTINGS_BATTERYTYPE_LIFESO4=3, BATTERYSETTINGS_BATTERYTYPE_NONE=4 } BatterySettingsBatteryTypeOptions;
// Field Calibrations information
/* Array element names for field Calibrations */
typedef enum { BATTERYSETTINGS_CALIBRATIONS_VOLTAGE=0, BATTERYSETTINGS_CALIBRATIONS_CURRENT=1 } BatterySettingsCalibrationsElem;
/* Number of elements for field Calibrations */
#define BATTERYSETTINGS_CALIBRATIONS_NUMELEM 2
// Generic interface functions
int32_t BatterySettingsInitialize();
UAVObjHandle BatterySettingsHandle();
#endif // BATTERYSETTINGS_H
/**
* @}
* @}
*/

View File

@ -38,6 +38,7 @@
#include "attitudedesired.h"
#include "attituderaw.h"
#include "baroaltitude.h"
#include "batterysettings.h"
#include "firmwareiapobj.h"
#include "flightbatterystate.h"
#include "flighttelemetrystats.h"
@ -83,6 +84,7 @@ void UAVObjectsInitializeAll()
AttitudeDesiredInitialize();
AttitudeRawInitialize();
BaroAltitudeInitialize();
BatterySettingsInitialize();
FirmwareIAPObjInitialize();
FlightBatteryStateInitialize();
FlightTelemetryStatsInitialize();

View File

@ -109,6 +109,13 @@ function [] = OPLogConvert()
BaroAltitude(1).Temperature = 0;
BaroAltitude(1).Pressure = 0;
batterysettingsIdx = 1;
BatterySettings.timestamp = 0;
BatterySettings(1).BatteryVoltage = 0;
BatterySettings(1).BatteryCapacity = 0;
BatterySettings(1).BatteryType = 0;
BatterySettings(1).Calibrations = zeros(1,2);
firmwareiapobjIdx = 1;
FirmwareIAPObj.timestamp = 0;
FirmwareIAPObj(1).Command = 0;
@ -449,6 +456,9 @@ function [] = OPLogConvert()
case 3980666102
BaroAltitude(baroaltitudeIdx) = ReadBaroAltitudeObject(fid, timestamp);
baroaltitudeIdx = baroaltitudeIdx + 1;
case 2784959898
BatterySettings(batterysettingsIdx) = ReadBatterySettingsObject(fid, timestamp);
batterysettingsIdx = batterysettingsIdx + 1;
case 879185696
FirmwareIAPObj(firmwareiapobjIdx) = ReadFirmwareIAPObjObject(fid, timestamp);
firmwareiapobjIdx = firmwareiapobjIdx + 1;
@ -543,7 +553,7 @@ function [] = OPLogConvert()
fclose(fid);
matfile = strrep(logfile,'opl','mat');
save(matfile ,'ActuatorCommand','ActuatorDesired','ActuatorSettings','AHRSCalibration','AHRSSettings','AhrsStatus','AttitudeActual','AttitudeDesired','AttitudeRaw','BaroAltitude','FirmwareIAPObj','FlightBatteryState','FlightTelemetryStats','GCSTelemetryStats','GPSPosition','GPSSatellites','GPSTime','GuidanceSettings','HomeLocation','I2CStats','ManualControlCommand','ManualControlSettings','MixerSettings','MixerStatus','ObjectPersistence','PipXtremeModemSettings','PipXtremeModemStatus','PositionActual','PositionDesired','RateDesired','StabilizationSettings','SystemAlarms','SystemSettings','SystemStats','TelemetrySettings','VelocityActual','VelocityDesired');
save(matfile ,'ActuatorCommand','ActuatorDesired','ActuatorSettings','AHRSCalibration','AHRSSettings','AhrsStatus','AttitudeActual','AttitudeDesired','AttitudeRaw','BaroAltitude','BatterySettings','FirmwareIAPObj','FlightBatteryState','FlightTelemetryStats','GCSTelemetryStats','GPSPosition','GPSSatellites','GPSTime','GuidanceSettings','HomeLocation','I2CStats','ManualControlCommand','ManualControlSettings','MixerSettings','MixerStatus','ObjectPersistence','PipXtremeModemSettings','PipXtremeModemStatus','PositionActual','PositionDesired','RateDesired','StabilizationSettings','SystemAlarms','SystemSettings','SystemStats','TelemetrySettings','VelocityActual','VelocityDesired');
end
@ -757,6 +767,23 @@ function [BaroAltitude] = ReadBaroAltitudeObject(fid, timestamp)
fread(fid, 1, 'uint8');
end
function [BatterySettings] = ReadBatterySettingsObject(fid, timestamp)
if 1
headerSize = 8;
else
BatterySettings.instanceID = fread(fid, 1, 'uint16');
headerSize = 10;
end
BatterySettings.timestamp = timestamp;
BatterySettings.BatteryVoltage = double(fread(fid, 1, 'float32'));
BatterySettings.BatteryCapacity = double(fread(fid, 1, 'uint32'));
BatterySettings.BatteryType = double(fread(fid, 1, 'uint8'));
BatterySettings.Calibrations = double(fread(fid, 2, 'float32'));
% read CRC
fread(fid, 1, 'uint8');
end
function [FirmwareIAPObj] = ReadFirmwareIAPObjObject(fid, timestamp)
if 1
headerSize = 8;

View File

@ -0,0 +1,152 @@
/**
******************************************************************************
*
* @file batterysettings.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{
*
* @note Object definition file: batterysettings.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @brief The UAVUObjects GCS plugin
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "batterysettings.h"
#include "uavobjectfield.h"
const QString BatterySettings::NAME = QString("BatterySettings");
const QString BatterySettings::DESCRIPTION = QString("Battery configuration information.");
/**
* Constructor
*/
BatterySettings::BatterySettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList BatteryVoltageElemNames;
BatteryVoltageElemNames.append("0");
fields.append( new UAVObjectField(QString("BatteryVoltage"), QString("V"), UAVObjectField::FLOAT32, BatteryVoltageElemNames, QStringList()) );
QStringList BatteryCapacityElemNames;
BatteryCapacityElemNames.append("0");
fields.append( new UAVObjectField(QString("BatteryCapacity"), QString("mAh"), UAVObjectField::UINT32, BatteryCapacityElemNames, QStringList()) );
QStringList BatteryTypeElemNames;
BatteryTypeElemNames.append("0");
QStringList BatteryTypeEnumOptions;
BatteryTypeEnumOptions.append("LiPo");
BatteryTypeEnumOptions.append("A123");
BatteryTypeEnumOptions.append("LiCo");
BatteryTypeEnumOptions.append("LiFeSO4");
BatteryTypeEnumOptions.append("None");
fields.append( new UAVObjectField(QString("BatteryType"), QString(""), UAVObjectField::ENUM, BatteryTypeElemNames, BatteryTypeEnumOptions) );
QStringList CalibrationsElemNames;
CalibrationsElemNames.append("Voltage");
CalibrationsElemNames.append("Current");
fields.append( new UAVObjectField(QString("Calibrations"), QString(""), UAVObjectField::FLOAT32, CalibrationsElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
// Set the object description
setDescription(DESCRIPTION);
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata BatterySettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.flightTelemetryAcked = 1;
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.flightTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
return metadata;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
void BatterySettings::setDefaultFieldValues()
{
data.BatteryVoltage = 11.1;
data.BatteryCapacity = 2200;
data.BatteryType = 0;
data.Calibrations[0] = 1;
data.Calibrations[1] = 1;
}
/**
* Get the object data fields
*/
BatterySettings::DataFields BatterySettings::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void BatterySettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**
* Create a clone of this object, a new instance ID must be specified.
* Do not use this function directly to create new instances, the
* UAVObjectManager should be used instead.
*/
UAVDataObject* BatterySettings::clone(quint32 instID)
{
BatterySettings* obj = new BatterySettings();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
BatterySettings* BatterySettings::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<BatterySettings*>(objMngr->getObject(BatterySettings::OBJID, instID));
}

View File

@ -0,0 +1,91 @@
/**
******************************************************************************
*
* @file batterysettings.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{
*
* @note Object definition file: batterysettings.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @brief The UAVUObjects GCS plugin
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BATTERYSETTINGS_H
#define BATTERYSETTINGS_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT BatterySettings: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
float BatteryVoltage;
quint32 BatteryCapacity;
quint8 BatteryType;
float Calibrations[2];
} __attribute__((packed)) DataFields;
// Field information
// Field BatteryVoltage information
// Field BatteryCapacity information
// Field BatteryType information
/* Enumeration options for field BatteryType */
typedef enum { BATTERYTYPE_LIPO=0, BATTERYTYPE_A123=1, BATTERYTYPE_LICO=2, BATTERYTYPE_LIFESO4=3, BATTERYTYPE_NONE=4 } BatteryTypeOptions;
// Field Calibrations information
/* Array element names for field Calibrations */
typedef enum { CALIBRATIONS_VOLTAGE=0, CALIBRATIONS_CURRENT=1 } CalibrationsElem;
/* Number of elements for field Calibrations */
static const quint32 CALIBRATIONS_NUMELEM = 2;
// Constants
static const quint32 OBJID = 2784959898U;
static const QString NAME;
static const QString DESCRIPTION;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 1;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
BatterySettings();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static BatterySettings* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // BATTERYSETTINGS_H

View File

@ -0,0 +1,122 @@
##
##############################################################################
#
# @file batterysettings.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the BatterySettings object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: batterysettings.xml.
# This is an automatically generated file.
# DO NOT modify manually.
#
# @see The GNU Public License (GPL) Version 3
#
#############################################################################/
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import uavobject
import struct
from collections import namedtuple
# This is a list of instances of the data fields contained in this object
_fields = [ \
uavobject.UAVObjectField(
'BatteryVoltage',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'BatteryCapacity',
'I',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'BatteryType',
'b',
1,
[
'0',
],
{
'0' : 'LiPo',
'1' : 'A123',
'2' : 'LiCo',
'3' : 'LiFeSO4',
'4' : 'None',
}
),
uavobject.UAVObjectField(
'Calibrations',
'f',
2,
[
'Voltage',
'Current',
],
{
}
),
]
class BatterySettings(uavobject.UAVObject):
## Object constants
OBJID = 2784959898
NAME = "BatterySettings"
METANAME = "BatterySettingsMeta"
ISSINGLEINST = 1
ISSETTINGS = 1
def __init__(self):
uavobject.UAVObject.__init__(self,
self.OBJID,
self.NAME,
self.METANAME,
0,
self.ISSINGLEINST)
for f in _fields:
self.add_field(f)
def __str__(self):
s = ("0x%08X (%10u) %-30s %3u bytes format '%s'\n"
% (self.OBJID, self.OBJID, self.NAME, self.get_struct().size, self.get_struct().format))
for f in self.get_tuple()._fields:
s += ("\t%s\n" % f)
return (s)
def main():
# Instantiate the object and dump out some interesting info
x = BatterySettings()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -47,7 +47,8 @@ HEADERS += uavobjects_global.h \
firmwareiapobj.h \
pipxtrememodemsettings.h \
pipxtrememodemstatus.h \
i2cstats.h
i2cstats.h \
batterysettings.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
@ -92,5 +93,6 @@ SOURCES += uavobject.cpp \
firmwareiapobj.cpp \
pipxtrememodemsettings.cpp \
pipxtrememodemstatus.cpp \
i2cstats.cpp
i2cstats.cpp \
batterysettings.cpp
OTHER_FILES += UAVObjects.pluginspec

View File

@ -40,6 +40,7 @@
#include "attitudedesired.h"
#include "attituderaw.h"
#include "baroaltitude.h"
#include "batterysettings.h"
#include "firmwareiapobj.h"
#include "flightbatterystate.h"
#include "flighttelemetrystats.h"
@ -85,6 +86,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new AttitudeDesired() );
objMngr->registerObject( new AttitudeRaw() );
objMngr->registerObject( new BaroAltitude() );
objMngr->registerObject( new BatterySettings() );
objMngr->registerObject( new FirmwareIAPObj() );
objMngr->registerObject( new FlightBatteryState() );
objMngr->registerObject( new FlightTelemetryStats() );

View File

@ -0,0 +1,13 @@
<xml>
<object name="BatterySettings" singleinstance="true" settings="true">
<description>Battery configuration information.</description>
<field name="BatteryVoltage" units="V" type="float" elements="1" defaultvalue="11.1"/>
<field name="BatteryCapacity" units="mAh" type="uint32" elements="1" defaultvalue="2200"/>
<field name="BatteryType" units="" type="enum" elements="1" options="LiPo,A123,LiCo,LiFeSO4,None" defaultvalue="LiPo"/>
<field name="Calibrations" units="" type="float" elementnames="Voltage,Current" defaultvalue="1.0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>
</object>
</xml>