Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : #pragma once 16 : 17 : #include "AP_BattMonitor_config.h" 18 : 19 : #if AP_BATTERY_TORQEEDO_ENABLED 20 : 21 : #include <AP_Torqeedo/AP_Torqeedo.h> 22 : 23 : #include <AP_Common/AP_Common.h> 24 : #include <AP_HAL/AP_HAL.h> 25 : #include "AP_BattMonitor_Backend.h" 26 : 27 : class AP_BattMonitor_Torqeedo: public AP_BattMonitor_Backend 28 : { 29 : public: 30 : 31 : // inherit constructor 32 : using AP_BattMonitor_Backend::AP_BattMonitor_Backend; 33 : 34 : // read the latest battery voltage 35 : void read() override; 36 : 37 : /// returns true if battery monitor instance provides current info 38 0 : bool has_current() const override { return have_info; }; 39 : 40 : // returns true if battery monitor provides temperature 41 0 : bool has_temperature() const override { return have_info; }; 42 : 43 : // capacity_remaining_pct - returns true if the battery % is available and writes to the percentage argument 44 : bool capacity_remaining_pct(uint8_t &percentage) const override WARN_IF_UNUSED; 45 : 46 : private: 47 : 48 : bool have_info; // true if torqeedo has provided battery info at least once 49 : bool have_capacity; // true once torqeedo has provided battery capacity 50 : uint8_t remaining_pct; // battery remaining capacity as a percentage 51 : }; 52 : 53 : #endif