mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 15:17:48 +01:00
39 lines
757 B
C++
39 lines
757 B
C++
//
|
|
// Created by Stepan Usatiuk on 02.03.2025.
|
|
//
|
|
|
|
#ifndef CB_BAT_MON_HPP
|
|
#define CB_BAT_MON_HPP
|
|
|
|
#include "config.hpp"
|
|
|
|
#include "driver/i2c_master.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
class BatMon {
|
|
public:
|
|
static BatMon& get();
|
|
float get_voltage() const;
|
|
float get_charge() const;
|
|
float get_current() const;
|
|
|
|
void pooler(); // FIXME:
|
|
private:
|
|
static inline i2c_device_config_t _dev_cfg = {
|
|
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
|
.device_address = 0x36,
|
|
.scl_speed_hz = 100000,
|
|
.flags = 0,
|
|
};
|
|
|
|
BatMon();
|
|
|
|
volatile float _voltage;
|
|
volatile float _current;
|
|
volatile float _charge;
|
|
|
|
TaskHandle_t _pooler_task;
|
|
};
|
|
|
|
#endif // CB_BAT_MON_HPP
|