CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_LTC2946.h
Views: 1798
1
#pragma once
2
3
#include <AP_Common/AP_Common.h>
4
#include <AP_HAL/I2CDevice.h>
5
#include "AP_BattMonitor_Backend.h"
6
#include <utility>
7
8
#if AP_BATTERY_LTC2946_ENABLED
9
10
class AP_BattMonitor_LTC2946 : public AP_BattMonitor_Backend
11
{
12
public:
13
// inherit constructor
14
using AP_BattMonitor_Backend::AP_BattMonitor_Backend;
15
16
bool has_cell_voltages() const override { return false; }
17
bool has_temperature() const override { return false; }
18
bool has_current() const override { return true; }
19
bool get_cycle_count(uint16_t &cycles) const override { return false; }
20
21
virtual void init(void) override;
22
virtual void read() override;
23
24
private:
25
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;
26
27
bool read_word(const uint8_t reg, uint16_t& data) const;
28
void timer(void);
29
30
struct {
31
uint16_t count;
32
float volt_sum;
33
float current_sum;
34
HAL_Semaphore sem;
35
} accumulate;
36
float current_LSB;
37
float voltage_LSB;
38
};
39
40
#endif // AP_BATTERY_LTC2946_ENABLED
41
42