diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.cpp b/libraries/AP_BattMonitor/AP_BattMonitor.cpp index 2cc0ff529f..f4640a6259 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor.cpp @@ -58,6 +58,7 @@ const AP_Param::GroupInfo AP_BattMonitor::var_info[] = { // 7 & 8 were used for VOLT2_PIN and VOLT2_MULT +#if APM_BUILD_TYPE(APM_BUILD_ArduPlane) // @Param: _WATT_MAX // @DisplayName: Maximum allowed power (Watts) // @Description: If battery wattage (voltage * current) exceeds this value then the system will reduce max throttle (THR_MAX, TKOFF_THR_MAX and THR_MIN for reverse thrust) to satisfy this limit. This helps limit high current to low C rated batteries regardless of battery voltage. The max throttle will slowly grow back to THR_MAX (or TKOFF_THR_MAX ) and THR_MIN if demanding the current max and under the watt max. Use 0 to disable. @@ -65,6 +66,7 @@ const AP_Param::GroupInfo AP_BattMonitor::var_info[] = { // @Increment: 1 // @User: Advanced AP_GROUPINFO("_WATT_MAX", 9, AP_BattMonitor, _watt_max[0], AP_BATT_MAX_WATT_DEFAULT), +#endif // 10 is left for future expansion @@ -119,6 +121,7 @@ const AP_Param::GroupInfo AP_BattMonitor::var_info[] = { AP_GROUPINFO("2_CAPACITY", 17, AP_BattMonitor, _pack_capacity[1], AP_BATT_CAPACITY_DEFAULT), +#if APM_BUILD_TYPE(APM_BUILD_ArduPlane) // @Param: 2_WATT_MAX // @DisplayName: Maximum allowed current // @Description: If battery wattage (voltage * current) exceeds this value then the system will reduce max throttle (THR_MAX, TKOFF_THR_MAX and THR_MIN for reverse thrust) to satisfy this limit. This helps limit high current to low C rated batteries regardless of battery voltage. The max throttle will slowly grow back to THR_MAX (or TKOFF_THR_MAX ) and THR_MIN if demanding the current max and under the watt max. Use 0 to disable. @@ -126,6 +129,7 @@ const AP_Param::GroupInfo AP_BattMonitor::var_info[] = { // @Increment: 1 // @User: Advanced AP_GROUPINFO("2_WATT_MAX", 18, AP_BattMonitor, _watt_max[1], AP_BATT_MAX_WATT_DEFAULT), +#endif #endif // AP_BATT_MONITOR_MAX_INSTANCES > 1 @@ -322,6 +326,7 @@ 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 { @@ -340,3 +345,5 @@ bool AP_BattMonitor::overpower_detected(uint8_t instance) const } return false; } +#endif + diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.h b/libraries/AP_BattMonitor/AP_BattMonitor.h index 1750a7e9ac..3af858ad7b 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor.h @@ -4,6 +4,7 @@ #include #include #include +#include // maximum number of battery monitors #define AP_BATT_MONITOR_MAX_INSTANCES 2 @@ -108,12 +109,14 @@ 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,7 +130,9 @@ 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];