Browse Source

AP_BattMonitor: move vehicle dependant code to be c-file only, not header

master
Tom Pittenger 9 years ago
parent
commit
5108b4cbb6
  1. 7
      libraries/AP_BattMonitor/AP_BattMonitor.cpp
  2. 5
      libraries/AP_BattMonitor/AP_BattMonitor.h

7
libraries/AP_BattMonitor/AP_BattMonitor.cpp

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "AP_BattMonitor_Analog.h"
#include "AP_BattMonitor_SMBus.h"
#include "AP_BattMonitor_Bebop.h"
#include <AP_Vehicle/AP_Vehicle_Type.h>
extern const AP_HAL::HAL& hal;
@ -298,7 +299,6 @@ bool AP_BattMonitor::exhausted(uint8_t instance, float low_voltage, float min_ca @@ -298,7 +299,6 @@ bool AP_BattMonitor::exhausted(uint8_t instance, float low_voltage, float min_ca
return false;
}
#if APM_BUILD_TYPE(APM_BUILD_ArduPlane)
// return true if any battery is pushing too much power
bool AP_BattMonitor::overpower_detected() const
{
@ -311,11 +311,14 @@ bool AP_BattMonitor::overpower_detected() const @@ -311,11 +311,14 @@ bool AP_BattMonitor::overpower_detected() const
bool AP_BattMonitor::overpower_detected(uint8_t instance) const
{
#if APM_BUILD_TYPE(APM_BUILD_ArduPlane)
if (instance < _num_instances && _watt_max[instance] > 0) {
float power = _BattMonitor_STATE(instance).current_amps * _BattMonitor_STATE(instance).voltage;
return _BattMonitor_STATE(instance).healthy && (power > _watt_max[instance]);
}
return false;
}
#else
return false;
#endif
}

5
libraries/AP_BattMonitor/AP_BattMonitor.h

@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
#include <AP_Common/AP_Common.h>
#include <AP_Param/AP_Param.h>
#include <AP_Math/AP_Math.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
// maximum number of battery monitors
#define AP_BATT_MONITOR_MAX_INSTANCES 2
@ -106,14 +105,12 @@ public: @@ -106,14 +105,12 @@ public:
/// set_monitoring - sets the monitor type (used for example sketch only)
void set_monitoring(uint8_t instance, uint8_t mon) { _monitoring[instance].set(mon); }
#if APM_BUILD_TYPE(APM_BUILD_ArduPlane)
bool get_watt_max() { return get_watt_max(AP_BATT_PRIMARY_INSTANCE); }
bool get_watt_max(uint8_t instance) { return _watt_max[instance]; }
/// true when (voltage * current) > watt_max
bool overpower_detected() const;
bool overpower_detected(uint8_t instance) const;
#endif
static const struct AP_Param::GroupInfo var_info[];
@ -127,9 +124,7 @@ protected: @@ -127,9 +124,7 @@ protected:
AP_Float _curr_amp_per_volt[AP_BATT_MONITOR_MAX_INSTANCES]; /// voltage on current pin multiplied by this to calculate current in amps
AP_Float _curr_amp_offset[AP_BATT_MONITOR_MAX_INSTANCES]; /// offset voltage that is subtracted from current pin before conversion to amps
AP_Int32 _pack_capacity[AP_BATT_MONITOR_MAX_INSTANCES]; /// battery pack capacity less reserve in mAh
#if APM_BUILD_TYPE(APM_BUILD_ArduPlane)
AP_Int16 _watt_max[AP_BATT_MONITOR_MAX_INSTANCES]; /// max battery power allowed. Reduce max throttle to reduce current to satisfy this limit
#endif
private:
BattMonitor_State state[AP_BATT_MONITOR_MAX_INSTANCES];

Loading…
Cancel
Save