mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
- Change init sequence: I2C is now initialized before "power" init phase, to allow for I2C power control - I2c HAL: Added read/write support for registers - Added axp192 code from https://github.com/tuupola/axp192 to Core2 implementation - Fixes for Core2Power - Fix for root project CMakeLists.txt
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
namespace tt::hal {
|
|
|
|
class Power{
|
|
|
|
public:
|
|
|
|
Power() = default;
|
|
virtual ~Power() = default;
|
|
|
|
enum MetricType {
|
|
IS_CHARGING, // bool
|
|
CURRENT, // int32_t, mAh - battery current: either during charging (positive value) or discharging (negative value)
|
|
BATTERY_VOLTAGE, // uint32_t, mV
|
|
CHARGE_LEVEL, // uint8_t [0, 100]
|
|
};
|
|
|
|
union MetricData {
|
|
int32_t valueAsInt32 = 0;
|
|
uint32_t valueAsUint32;
|
|
uint8_t valueAsUint8;
|
|
float valueAsFloat;
|
|
bool valueAsBool;
|
|
};
|
|
|
|
virtual bool supportsMetric(MetricType type) const = 0;
|
|
|
|
/**
|
|
* @return false when metric is not supported or (temporarily) not available.
|
|
*/
|
|
virtual bool getMetric(Power::MetricType type, MetricData& data) = 0;
|
|
|
|
virtual bool supportsChargeControl() const { return false; }
|
|
virtual bool isAllowedToCharge() const { return false; }
|
|
virtual void setAllowedToCharge(bool canCharge) { /* NO-OP*/ }
|
|
};
|
|
|
|
} // namespace tt
|