diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.cpp b/libraries/AP_BattMonitor/AP_BattMonitor.cpp index e3edc4f9d3..3b44eee21b 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor.cpp @@ -777,6 +777,14 @@ float AP_BattMonitor::gcs_voltage(uint8_t instance) const return state[instance].voltage; } +bool AP_BattMonitor::option_is_set(uint8_t instance, AP_BattMonitor_Params::Options option) const +{ + if (instance >= _num_instances || drivers[instance] == nullptr) { + return false; + } + return drivers[instance]->option_is_set(option); +} + /// current_amps - returns the instantaneous current draw in amperes bool AP_BattMonitor::current_amps(float ¤t, uint8_t instance) const { if ((instance < _num_instances) && (drivers[instance] != nullptr) && drivers[instance]->has_current()) { diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.h b/libraries/AP_BattMonitor/AP_BattMonitor.h index 0dbcf93bb7..0b55e2846d 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor.h @@ -262,6 +262,8 @@ public: void MPPT_set_powered_state_to_all(const bool power_on); void MPPT_set_powered_state(const uint8_t instance, const bool power_on); + bool option_is_set(uint8_t instance, AP_BattMonitor_Params::Options option) const; + // cycle count bool get_cycle_count(uint8_t instance, uint16_t &cycles) const; diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_Params.h b/libraries/AP_BattMonitor/AP_BattMonitor_Params.h index 2088845c39..8298a0c34a 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_Params.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_Params.h @@ -17,7 +17,7 @@ public: BattMonitor_LowVoltageSource_Raw = 0, BattMonitor_LowVoltageSource_SagCompensated = 1 }; - enum class Options : uint8_t { + enum class Options : uint16_t { Ignore_UAVCAN_SoC = (1U<<0), // Ignore UAVCAN State-of-Charge (charge %) supplied value from the device and use the internally calculated one MPPT_Use_Input_Value = (1U<<1), // MPPT reports voltage and current from Input (usually solar panel) instead of the output MPPT_Power_Off_At_Disarm = (1U<<2), // MPPT Disabled when vehicle is disarmed, if HW supports it @@ -26,6 +26,7 @@ public: MPPT_Power_On_At_Boot = (1U<<5), // MPPT Enabled at startup (aka boot), if HW supports it. If Power_Off_at_Boot is also set, the behavior is Power_Off_at_Boot GCS_Resting_Voltage = (1U<<6), // send resistance resting voltage to GCS AllowSplitAuxInfo = (1U<<7), // allow different node to provide aux info for DroneCAN + InternalUseOnly = (1U<<8), // for use internally to ArduPilot, not to be (eg.) sent via MAVLink BATTERY_STATUS }; BattMonitor_LowVoltage_Source failsafe_voltage_source(void) const { return (enum BattMonitor_LowVoltage_Source)_failsafe_voltage_source.get(); }