From 9388ea3848bf5a654baefb3da13d884ae34231db Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 30 Sep 2013 23:15:35 +0900 Subject: [PATCH] Plane: integrate BattMonitor exhausted method BatteryMonitor object made static Removed unused macros for battery voltage and current monitoring --- ArduPlane/ArduPlane.pde | 2 +- ArduPlane/defines.h | 4 ---- ArduPlane/sensors.pde | 11 +---------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/ArduPlane/ArduPlane.pde b/ArduPlane/ArduPlane.pde index 93d29ba423..6abcf3a76e 100644 --- a/ArduPlane/ArduPlane.pde +++ b/ArduPlane/ArduPlane.pde @@ -466,7 +466,7 @@ static int32_t altitude_error_cm; //////////////////////////////////////////////////////////////////////////////// // Battery Sensors //////////////////////////////////////////////////////////////////////////////// -AP_BattMonitor battery; +static AP_BattMonitor battery; //////////////////////////////////////////////////////////////////////////////// // Airspeed Sensors diff --git a/ArduPlane/defines.h b/ArduPlane/defines.h index 5eedfb5578..a7797f9c36 100644 --- a/ArduPlane/defines.h +++ b/ArduPlane/defines.h @@ -199,10 +199,6 @@ enum log_messages { #define ALTITUDE_HISTORY_LENGTH 8 //Number of (time,altitude) points to // regress a climb rate from - -#define BATTERY_VOLTAGE(x) (x->voltage_average()*g.volt_div_ratio) -#define CURRENT_AMPS(x) (x->voltage_average()-g.curr_amp_offset)*g.curr_amp_per_volt - #define AN4 4 #define AN5 5 diff --git a/ArduPlane/sensors.pde b/ArduPlane/sensors.pde index 8b43da858d..9e43d5f63e 100644 --- a/ArduPlane/sensors.pde +++ b/ArduPlane/sensors.pde @@ -50,16 +50,7 @@ static void read_battery(void) battery.read(); - if (!usb_connected && - battery.voltage() != 0 && - g.fs_batt_voltage > 0 && - battery.voltage() < g.fs_batt_voltage) { - low_battery_event(); - } - if (!usb_connected && - battery.monitoring() == AP_BATT_MONITOR_VOLTAGE_AND_CURRENT && - g.fs_batt_mah > 0 && - battery.pack_capacity() - battery.current_total_mah() < g.fs_batt_mah) { + if (!usb_connected && battery.exhausted(g.fs_batt_voltage, g.fs_batt_mah)) { low_battery_event(); } }