AP_BattMonitor_FuelFlow.h 923 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "AP_BattMonitor.h"
  3. #include "AP_BattMonitor_Backend.h"
  4. class AP_BattMonitor_FuelFlow : public AP_BattMonitor_Backend
  5. {
  6. public:
  7. /// Constructor
  8. AP_BattMonitor_FuelFlow(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params &params);
  9. /// Read the battery voltage and current. Should be called at 10hz
  10. void read() override;
  11. /// returns true if battery monitor provides consumed energy info
  12. bool has_consumed_energy() const override { return true; }
  13. /// returns true if battery monitor provides current info
  14. bool has_current() const override { return true; }
  15. void init(void) override {}
  16. private:
  17. void irq_handler(uint8_t pin, bool pin_state, uint32_t timestamp);
  18. struct IrqState {
  19. uint32_t pulse_count;
  20. uint32_t total_us;
  21. uint32_t last_pulse_us;
  22. } irq_state;
  23. int8_t last_pin = -1;
  24. };