Merge develop into main (#316)
- Updated all boards to use `hal::Configuration.createDevices` - Updated all boards to use new directory structure and file naming convention - Refactored `Xpt2046SoftSpi` driver. - Created `Axp2101Power` device in `Drivers/AXP2101` - Removed global static instances from some drivers (instances that kept a reference to the Device*) - Improved `SystemInfoApp` UI: better memory labels, hide external memory bar when there's no PSRAM - Fix for HAL: register touch devices after displays are registered - Fix for Boot splash hanging on WiFi init: unlock file lock after using it
This commit is contained in:
committed by
GitHub
parent
1deaf4c426
commit
1627b9fa85
@@ -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",
|
||||
|
||||
+3
-3
@@ -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
|
||||
+4
@@ -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
-3
@@ -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();
|
||||
@@ -1,82 +0,0 @@
|
||||
#include "CoreS3Power.h"
|
||||
|
||||
bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage:
|
||||
case IsCharging:
|
||||
case ChargeLevel:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool CoreS3Power::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage: {
|
||||
float milliVolt;
|
||||
if (axpDevice->getBatteryVoltage(milliVolt)) {
|
||||
data.valueAsUint32 = (uint32_t)milliVolt;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case ChargeLevel: {
|
||||
float vbatMillis;
|
||||
if (axpDevice->getBatteryVoltage(vbatMillis)) {
|
||||
float vbat = vbatMillis / 1000.f;
|
||||
float max_voltage = 4.20f;
|
||||
float min_voltage = 2.69f; // From M5Unified
|
||||
if (vbat > 2.69f) {
|
||||
float charge_factor = (vbat - min_voltage) / (max_voltage - min_voltage);
|
||||
data.valueAsUint8 = (uint8_t)(charge_factor * 100.f);
|
||||
} else {
|
||||
data.valueAsUint8 = 0;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case IsCharging: {
|
||||
Axp2101::ChargeStatus status;
|
||||
if (axpDevice->getChargeStatus(status)) {
|
||||
data.valueAsBool = (status == Axp2101::CHARGE_STATUS_CHARGING);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CoreS3Power::isAllowedToCharge() const {
|
||||
bool enabled;
|
||||
if (axpDevice->isChargingEnabled(enabled)) {
|
||||
return enabled;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CoreS3Power::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;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <Axp2101.h>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class CoreS3Power final : public PowerDevice {
|
||||
|
||||
std::shared_ptr<Axp2101> axpDevice;
|
||||
|
||||
public:
|
||||
|
||||
explicit CoreS3Power(std::shared_ptr<Axp2101> axp) : axpDevice(std::move(axp)) {}
|
||||
~CoreS3Power() override = default;
|
||||
|
||||
std::string getName() const final { return "AXP2101 Power"; }
|
||||
std::string getDescription() const final { return "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;
|
||||
};
|
||||
|
||||
std::shared_ptr<PowerDevice> createPower();
|
||||
Reference in New Issue
Block a user