APM:Libraries
AP_BattMonitor_Bebop.h
Go to the documentation of this file.
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_BattMonitor_Backend.h"
20 
22 {
23 public:
24  // constructor. This incorporates initialisation as well.
26  AP_BattMonitor_Backend(mon, mon_state, params),
27  _prev_vbat_raw(0.0f),
28  _prev_vbat(0.0f),
30  {};
31 
32  virtual ~AP_BattMonitor_Bebop(void) {};
33 
34  // initialise
35  void init() override;
36 
37  // read the latest battery voltage
38  void read() override;
39 
40  // bebop provides current info
41  bool has_current() const override { return true; };
42 
43 private:
44  float _prev_vbat_raw;
45  float _prev_vbat;
47  float _compute_compensation(const uint16_t *rpm, float vbat_raw);
48  float _filter_voltage(float vbat_raw);
49  float _compute_battery_percentage(float vbat);
50 };
float _compute_battery_percentage(float vbat)
bool has_current() const override
returns true if battery monitor instance provides current info
#define f(i)
Common definitions and utility routines for the ArduPilot libraries.
virtual ~AP_BattMonitor_Bebop(void)
float _filter_voltage(float vbat_raw)
float _compute_compensation(const uint16_t *rpm, float vbat_raw)
AP_BattMonitor_Bebop(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params &params)