Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/14#pragma once1516#include <AP_Common/AP_Common.h>17#include <AP_HAL/AP_HAL.h>18#include "AP_BattMonitor_Backend.h"1920class AP_BattMonitor_Bebop :public AP_BattMonitor_Backend21{22public:23// constructor. This incorporates initialisation as well.24AP_BattMonitor_Bebop(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms):25AP_BattMonitor_Backend(mon, mon_state, params),26_prev_vbat_raw(0.0f),27_prev_vbat(0.0f),28_battery_voltage_max(0.0f)29{};3031virtual ~AP_BattMonitor_Bebop(void) {};3233// initialise34void init() override;3536// read the latest battery voltage37void read() override;3839// bebop provides current info40bool has_current() const override { return true; };4142// don't allow reset of remaining capacity for bebop battery43bool reset_remaining(float percentage) override { return false; }4445private:46float _prev_vbat_raw;47float _prev_vbat;48float _battery_voltage_max;49float _compute_compensation(const uint16_t *rpm, float vbat_raw);50float _filter_voltage(float vbat_raw);51float _compute_battery_percentage(float vbat);52};535455