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
@@ -71,7 +71,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<YellowTouch>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Display.h>
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay();
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -2,28 +2,30 @@
|
||||
|
||||
#define TAG "twodotfour_sdcard"
|
||||
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/SpiSdCard.h>
|
||||
|
||||
#define SDCARD_SPI_HOST SPI3_HOST
|
||||
#define SDCARD_PIN_CS GPIO_NUM_5
|
||||
|
||||
std::shared_ptr<SdCard> createYellowSdCard() {
|
||||
auto* configuration = new tt::hal::SpiSdCard::Config(
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCard::MountBehaviour::AtBoot,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::Mutex>(),
|
||||
std::vector<gpio_num_t>(),
|
||||
SDCARD_SPI_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,8 +1,8 @@
|
||||
#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> createYellowSdCard();
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard();
|
||||
|
||||
|
||||
@@ -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 YellowTouch : public tt::hal::Touch {
|
||||
class YellowTouch : public tt::hal::touch::TouchDevice {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ void TdeckDisplay::setPowerOn(bool turnOn) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Touch> _Nullable TdeckDisplay::createTouch() {
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable TdeckDisplay::createTouch() {
|
||||
return std::make_shared<TdeckTouch>();
|
||||
}
|
||||
|
||||
@@ -233,6 +233,6 @@ void TdeckDisplay::setGammaCurve(uint8_t index) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
return std::make_shared<TdeckDisplay>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <esp_lcd_types.h>
|
||||
#include <lvgl.h>
|
||||
#include <Tactility/hal/Display.h>
|
||||
|
||||
class TdeckDisplay : public tt::hal::Display {
|
||||
class TdeckDisplay : public tt::hal::display::DisplayDevice {
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
bool isPoweredOn() const override { return poweredOn; };
|
||||
bool supportsPowerControl() const override { return true; }
|
||||
|
||||
std::shared_ptr<tt::hal::Touch> _Nullable createTouch() override;
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
|
||||
|
||||
void setBacklightDuty(uint8_t backlightDuty) override;
|
||||
bool supportsBacklightDuty() const override { return true; }
|
||||
@@ -35,10 +35,6 @@ public:
|
||||
uint8_t getGammaCurveCount() const override { return 4; };
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
|
||||
|
||||
private:
|
||||
|
||||
static bool startBacklight();
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay();
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -62,6 +62,6 @@ bool TdeckKeyboard::isAttached() const {
|
||||
return tt::hal::i2c::masterHasDeviceAtAddress(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, 100);
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Keyboard> createKeyboard() {
|
||||
std::shared_ptr<tt::hal::keyboard::KeyboardDevice> createKeyboard() {
|
||||
return std::make_shared<TdeckKeyboard>();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Keyboard.h>
|
||||
#include <Tactility/hal/keyboard/KeyboardDevice.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <esp_lcd_panel_io_interface.h>
|
||||
#include <esp_lcd_touch.h>
|
||||
|
||||
class TdeckKeyboard : public tt::hal::Keyboard {
|
||||
class TdeckKeyboard : public tt::hal::keyboard::KeyboardDevice {
|
||||
|
||||
private:
|
||||
|
||||
@@ -22,4 +22,4 @@ public:
|
||||
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::Keyboard> createKeyboard();
|
||||
std::shared_ptr<tt::hal::keyboard::KeyboardDevice> createKeyboard();
|
||||
|
||||
@@ -66,7 +66,7 @@ bool TdeckPower::supportsMetric(MetricType type) const {
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool TdeckPower::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
bool TdeckPower::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage:
|
||||
@@ -119,9 +119,9 @@ bool TdeckPower::readBatteryVoltageSampled(uint32_t& output) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::shared_ptr<Power> power;
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
|
||||
std::shared_ptr<Power> tdeck_get_power() {
|
||||
std::shared_ptr<PowerDevice> tdeck_get_power() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<TdeckPower>();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Power.h>
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <esp_adc/adc_oneshot.h>
|
||||
#include <memory>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class TdeckPower : public Power {
|
||||
class TdeckPower : public PowerDevice {
|
||||
|
||||
adc_oneshot_unit_handle_t adcHandle = nullptr;
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
std::string getDescription() const final { return "Power measurement interface via ADC pin"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override;
|
||||
bool getMetric(Power::MetricType type, Power::MetricData& data) override;
|
||||
bool getMetric(MetricType type, MetricData& data) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,4 +27,4 @@ private:
|
||||
bool readBatteryVoltageOnce(uint32_t& output);
|
||||
};
|
||||
|
||||
std::shared_ptr<Power> tdeck_get_power();
|
||||
std::shared_ptr<PowerDevice> tdeck_get_power();
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
#include "TdeckSdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/SpiSdCard.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
#define TDECK_SDCARD_PIN_CS GPIO_NUM_39
|
||||
#define TDECK_LCD_PIN_CS GPIO_NUM_12
|
||||
#define TDECK_RADIO_PIN_CS GPIO_NUM_9
|
||||
|
||||
std::shared_ptr<SdCard> createTdeckSdCard() {
|
||||
auto* configuration = new tt::hal::SpiSdCard::Config(
|
||||
std::shared_ptr<SdCardDevice> createTdeckSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
TDECK_SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCard::MountBehaviour::AtBoot,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getLvglSyncLockable(),
|
||||
{
|
||||
TDECK_RADIO_PIN_CS,
|
||||
@@ -23,9 +25,9 @@ std::shared_ptr<SdCard> createTdeckSdCard() {
|
||||
}
|
||||
);
|
||||
|
||||
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> createTdeckSdCard();
|
||||
std::shared_ptr<SdCardDevice> createTdeckSdCard();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Touch.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <esp_lcd_panel_io_interface.h>
|
||||
#include <esp_lcd_touch.h>
|
||||
|
||||
class TdeckTouch : public tt::hal::Touch {
|
||||
class TdeckTouch : public tt::hal::touch::TouchDevice {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <Ili934xDisplay.h>
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch = std::make_shared<Core2Touch>();
|
||||
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Display.h>
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
#define CORE2_LCD_SPI_HOST SPI2_HOST
|
||||
@@ -11,4 +11,4 @@
|
||||
#define CORE2_LCD_DRAW_BUFFER_HEIGHT (CORE2_LCD_VERTICAL_RESOLUTION / 10)
|
||||
#define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT)
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay();
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -20,7 +20,7 @@ bool Core2Power::supportsMetric(MetricType type) const {
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool Core2Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
bool Core2Power::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage: {
|
||||
@@ -100,9 +100,9 @@ void Core2Power::setAllowedToCharge(bool canCharge) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::shared_ptr<Power> power;
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
|
||||
std::shared_ptr<Power> createPower() {
|
||||
std::shared_ptr<PowerDevice> createPower() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<Core2Power>();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Power.h>
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class Core2Power : public Power {
|
||||
class Core2Power : public PowerDevice {
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,11 +16,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,29 +1,31 @@
|
||||
#include "Core2SdCard.h"
|
||||
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/SpiSdCard.h>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
|
||||
#define CORE2_SDCARD_PIN_CS GPIO_NUM_4
|
||||
#define CORE2_LCD_PIN_CS GPIO_NUM_5
|
||||
|
||||
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(
|
||||
CORE2_SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCard::MountBehaviour::AtBoot,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getLvglSyncLockable(),
|
||||
{
|
||||
CORE2_LCD_PIN_CS
|
||||
}
|
||||
);
|
||||
|
||||
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/TactilityCore.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include "ft6x36/FT6X36.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
class Core2Touch : public tt::hal::Touch {
|
||||
class Core2Touch : public tt::hal::touch::TouchDevice {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "SdlTouch.h"
|
||||
#include <Tactility/hal/Display.h>
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
/** Hack: variable comes from LvglTask.cpp */
|
||||
extern lv_disp_t* displayHandle;
|
||||
|
||||
class SdlDisplay final : public tt::hal::Display {
|
||||
class SdlDisplay final : public tt::hal::display::DisplayDevice {
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,12 +20,12 @@ public:
|
||||
|
||||
bool stop() override { tt_crash("Not supported"); }
|
||||
|
||||
std::shared_ptr<tt::hal::Touch> _Nullable createTouch() override { return std::make_shared<SdlTouch>(); }
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override { return std::make_shared<SdlTouch>(); }
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
return std::make_shared<SdlDisplay>();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Keyboard.h>
|
||||
#include <Tactility/hal/keyboard/KeyboardDevice.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
class SdlKeyboard final : public tt::hal::Keyboard {
|
||||
class SdlKeyboard final : public tt::hal::keyboard::KeyboardDevice {
|
||||
private:
|
||||
lv_indev_t* _Nullable handle = nullptr;
|
||||
|
||||
@@ -24,6 +24,6 @@ public:
|
||||
lv_indev_t* _Nullable getLvglIndev() override { return handle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::Keyboard> createKeyboard() {
|
||||
std::shared_ptr<tt::hal::keyboard::KeyboardDevice> createKeyboard() {
|
||||
return std::make_shared<SdlKeyboard>();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Touch.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
class SdlTouch final : public tt::hal::Touch {
|
||||
class SdlTouch final : public tt::hal::touch::TouchDevice {
|
||||
private:
|
||||
lv_indev_t* _Nullable handle = nullptr;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ bool SimulatorPower::supportsMetric(MetricType type) const {
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool SimulatorPower::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
bool SimulatorPower::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case IsCharging:
|
||||
@@ -35,9 +35,9 @@ bool SimulatorPower::getMetric(Power::MetricType type, Power::MetricData& data)
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
static std::shared_ptr<Power> power;
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
|
||||
std::shared_ptr<Power> simulatorPower() {
|
||||
std::shared_ptr<PowerDevice> simulatorPower() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<SimulatorPower>();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Power.h>
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class SimulatorPower final : public Power {
|
||||
class SimulatorPower final : public PowerDevice {
|
||||
|
||||
bool allowedToCharge = false;
|
||||
|
||||
@@ -18,11 +18,11 @@ public:
|
||||
std::string getDescription() const final { return ""; }
|
||||
|
||||
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 { return allowedToCharge; }
|
||||
void setAllowedToCharge(bool canCharge) override { allowedToCharge = canCharge; }
|
||||
};
|
||||
|
||||
std::shared_ptr<Power> simulatorPower();
|
||||
std::shared_ptr<PowerDevice> simulatorPower();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/SdCard.h>
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <memory>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
class SimulatorSdCard final : public SdCard {
|
||||
class SimulatorSdCard final : public SdCardDevice {
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,7 +16,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
SimulatorSdCard() : SdCard(MountBehaviour::AtBoot),
|
||||
SimulatorSdCard() : SdCardDevice(MountBehaviour::AtBoot),
|
||||
state(State::Unmounted),
|
||||
lockable(std::make_shared<tt::Mutex>())
|
||||
{}
|
||||
|
||||
@@ -63,10 +63,10 @@ bool UnPhoneDisplay::stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Touch> _Nullable UnPhoneDisplay::createTouch() {
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable UnPhoneDisplay::createTouch() {
|
||||
return std::make_shared<UnPhoneTouch>();
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay() {
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
return std::make_shared<UnPhoneDisplay>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <esp_lcd_types.h>
|
||||
#include <lvgl.h>
|
||||
#include <Tactility/hal/Display.h>
|
||||
|
||||
class UnPhoneDisplay : public tt::hal::Display {
|
||||
class UnPhoneDisplay : public tt::hal::display::DisplayDevice {
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,9 +20,9 @@ public:
|
||||
|
||||
bool stop() override;
|
||||
|
||||
std::shared_ptr<tt::hal::Touch> _Nullable createTouch() override;
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::Display> createDisplay();
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -27,7 +27,7 @@ bool UnPhonePower::supportsMetric(MetricType type) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool UnPhonePower::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
bool UnPhonePower::getMetric(MetricType type, MetricData& data) {
|
||||
switch (type) {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage:
|
||||
@@ -83,9 +83,9 @@ bool UnPhonePower::readBatteryVoltageSampled(uint32_t& output) const {
|
||||
}
|
||||
}
|
||||
|
||||
static std::shared_ptr<Power> power;
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
|
||||
std::shared_ptr<Power> unPhoneGetPower() {
|
||||
std::shared_ptr<PowerDevice> unPhoneGetPower() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<UnPhonePower>();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Power.h>
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace tt::hal;
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class UnPhonePower : public Power {
|
||||
class UnPhonePower : public PowerDevice {
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
std::string getDescription() const final { return "Power interface via XPT2046 voltage measurement"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override;
|
||||
bool getMetric(Power::MetricType type, Power::MetricData& data) override;
|
||||
bool getMetric(MetricType type, MetricData& data) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -24,4 +24,4 @@ private:
|
||||
bool readBatteryVoltageSampled(uint32_t& output) const;
|
||||
};
|
||||
|
||||
std::shared_ptr<Power> unPhoneGetPower();
|
||||
std::shared_ptr<PowerDevice> unPhoneGetPower();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "UnPhoneSdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/SpiSdCard.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
#define UNPHONE_LORA_PIN_CS GPIO_NUM_44
|
||||
#define UNPHONE_TOUCH_PIN_CS GPIO_NUM_38
|
||||
|
||||
std::shared_ptr<SdCard> createUnPhoneSdCard() {
|
||||
auto* configuration = new tt::hal::SpiSdCard::Config(
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createUnPhoneSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
UNPHONE_SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCard::MountBehaviour::AtBoot,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getLvglSyncLockable(),
|
||||
{
|
||||
UNPHONE_LORA_PIN_CS,
|
||||
@@ -25,9 +27,9 @@ std::shared_ptr<SdCard> createUnPhoneSdCard() {
|
||||
}
|
||||
);
|
||||
|
||||
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> createUnPhoneSdCard();
|
||||
std::shared_ptr<SdCardDevice> createUnPhoneSdCard();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Touch.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <esp_lcd_panel_io_interface.h>
|
||||
#include <esp_lcd_touch.h>
|
||||
|
||||
class UnPhoneTouch : public tt::hal::Touch {
|
||||
class UnPhoneTouch : public tt::hal::touch::TouchDevice {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user