mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
New boards: - LilyGO T-Dongle S3 - M5Stack StickC Plus - M5Stack StickC Plus2 New drivers: - AXP192: power control via I2C - ButtonControl: GPIO button input as LVGL device Other changes: - Updated implementation of AXP192 driver for Core2 board - Fix launcher UX for vertical layout - Fix error when properties file had an empty line - Add `__floatsidf` to `tt_init.cpp`
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <axp192/axp192.h>
|
|
#include <Tactility/hal/power/PowerDevice.h>
|
|
#include <Tactility/hal/i2c/I2c.h>
|
|
|
|
#include <memory>
|
|
|
|
class Axp192 final : public tt::hal::power::PowerDevice {
|
|
|
|
static int32_t i2cRead(void* handle, uint8_t address, uint8_t reg, uint8_t* buffer, uint16_t size);
|
|
static int32_t i2cWrite(void* handle, uint8_t address, uint8_t reg, const uint8_t* buffer, uint16_t size);
|
|
|
|
public:
|
|
|
|
struct Configuration {
|
|
i2c_port_t port;
|
|
TickType_t readTimeout = 50 / portTICK_PERIOD_MS;
|
|
TickType_t writeTimeout = 50 / portTICK_PERIOD_MS;
|
|
};
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Configuration> configuration;
|
|
|
|
axp192_t axpDevice = {
|
|
.read = i2cRead,
|
|
.write = i2cWrite,
|
|
.handle = this
|
|
};
|
|
|
|
bool isInitialized = false;
|
|
|
|
public:
|
|
|
|
explicit Axp192(std::unique_ptr<Configuration> configuration) : configuration(std::move(configuration)) {}
|
|
~Axp192() override {}
|
|
|
|
/**
|
|
* @warning Must call this function before device can operate!
|
|
* @param onInit
|
|
*/
|
|
bool init(const std::function<bool(axp192_t*)>& onInit) {
|
|
isInitialized = onInit(&axpDevice);
|
|
return isInitialized;
|
|
}
|
|
|
|
axp192_t* getAxp192() { return &axpDevice; }
|
|
|
|
std::string getName() const override { return "AXP192"; }
|
|
std::string getDescription() const override { return "AXP192 power management via I2C"; }
|
|
|
|
bool supportsMetric(MetricType type) const override;
|
|
bool getMetric(MetricType type, MetricData& data) override;
|
|
|
|
bool supportsChargeControl() const override { return true; }
|
|
bool isAllowedToCharge() const override;
|
|
void setAllowedToCharge(bool canCharge) override;
|
|
};
|