From d583d157e7cb8dd6637adb6901ef25cc9ecd427d Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Tue, 23 Feb 2021 11:52:41 -0300 Subject: [PATCH] GCS_MAVLink: add default instance to get_battery_remaining_percentage, make it const --- ArduSub/GCS_Mavlink.h | 2 +- libraries/GCS_MAVLink/GCS.h | 2 +- libraries/GCS_MAVLink/GCS_Common.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ArduSub/GCS_Mavlink.h b/ArduSub/GCS_Mavlink.h index 921b51f4b0..b723466a4f 100644 --- a/ArduSub/GCS_Mavlink.h +++ b/ArduSub/GCS_Mavlink.h @@ -40,7 +40,7 @@ protected: uint64_t capabilities() const override; - uint8_t get_battery_remaining_percentage() override { return -1; }; + uint8_t get_battery_remaining_percentage(uint8_t instance) const override { return -1; }; private: diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 58acebf462..7a1996676f 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -431,7 +431,7 @@ protected: virtual float vfr_hud_airspeed() const; virtual int16_t vfr_hud_throttle() const { return 0; } virtual float vfr_hud_alt() const; - virtual uint8_t get_battery_remaining_percentage(); + virtual uint8_t get_battery_remaining_percentage(uint8_t instance=0) const; static constexpr const float magic_force_arm_value = 2989.0f; static constexpr const float magic_force_disarm_value = 21196.0f; diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index cd7b3a2e5d..549f45442b 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -4662,9 +4662,9 @@ void GCS_MAVLINK::manual_override(RC_Channel *c, int16_t value_in, const uint16_ c->set_override(override_value, tnow); } -uint8_t GCS_MAVLINK::get_battery_remaining_percentage() { +uint8_t GCS_MAVLINK::get_battery_remaining_percentage(uint8_t instance) const { const AP_BattMonitor &battery = AP::battery(); - return battery.capacity_remaining_pct(); + return battery.capacity_remaining_pct(instance); } GCS &gcs()