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

FlightBatteryState Object : Made Voltage and Current fields float

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@895 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
FredericG 2010-06-26 10:59:11 +00:00 committed by FredericG
parent 8204143f9d
commit 55f13788de
8 changed files with 19 additions and 19 deletions

View File

@ -108,8 +108,8 @@ static void task(void* parameters)
DEBUG_MSG("%03d %06d => %06dmV %06d => %06dmA %06dmAh\n", cnt, PIOS_ADC_PinGet(2), mV, PIOS_ADC_PinGet(1), mA, mAs/3600);
cnt++;
flightBatteryData.Voltage = mV;
flightBatteryData.Current = mA;
flightBatteryData.Voltage = (float)mV/1000;
flightBatteryData.Current = (float)mA/1000;
flightBatteryData.ConsumedEnergy = mAs / 3600;
FlightBatteryStateSet(&flightBatteryData);

View File

@ -540,7 +540,7 @@ static void DoConnectedToNC(void)
#if GENERATE_BATTERY_INFO
if (++battStateCnt > 2)
{
flightBatteryData.Voltage = (uint32_t)msg.pars[OSD_MSG_BATT_IDX]*100;
flightBatteryData.Voltage = (float)msg.pars[OSD_MSG_BATT_IDX]/10;
FlightBatteryStateSet(&flightBatteryData);
battStateCnt = 0;
}

View File

@ -339,10 +339,10 @@ static void Task(void* parameters)
FlightBatteryStateGet(&flightBatteryData);
DEBUG_MSG("%5d Batt: V=%dmV\n\r", cnt, flightBatteryData.Voltage);
DEBUG_MSG("%5d Batt: V=%dmV\n\r", cnt, (uint32_t)(flightBatteryData.Voltage*1000));
SetVoltage(flightBatteryData.Voltage);
SetCurrent(flightBatteryData.Current);
SetVoltage((uint32_t)(flightBatteryData.Voltage*1000));
SetCurrent((uint32_t)(flightBatteryData.Current*1000));
newBattData = FALSE;
}

View File

@ -33,7 +33,7 @@
#define FLIGHTBATTERYSTATE_H
// Object constants
#define FLIGHTBATTERYSTATE_OBJID 4176558368U
#define FLIGHTBATTERYSTATE_OBJID 144318184U
#define FLIGHTBATTERYSTATE_NAME "FlightBatteryState"
#define FLIGHTBATTERYSTATE_METANAME "FlightBatteryStateMeta"
#define FLIGHTBATTERYSTATE_ISSINGLEINST 1
@ -57,8 +57,8 @@
// Object data
typedef struct {
uint32_t Voltage;
uint32_t Current;
float Voltage;
float Current;
uint32_t ConsumedEnergy;
} __attribute__((packed)) FlightBatteryStateData;

View File

@ -42,10 +42,10 @@ FlightBatteryState::FlightBatteryState(): UAVDataObject(OBJID, ISSINGLEINST, ISS
QList<UAVObjectField*> fields;
QStringList VoltageElemNames;
VoltageElemNames.append("0");
fields.append( new UAVObjectField(QString("Voltage"), QString("mV"), UAVObjectField::UINT32, VoltageElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Voltage"), QString("V"), UAVObjectField::FLOAT32, VoltageElemNames, QStringList()) );
QStringList CurrentElemNames;
CurrentElemNames.append("0");
fields.append( new UAVObjectField(QString("Current"), QString("mA"), UAVObjectField::UINT32, CurrentElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Current"), QString("A"), UAVObjectField::FLOAT32, CurrentElemNames, QStringList()) );
QStringList ConsumedEnergyElemNames;
ConsumedEnergyElemNames.append("0");
fields.append( new UAVObjectField(QString("ConsumedEnergy"), QString("mAh"), UAVObjectField::UINT32, ConsumedEnergyElemNames, QStringList()) );

View File

@ -41,8 +41,8 @@ class UAVOBJECTS_EXPORT FlightBatteryState: public UAVDataObject
public:
// Field structure
typedef struct {
quint32 Voltage;
quint32 Current;
float Voltage;
float Current;
quint32 ConsumedEnergy;
} __attribute__((packed)) DataFields;
@ -54,7 +54,7 @@ public:
// Constants
static const quint32 OBJID = 4176558368U;
static const quint32 OBJID = 144318184U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;

View File

@ -39,7 +39,7 @@ from collections import namedtuple
_fields = [ \
uavobject.UAVObjectField(
'Voltage',
'I',
'f',
1,
[
'0',
@ -49,7 +49,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Current',
'I',
'f',
1,
[
'0',
@ -72,7 +72,7 @@ _fields = [ \
class FlightBatteryState(uavobject.UAVObject):
## Object constants
OBJID = 4176558368
OBJID = 144318184
NAME = "FlightBatteryState"
METANAME = "FlightBatteryStateMeta"
ISSINGLEINST = 1

View File

@ -1,8 +1,8 @@
<xml>
<object name="FlightBatteryState" singleinstance="true" settings="false">
<field name="Voltage" units="mV" type="uint32" elements="1"/>
<field name="Current" units="mA" type="uint32" elements="1"/>
<field name="Voltage" units="V" type="float" elements="1"/>
<field name="Current" units="A" type="float" elements="1"/>
<field name="ConsumedEnergy" units="mAh" type="uint32" elements="1"/>
<access gcs="readonly" flight="readwrite"/>