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_EFI.cpp
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*/1415#include "AP_BattMonitor_config.h"1617#if AP_BATTERY_EFI_ENABLED1819#include <AP_Common/AP_Common.h>20#include <AP_Math/AP_Math.h>21#include <AP_EFI/AP_EFI.h>2223#include "AP_BattMonitor_EFI.h"2425// update state26void AP_BattMonitor_EFI::read()27{28AP_EFI *efi = AP::EFI();29if (efi == nullptr) {30return;31}3233if (!efi->is_healthy()) {34_state.healthy = false;35return;36}3738struct EFI_State efi_state;39/*40a simple mapping of 1 Amp == 1 litre/hour and 1Ah = 1Litre41*/42efi->get_state(efi_state);4344_state.current_amps = efi_state.fuel_consumption_rate_cm3pm*0.001*60; // litres/hour45// use arbitrary 1.0 Volts46_state.voltage = 1.0;47_state.consumed_mah = efi_state.estimated_consumed_fuel_volume_cm3; // millilitres48_state.consumed_wh = 0.001 * _state.consumed_mah;49_state.healthy = true;50_state.last_time_micros = AP_HAL::micros();51}5253#endif // AP_BATTERY_EFI_ENABLED545556