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_Common/AP_Common.h> 18 : #include <AP_HAL/AP_HAL.h> 19 : #include <AP_ESC_Telem/AP_ESC_Telem.h> 20 : #include "AP_BattMonitor_Backend.h" 21 : 22 : #if AP_BATTERY_ESC_ENABLED 23 : 24 : class AP_BattMonitor_ESC :public AP_BattMonitor_Backend 25 : { 26 : public: 27 : // constructor. This incorporates initialisation as well. 28 : AP_BattMonitor_ESC(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms); 29 : 30 0 : virtual ~AP_BattMonitor_ESC(void) {}; 31 : 32 : // initialise 33 : void init() override; 34 : 35 : // read the latest battery voltage 36 : void read() override; 37 : 38 : // ESC_Telem provides current info 39 0 : bool has_current() const override { return have_current; }; 40 : 41 : // ESC_Telem provides temperature info 42 0 : bool has_temperature() const override { return have_temperature; }; 43 : 44 : // reset remaining percentage to given value 45 : virtual bool reset_remaining(float percentage) override; 46 : 47 : static const struct AP_Param::GroupInfo var_info[]; 48 : 49 : private: 50 : 51 : AP_Int32 _mask; 52 : 53 : bool have_current; 54 : bool have_consumed_mah; 55 : bool have_temperature; 56 : float delta_mah; 57 : 58 : uint32_t last_read_us; 59 : }; 60 : 61 : #endif // AP_BATTERY_ESC_ENABLED