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:
Ken Van Hoeylandt
2025-09-03 22:05:28 +02:00
committed by GitHub
parent 1deaf4c426
commit 1627b9fa85
135 changed files with 543 additions and 577 deletions
@@ -3,7 +3,7 @@
#include <Tactility/TactilityCore.h>
#include <esp_sleep.h>
#define TAG "unphone"
constexpr auto* TAG = "unPhone";
std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
static std::unique_ptr<tt::Thread> powerThread;
@@ -14,8 +14,6 @@ static const char* powerSleepKey = "power_sleep_key";
class DeviceStats {
private:
tt::Preferences preferences = tt::Preferences("unphone");
int32_t getValue(const char* key) {
@@ -161,7 +159,6 @@ static bool unPhonePowerOn() {
bootStats.notifyBootStart();
bq24295 = std::make_shared<Bq24295>(I2C_NUM_0);
tt::hal::registerDevice(bq24295);
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
@@ -185,7 +182,7 @@ static bool unPhonePowerOn() {
return true;
}
bool unPhoneInitPower() {
bool initBoot() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
if (!unPhonePowerOn()) {
+13 -8
View File
@@ -1,20 +1,25 @@
#include "Tactility/lvgl/LvglSync.h"
#include "UnPhoneFeatures.h"
#include "Xpt2046Power.h"
#include "hal/UnPhoneDisplay.h"
#include "hal/UnPhoneDisplayConstants.h"
#include "hal/UnPhoneSdCard.h"
#include "devices/Hx8357Display.h"
#include "devices/SdCard.h"
#include <Tactility/hal/Configuration.h>
#define UNPHONE_SPI_TRANSFER_SIZE_LIMIT (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_SPI_TRANSFER_HEIGHT * LV_COLOR_DEPTH / 8)
bool unPhoneInitPower();
bool initBoot();
static tt::hal::DeviceVector createDevices() {
return {
std::make_shared<Xpt2046Power>(),
createDisplay(),
createSdCard()
};
}
extern const tt::hal::Configuration unPhone = {
.initBoot = unPhoneInitPower,
.createDisplay = createDisplay,
.sdcard = createUnPhoneSdCard(),
.power = getOrCreatePower,
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {
tt::hal::i2c::Configuration {
.name = "Internal",
@@ -1,20 +1,18 @@
#include "UnPhoneDisplay.h"
#include "UnPhoneDisplayConstants.h"
#include "UnPhoneTouch.h"
#include "UnPhoneFeatures.h"
#include "Hx8357Display.h"
#include "Touch.h"
#include <UnPhoneFeatures.h>
#include <Tactility/Log.h>
#include <esp_err.h>
#include <hx8357/disp_spi.h>
#include <hx8357/hx8357.h>
constexpr auto TAG = "UnPhoneDisplay";
constexpr auto TAG = "Hx8357Display";
constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8);
extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
bool UnPhoneDisplay::start() {
bool Hx8357Display::start() {
TT_LOG_I(TAG, "start");
disp_spi_add_device(SPI2_HOST);
@@ -27,13 +25,13 @@ bool UnPhoneDisplay::start() {
return true;
}
bool UnPhoneDisplay::stop() {
bool Hx8357Display::stop() {
TT_LOG_I(TAG, "stop");
disp_spi_remove_device();
return true;
}
bool UnPhoneDisplay::startLvgl() {
bool Hx8357Display::startLvgl() {
TT_LOG_I(TAG, "startLvgl");
if (lvglDisplay != nullptr) {
@@ -74,7 +72,7 @@ bool UnPhoneDisplay::startLvgl() {
return true;
}
bool UnPhoneDisplay::stopLvgl() {
bool Hx8357Display::stopLvgl() {
TT_LOG_I(TAG, "stopLvgl");
if (lvglDisplay == nullptr) {
@@ -100,7 +98,7 @@ bool UnPhoneDisplay::stopLvgl() {
return true;
}
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable UnPhoneDisplay::getTouchDevice() {
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable Hx8357Display::getTouchDevice() {
if (touchDevice == nullptr) {
touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch());
TT_LOG_I(TAG, "Created touch device");
@@ -110,10 +108,10 @@ std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable UnPhoneDisplay::getTouchD
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
return std::make_shared<UnPhoneDisplay>();
return std::make_shared<Hx8357Display>();
}
bool UnPhoneDisplay::UnPhoneDisplayDriver::drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) {
bool Hx8357Display::Hx8357Driver::drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) {
lv_area_t area = { xStart, yStart, xEnd, yEnd };
hx8357_flush(nullptr, &area, (uint8_t*)pixelData);
return true;
@@ -7,18 +7,26 @@
#include <esp_lcd_types.h>
#include <lvgl.h>
#include "UnPhoneDisplayConstants.h"
#include <Tactility/hal/spi/Spi.h>
class UnPhoneDisplay : public tt::hal::display::DisplayDevice {
#define UNPHONE_LCD_SPI_HOST SPI2_HOST
#define UNPHONE_LCD_PIN_CS GPIO_NUM_48
#define UNPHONE_LCD_PIN_DC GPIO_NUM_47
#define UNPHONE_LCD_PIN_RESET GPIO_NUM_46
#define UNPHONE_LCD_SPI_FREQUENCY 27000000
#define UNPHONE_LCD_HORIZONTAL_RESOLUTION 320
#define UNPHONE_LCD_VERTICAL_RESOLUTION 480
#define UNPHONE_LCD_DRAW_BUFFER_HEIGHT (UNPHONE_LCD_VERTICAL_RESOLUTION / 15)
#define UNPHONE_LCD_SPI_TRANSFER_HEIGHT (UNPHONE_LCD_VERTICAL_RESOLUTION / 15)
class Hx8357Display : public tt::hal::display::DisplayDevice {
uint8_t* _Nullable buffer = nullptr;
lv_display_t* _Nullable lvglDisplay = nullptr;
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable touchDevice;
std::shared_ptr<tt::hal::display::DisplayDriver> _Nullable nativeDisplay;
class UnPhoneDisplayDriver : public tt::hal::display::DisplayDriver {
class Hx8357Driver : public tt::hal::display::DisplayDriver {
std::shared_ptr<tt::Lock> lock = tt::hal::spi::getLock(SPI2_HOST);
public:
tt::hal::display::ColorFormat getColorFormat() const override { return tt::hal::display::ColorFormat::RGB888; }
@@ -52,7 +60,7 @@ public:
std::shared_ptr<tt::hal::display::DisplayDriver> _Nullable getDisplayDriver() override {
if (nativeDisplay == nullptr) {
nativeDisplay = std::make_shared<UnPhoneDisplayDriver>();
nativeDisplay = std::make_shared<Hx8357Driver>();
}
assert(nativeDisplay != nullptr);
return nativeDisplay;
@@ -1,10 +1,8 @@
#include "UnPhoneSdCard.h"
#include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
#define UNPHONE_SDCARD_PIN_CS GPIO_NUM_43
#define UNPHONE_LCD_PIN_CS GPIO_NUM_48
#define UNPHONE_LORA_PIN_CS GPIO_NUM_44
@@ -12,7 +10,7 @@
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createUnPhoneSdCard() {
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
UNPHONE_SDCARD_PIN_CS,
GPIO_NUM_NC,
@@ -4,4 +4,4 @@
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createUnPhoneSdCard();
std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,11 +1,10 @@
#include "UnPhoneTouch.h"
#include "UnPhoneDisplayConstants.h"
#include "Touch.h"
#include <Tactility/Log.h>
std::shared_ptr<Xpt2046Touch> createTouch() {
auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
UNPHONE_LCD_SPI_HOST,
SPI2_HOST,
GPIO_NUM_38,
320,
480
@@ -1,11 +0,0 @@
#pragma once
#define UNPHONE_LCD_SPI_HOST SPI2_HOST
#define UNPHONE_LCD_PIN_CS GPIO_NUM_48
#define UNPHONE_LCD_PIN_DC GPIO_NUM_47
#define UNPHONE_LCD_PIN_RESET GPIO_NUM_46
#define UNPHONE_LCD_SPI_FREQUENCY 27000000
#define UNPHONE_LCD_HORIZONTAL_RESOLUTION 320
#define UNPHONE_LCD_VERTICAL_RESOLUTION 480
#define UNPHONE_LCD_DRAW_BUFFER_HEIGHT (UNPHONE_LCD_VERTICAL_RESOLUTION / 15)
#define UNPHONE_LCD_SPI_TRANSFER_HEIGHT (UNPHONE_LCD_VERTICAL_RESOLUTION / 15)