Line data Source code
1 : #pragma once 2 : 3 : #include "AP_BattMonitor_Analog.h" 4 : 5 : #if AP_BATTERY_FUELFLOW_ENABLED 6 : 7 : #include "AP_BattMonitor.h" 8 : 9 : class AP_BattMonitor_FuelFlow : public AP_BattMonitor_Analog 10 : { 11 : public: 12 : 13 : /// Constructor 14 : AP_BattMonitor_FuelFlow(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms); 15 : 16 : /// Read the battery voltage and current. Should be called at 10hz 17 : void read() override; 18 : 19 : /// returns true if battery monitor provides consumed energy info 20 0 : bool has_consumed_energy() const override { return true; } 21 : 22 : /// returns true if battery monitor provides current info 23 0 : bool has_current() const override { return true; } 24 : 25 0 : void init(void) override {} 26 : 27 : private: 28 : void irq_handler(uint8_t pin, bool pin_state, uint32_t timestamp); 29 : 30 : struct IrqState { 31 : uint32_t pulse_count; 32 : uint32_t total_us; 33 : uint32_t last_pulse_us; 34 : } irq_state; 35 : 36 : int8_t last_pin = -1; 37 : }; 38 : 39 : #endif // AP_BATTERY_FUELFLOW_ENABLED