mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-19 03:13:14 +00:00
Board update and created Axp2101Power class
This commit is contained in:
parent
b0408e40ec
commit
e971f01eeb
@ -1,5 +1,7 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source" "Source/hal"
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port ILI934x FT5x06 AXP2101 AW9523 driver vfs fatfs
|
||||
)
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define AXP2101_ADDRESS 0x34
|
||||
#define AW9523_ADDRESS 0x58
|
||||
@ -1,10 +1,9 @@
|
||||
#include <Axp2101.h>
|
||||
#include <Aw9523.h>
|
||||
#include "InitBoot.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#define TAG "cores3"
|
||||
constexpr auto* TAG = "CoreS3";
|
||||
|
||||
std::shared_ptr<Axp2101> axp2101;
|
||||
std::shared_ptr<Aw9523> aw9523;
|
||||
@ -148,9 +147,7 @@ bool initBoot() {
|
||||
TT_LOG_I(TAG, "initBoot()");
|
||||
|
||||
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
|
||||
tt::hal::registerDevice(axp2101);
|
||||
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
|
||||
tt::hal::registerDevice(aw9523);
|
||||
|
||||
return initPowerControl() && initGpioExpander();
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <Axp2101.h>
|
||||
#include <Aw9523.h>
|
||||
|
||||
extern std::shared_ptr<Axp2101> axp2101;
|
||||
extern std::shared_ptr<Aw9523> aw9523;
|
||||
|
||||
bool initBoot();
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
#include "M5stackCoreS3.h"
|
||||
#include "InitBoot.h"
|
||||
#include "hal/CoreS3Display.h"
|
||||
#include "hal/CoreS3DisplayConstants.h"
|
||||
#include "hal/CoreS3Power.h"
|
||||
#include "hal/CoreS3SdCard.h"
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
|
||||
#include <Axp2101Power.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
|
||||
@ -12,11 +11,19 @@
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
axp2101,
|
||||
aw9523,
|
||||
std::make_shared<Axp2101Power>(axp2101),
|
||||
createSdCard(),
|
||||
createDisplay()
|
||||
};
|
||||
}
|
||||
|
||||
const Configuration m5stack_cores3 = {
|
||||
.initBoot = initBoot,
|
||||
.createDisplay = createDisplay,
|
||||
.sdcard = createSdCard(),
|
||||
.power = createPower,
|
||||
.createDevices = createDevices,
|
||||
.i2c = {
|
||||
i2c::Configuration {
|
||||
.name = "Internal",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
#include "CoreS3Display.h"
|
||||
#include "CoreS3Constants.h"
|
||||
#include "Display.h"
|
||||
|
||||
#include <Axp2101.h>
|
||||
#include <Ft5x06Touch.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
|
||||
constexpr auto TAG = "CoreS3Display";
|
||||
constexpr auto* TAG = "CoreS3Display";
|
||||
|
||||
static void setBacklightDuty(uint8_t backlightDuty) {
|
||||
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
|
||||
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
|
||||
// Display
|
||||
#define CORES3_LCD_SPI_HOST SPI3_HOST
|
||||
#define CORES3_LCD_PIN_CS GPIO_NUM_3
|
||||
@ -8,3 +10,5 @@
|
||||
#define CORES3_LCD_VERTICAL_RESOLUTION 240
|
||||
#define CORES3_LCD_DRAW_BUFFER_HEIGHT (CORES3_LCD_VERTICAL_RESOLUTION / 10)
|
||||
#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT)
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@ -1,10 +1,8 @@
|
||||
#include "CoreS3SdCard.h"
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
|
||||
constexpr auto CORES3_SDCARD_PIN_CS = GPIO_NUM_4;
|
||||
constexpr auto CORES3_LCD_PIN_CS = GPIO_NUM_3;
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@ -21,8 +21,8 @@ public:
|
||||
|
||||
explicit Axp2101(i2c_port_t port) : I2cDevice(port, AXP2101_ADDRESS) {}
|
||||
|
||||
std::string getName() const final { return "AXP2101"; }
|
||||
std::string getDescription() const final { return "Power management with I2C interface."; }
|
||||
std::string getName() const override { return "AXP2101"; }
|
||||
std::string getDescription() const override { return "Power management with I2C interface."; }
|
||||
|
||||
bool setRegisters(uint8_t* bytePairs, size_t bytePairsSize) const;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "CoreS3Power.h"
|
||||
#include "Axp2101Power.h"
|
||||
|
||||
bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
bool Axp2101Power::supportsMetric(MetricType type) const {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage:
|
||||
@ -14,7 +14,7 @@ bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool CoreS3Power::getMetric(MetricType type, MetricData& data) {
|
||||
bool Axp2101Power::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage: {
|
||||
@ -57,7 +57,7 @@ bool CoreS3Power::getMetric(MetricType type, MetricData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
bool CoreS3Power::isAllowedToCharge() const {
|
||||
bool Axp2101Power::isAllowedToCharge() const {
|
||||
bool enabled;
|
||||
if (axpDevice->isChargingEnabled(enabled)) {
|
||||
return enabled;
|
||||
@ -66,17 +66,6 @@ bool CoreS3Power::isAllowedToCharge() const {
|
||||
}
|
||||
}
|
||||
|
||||
void CoreS3Power::setAllowedToCharge(bool canCharge) {
|
||||
void Axp2101Power::setAllowedToCharge(bool canCharge) {
|
||||
axpDevice->setChargingEnabled(canCharge);
|
||||
}
|
||||
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
extern std::shared_ptr<Axp2101> axp2101;
|
||||
|
||||
std::shared_ptr<PowerDevice> createPower() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<CoreS3Power>(axp2101);
|
||||
}
|
||||
|
||||
return power;
|
||||
}
|
||||
@ -7,17 +7,17 @@
|
||||
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class CoreS3Power final : public PowerDevice {
|
||||
class Axp2101Power final : public PowerDevice {
|
||||
|
||||
std::shared_ptr<Axp2101> axpDevice;
|
||||
|
||||
public:
|
||||
|
||||
explicit CoreS3Power(std::shared_ptr<Axp2101> axp) : axpDevice(std::move(axp)) {}
|
||||
~CoreS3Power() override = default;
|
||||
explicit Axp2101Power(std::shared_ptr<Axp2101> axp) : axpDevice(std::move(axp)) {}
|
||||
~Axp2101Power() override = default;
|
||||
|
||||
std::string getName() const final { return "AXP2101 Power"; }
|
||||
std::string getDescription() const final { return "Power management via I2C"; }
|
||||
std::string getName() const override { return "AXP2101 Power"; }
|
||||
std::string getDescription() const override { return "Power management via AXP2101 over I2C"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override;
|
||||
bool getMetric(MetricType type, MetricData& data) override;
|
||||
@ -26,5 +26,3 @@ public:
|
||||
bool isAllowedToCharge() const override;
|
||||
void setAllowedToCharge(bool canCharge) override;
|
||||
};
|
||||
|
||||
std::shared_ptr<PowerDevice> createPower();
|
||||
Loading…
x
Reference in New Issue
Block a user