2019-03-12 05:02:29 -03:00
|
|
|
#pragma once
|
|
|
|
|
2021-06-24 02:38:19 -03:00
|
|
|
#include "AP_BattMonitor_Analog.h"
|
2019-03-12 05:02:29 -03:00
|
|
|
|
2023-03-06 22:02:49 -04:00
|
|
|
#if AP_BATTERY_FUELFLOW_ENABLED
|
|
|
|
|
|
|
|
#include "AP_BattMonitor.h"
|
|
|
|
|
2021-06-24 02:38:19 -03:00
|
|
|
class AP_BattMonitor_FuelFlow : public AP_BattMonitor_Analog
|
2019-03-12 05:02:29 -03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Constructor
|
|
|
|
AP_BattMonitor_FuelFlow(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms);
|
|
|
|
|
|
|
|
/// Read the battery voltage and current. Should be called at 10hz
|
|
|
|
void read() override;
|
|
|
|
|
|
|
|
/// returns true if battery monitor provides consumed energy info
|
|
|
|
bool has_consumed_energy() const override { return true; }
|
|
|
|
|
|
|
|
/// returns true if battery monitor provides current info
|
|
|
|
bool has_current() const override { return true; }
|
|
|
|
|
|
|
|
void init(void) override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void irq_handler(uint8_t pin, bool pin_state, uint32_t timestamp);
|
|
|
|
|
|
|
|
struct IrqState {
|
|
|
|
uint32_t pulse_count;
|
|
|
|
uint32_t total_us;
|
|
|
|
uint32_t last_pulse_us;
|
|
|
|
} irq_state;
|
|
|
|
|
|
|
|
int8_t last_pin = -1;
|
|
|
|
};
|
2023-03-06 22:02:49 -04:00
|
|
|
|
|
|
|
#endif // AP_BATTERY_FUELFLOW_ENABLED
|