HAL renaming & relocation (#215)
Implemented more consistent naming: - Moved all HAL devices into their own namespace (and related folder) - Post-fixed all HAL device names with "Device"
This commit is contained in:
committed by
GitHub
parent
a7a3b17ff6
commit
2345ba6d13
@@ -10,7 +10,7 @@
|
||||
|
||||
#define TAG "cores3"
|
||||
|
||||
void setBacklightDuty(uint8_t backlightDuty) {
|
||||
static void setBacklightDuty(uint8_t backlightDuty) {
|
||||
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
|
||||
// TODO: Refactor to use Axp2102 class with https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
|
||||
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
|
||||
@@ -18,7 +18,7 @@ void setBacklightDuty(uint8_t backlightDuty) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch = std::make_shared<CoreS3Touch>();
|
||||
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Display.h>
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay();
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -14,7 +14,7 @@ bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
bool CoreS3Power::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage: {
|
||||
@@ -70,10 +70,10 @@ void CoreS3Power::setAllowedToCharge(bool canCharge) {
|
||||
axpDevice->setChargingEnabled(canCharge);
|
||||
}
|
||||
|
||||
static std::shared_ptr<Power> power;
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
extern std::shared_ptr<Axp2101> axp2101;
|
||||
|
||||
std::shared_ptr<Power> createPower() {
|
||||
std::shared_ptr<PowerDevice> createPower() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<CoreS3Power>(axp2101);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <Axp2101.h>
|
||||
#include <Tactility/hal/Power.h>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class CoreS3Power final : public Power {
|
||||
class CoreS3Power final : public PowerDevice {
|
||||
|
||||
std::shared_ptr<Axp2101> axpDevice;
|
||||
|
||||
@@ -20,11 +20,11 @@ public:
|
||||
std::string getDescription() const final { return "Power management via I2C"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override;
|
||||
bool getMetric(Power::MetricType type, Power::MetricData& data) 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<Power> createPower();
|
||||
std::shared_ptr<PowerDevice> createPower();
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
#include "CoreS3SdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/SpiSdCard.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
|
||||
#define CORES3_SDCARD_PIN_CS GPIO_NUM_4
|
||||
#define CORES3_LCD_PIN_CS GPIO_NUM_3
|
||||
|
||||
std::shared_ptr<SdCard> createSdCard() {
|
||||
auto* configuration = new tt::hal::SpiSdCard::Config(
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
CORES3_SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCard::MountBehaviour::AtBoot,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getLvglSyncLockable(),
|
||||
{
|
||||
CORES3_LCD_PIN_CS
|
||||
@@ -22,9 +24,9 @@ std::shared_ptr<SdCard> createSdCard() {
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
auto* sdcard = (SdCard*) new SpiSdCard(
|
||||
std::unique_ptr<SpiSdCard::Config>(configuration)
|
||||
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
|
||||
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
|
||||
);
|
||||
|
||||
return std::shared_ptr<SdCard>(sdcard);
|
||||
return std::shared_ptr<SdCardDevice>(sdcard);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/SdCard.h>
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCard> createSdCard();
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Touch.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <esp_lcd_touch.h>
|
||||
|
||||
class CoreS3Touch : public tt::hal::Touch {
|
||||
class CoreS3Touch : public tt::hal::touch::TouchDevice {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user