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_FuelLevel_Analog.h
Views: 1798
/*1* This file is free software: you can redistribute it and/or modify it2* under the terms of the GNU General Public License as published by the3* Free Software Foundation, either version 3 of the License, or4* (at your option) any later version.5*6* This file is distributed in the hope that it will be useful, but7* WITHOUT ANY WARRANTY; without even the implied warranty of8* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.9* See the GNU General Public License for more details.10*11* You should have received a copy of the GNU General Public License along12* with this program. If not, see <http://www.gnu.org/licenses/>.13*14* Code by Charlie Johnson15*/1617#pragma once1819#include "AP_BattMonitor_Backend.h"2021#if AP_BATTERY_FUELLEVEL_ANALOG_ENABLED2223#include <Filter/LowPassFilter.h>24#include "AP_BattMonitor.h"25#include <Filter/Filter.h> // Filter library2627class AP_BattMonitor_FuelLevel_Analog : public AP_BattMonitor_Backend28{29public:3031// Constructor32AP_BattMonitor_FuelLevel_Analog(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms);3334static const struct AP_Param::GroupInfo var_info[];3536// Read the battery voltage and current. Should be called at 10hz37void read() override;3839// returns true if battery monitor provides consumed energy info40bool has_consumed_energy() const override { return true; }4142// returns true if battery monitor provides current info (or capacity)43bool has_current() const override { return true; }4445void init(void) override {}4647private:4849AP_Float _fuel_level_empty_voltage;50AP_Float _fuel_level_voltage_mult;51AP_Float _fuel_level_filter_frequency;52AP_Int8 _pin;53AP_Float _fuel_fit_first_order_coeff;54AP_Float _fuel_fit_second_order_coeff;55AP_Float _fuel_fit_third_order_coeff;56AP_Float _fuel_fit_offset;57AP_HAL::AnalogSource *_analog_source;5859LowPassFilterFloat _voltage_filter;6061};6263#endif // AP_BATTERY_FUELLEVEL_ANALOG_ENABLED646566