AP_BattMonitor: add and use AP_BATTERY_ENABLED

This commit is contained in:
Peter Barker 2024-01-31 19:38:49 +11:00 committed by Andrew Tridgell
parent 9961e8c49d
commit 1f4c129341
6 changed files with 36 additions and 4 deletions

View File

@ -1,4 +1,9 @@
#include "AP_BattMonitor_config.h"
#if AP_BATTERY_ENABLED
#include "AP_BattMonitor.h"
#include "AP_BattMonitor_Analog.h"
#include "AP_BattMonitor_SMBus.h"
#include "AP_BattMonitor_SMBus_Solo.h"
@ -1117,3 +1122,5 @@ AP_BattMonitor &battery()
}
};
#endif // AP_BATTERY_ENABLED

View File

@ -1,12 +1,15 @@
#pragma once
#include "AP_BattMonitor_config.h"
#if AP_BATTERY_ENABLED
#include <AP_Common/AP_Common.h>
#include <AP_Param/AP_Param.h>
#include <AP_Math/AP_Math.h>
#include <AP_TemperatureSensor/AP_TemperatureSensor_config.h>
#include <GCS_MAVLink/GCS_MAVLink.h>
#include "AP_BattMonitor_Params.h"
#include "AP_BattMonitor_config.h"
// maximum number of battery monitors
#ifndef AP_BATT_MONITOR_MAX_INSTANCES
@ -315,3 +318,5 @@ private:
namespace AP {
AP_BattMonitor &battery();
};
#endif // AP_BATTERY_ENABLED

View File

@ -13,6 +13,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_BattMonitor_config.h"
#if AP_BATTERY_ENABLED
#include <AP_Common/AP_Common.h>
#include <AP_HAL/AP_HAL.h>
#include "AP_BattMonitor.h"
@ -334,3 +338,5 @@ void AP_BattMonitor_Backend::update_consumed(AP_BattMonitor::BattMonitor_State &
state.consumed_wh += 0.001 * mah * state.voltage;
}
}
#endif // AP_BATTERY_ENABLED

View File

@ -14,9 +14,14 @@
*/
#pragma once
#include <AP_Common/AP_Common.h>
#include "AP_BattMonitor_config.h"
#if AP_BATTERY_ENABLED
#include "AP_BattMonitor.h"
#include <AP_Common/AP_Common.h>
class AP_BattMonitor_Backend
{
public:
@ -141,3 +146,5 @@ struct BattMonitorScript_State {
float temperature=nanf(""); // Battery temperature in degrees Celsius
};
#endif // AP_BATTERY_SCRIPTING_ENABLED
#endif // AP_BATTERY_ENABLED

View File

@ -1,6 +1,7 @@
#include "AP_BattMonitor_config.h"
#include <AP_Logger/AP_Logger_config.h>
#if HAL_LOGGING_ENABLED
#if AP_BATTERY_ENABLED && HAL_LOGGING_ENABLED
#include "AP_BattMonitor_Backend.h"
#include <AP_Logger/AP_Logger.h>
@ -88,4 +89,4 @@ void AP_BattMonitor_Backend::Log_Write_BCL(const uint8_t instance, const uint64_
#endif
}
#endif // HAL_LOGGING_ENABLED
#endif // AP_BATTERY_ENABLED && HAL_LOGGING_ENABLED

View File

@ -1,3 +1,7 @@
#include "AP_BattMonitor_config.h"
#if AP_BATTERY_ENABLED
#include <AP_Common/AP_Common.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
#include "AP_BattMonitor_Params.h"
@ -172,3 +176,5 @@ const AP_Param::GroupInfo AP_BattMonitor_Params::var_info[] = {
AP_BattMonitor_Params::AP_BattMonitor_Params(void) {
AP_Param::setup_object_defaults(this, var_info);
}
#endif // AP_BATTERY_ENABLED