diff --git a/flight/Modules/Battery/battery.c b/flight/Modules/Battery/battery.c index a57efd69a..303e4aa47 100644 --- a/flight/Modules/Battery/battery.c +++ b/flight/Modules/Battery/battery.c @@ -75,12 +75,10 @@ static void onTimer(UAVObjEvent* ev); * Initialise the module, called on startup * \returns 0 on success or -1 if initialisation failed */ -MODULE_INITCALL(BatteryInitialize, 0) - int32_t BatteryInitialize(void) { - BatteryStateInitialze(); - BatterySettingsInitialize(); + FlightBatteryStateInitialize(); + FlightBatterySettingsInitialize(); static UAVObjEvent ev; @@ -90,6 +88,8 @@ int32_t BatteryInitialize(void) return 0; } +MODULE_INITCALL(BatteryInitialize, 0) + static void onTimer(UAVObjEvent* ev) { static portTickType lastSysTime; @@ -114,7 +114,6 @@ static void onTimer(UAVObjEvent* ev) portTickType thisSysTime; FlightBatterySettingsData batterySettings; static float dT = SAMPLE_PERIOD_MS / 1000; - float Bob; float energyRemaining; @@ -129,7 +128,7 @@ static void onTimer(UAVObjEvent* ev) //calculate the battery parameters flightBatteryData.Voltage = ((float)PIOS_ADC_PinGet(2)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_VOLTAGEFACTOR]; //in Volts flightBatteryData.Current = ((float)PIOS_ADC_PinGet(1)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_CURRENTFACTOR]; //in Amps -Bob =dT; // FIXME: something funky happens if I don't do this... Andrew + flightBatteryData.ConsumedEnergy += (flightBatteryData.Current * 1000.0 * dT / 3600.0) ;//in mAh if (flightBatteryData.Current > flightBatteryData.PeakCurrent)flightBatteryData.PeakCurrent = flightBatteryData.Current; //in Amps diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index 2553004c4..760c8584a 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -50,6 +50,7 @@ FLASH_TOOL = OPENOCD # List of modules to include MODULES = Sensors Attitude/revolution ManualControl Stabilization Actuator +MODULES += Battery MODULES += Altitude/revolution GPS FirmwareIAP MODULES += AltitudeHold VtolPathFollower PathPlanner MODULES += CameraStab