mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Update CYD-E32R28T and fixed some minor issues (#319)
This commit is contained in:
parent
c0ed8f0a44
commit
65335578a4
@ -1,22 +1,25 @@
|
||||
#include "E32R28T.h"
|
||||
#include "hal/YellowSdCard.h"
|
||||
#include "hal/YellowDisplay.h"
|
||||
#include "hal/YellowDisplayConstants.h"
|
||||
#include "devices/SdCard.h"
|
||||
#include "devices/Display.h"
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/app/App.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
#define CYD_SPI_TRANSFER_SIZE_LIMIT (240 * 320 / 4 * 2)
|
||||
|
||||
bool initBoot() {
|
||||
static bool initBoot() {
|
||||
return driver::pwmbacklight::init(CYD_BACKLIGHT_PIN);
|
||||
}
|
||||
|
||||
static tt::hal::DeviceVector createDevices() {
|
||||
return {
|
||||
createDisplay(),
|
||||
createSdCard()
|
||||
};
|
||||
}
|
||||
|
||||
const tt::hal::Configuration cyd_e32r28t_config = {
|
||||
.initBoot = initBoot,
|
||||
.createDisplay = createDisplay,
|
||||
.sdcard = createYellowSdCard(),
|
||||
.power = nullptr,
|
||||
.createDevices = createDevices,
|
||||
.i2c = {},
|
||||
.spi = {
|
||||
tt::hal::spi::Configuration {
|
||||
|
||||
41
Boards/CYD-E32R28T/Source/devices/Display.cpp
Normal file
41
Boards/CYD-E32R28T/Source/devices/Display.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "Display.h"
|
||||
|
||||
#include <Xpt2046SoftSpi.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/hal/touch/TouchDevice.h>
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
auto config = std::make_unique<Xpt2046SoftSpi::Configuration>(
|
||||
CYD_TOUCH_MOSI_PIN,
|
||||
CYD_TOUCH_MISO_PIN,
|
||||
CYD_TOUCH_SCK_PIN,
|
||||
CYD_TOUCH_CS_PIN,
|
||||
CYD_DISPLAY_HORIZONTAL_RESOLUTION,
|
||||
CYD_DISPLAY_VERTICAL_RESOLUTION,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
return std::make_shared<Xpt2046SoftSpi>(std::move(config));
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
CYD_DISPLAY_SPI_HOST,
|
||||
CYD_DISPLAY_PIN_CS,
|
||||
CYD_DISPLAY_PIN_DC,
|
||||
CYD_DISPLAY_HORIZONTAL_RESOLUTION,
|
||||
CYD_DISPLAY_VERTICAL_RESOLUTION,
|
||||
createTouch(),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
LCD_RGB_ELEMENT_ORDER_BGR
|
||||
);
|
||||
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||
return std::make_shared<Ili934xDisplay>(std::move(configuration));
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <memory>
|
||||
|
||||
// Display
|
||||
#define CYD_DISPLAY_SPI_HOST SPI2_HOST
|
||||
#define CYD_DISPLAY_PIN_CS GPIO_NUM_15
|
||||
@ -16,10 +19,7 @@
|
||||
#define CYD_TOUCH_CS_PIN GPIO_NUM_33
|
||||
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
|
||||
|
||||
// SD Card
|
||||
#define CYD_SDCARD_SPI_HOST SPI3_HOST
|
||||
#define CYD_SDCARD_PIN_CS GPIO_NUM_5
|
||||
|
||||
|
||||
// Backlight
|
||||
#define CYD_BACKLIGHT_PIN GPIO_NUM_21
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
21
Boards/CYD-E32R28T/Source/devices/SdCard.cpp
Normal file
21
Boards/CYD-E32R28T/Source/devices/SdCard.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "SdCard.h"
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
|
||||
GPIO_NUM_5,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::Mutex>(),
|
||||
std::vector<gpio_num_t>(),
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
);
|
||||
}
|
||||
7
Boards/CYD-E32R28T/Source/devices/SdCard.h
Normal file
7
Boards/CYD-E32R28T/Source/devices/SdCard.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
@ -1,58 +0,0 @@
|
||||
#include "YellowDisplay.h"
|
||||
#include "YellowDisplayConstants.h"
|
||||
#include "Xpt2046SoftSpi.h"
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/hal/touch/TouchDevice.h>
|
||||
#include <esp_log.h>
|
||||
#include <string>
|
||||
|
||||
static const char* TAG = "YellowDisplay";
|
||||
|
||||
// Global to hold reference (only needed if calling stop() later)
|
||||
static std::unique_ptr<Xpt2046SoftSpi> touch;
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
ESP_LOGI(TAG, "Creating bitbang SPI touch");
|
||||
|
||||
// Create bitbang config object
|
||||
auto config = std::make_unique<Xpt2046SoftSpi::Configuration>(
|
||||
CYD_TOUCH_MOSI_PIN,
|
||||
CYD_TOUCH_MISO_PIN,
|
||||
CYD_TOUCH_SCK_PIN,
|
||||
CYD_TOUCH_CS_PIN,
|
||||
CYD_DISPLAY_HORIZONTAL_RESOLUTION, // 240
|
||||
CYD_DISPLAY_VERTICAL_RESOLUTION, // 320
|
||||
false, // swapXY
|
||||
true, // mirrorX
|
||||
false // mirrorY
|
||||
);
|
||||
|
||||
// Allocate the driver
|
||||
touch = std::make_unique<Xpt2046SoftSpi>(std::move(config));
|
||||
|
||||
// Start the driver
|
||||
if (!touch->start()) {
|
||||
ESP_LOGE(TAG, "Touch driver start failed");
|
||||
}
|
||||
|
||||
return std::shared_ptr<tt::hal::touch::TouchDevice>(touch.get(), [](tt::hal::touch::TouchDevice*) {
|
||||
// No delete needed; `touch` is managed above
|
||||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch_device = createTouch();
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
CYD_DISPLAY_SPI_HOST,
|
||||
CYD_DISPLAY_PIN_CS,
|
||||
CYD_DISPLAY_PIN_DC,
|
||||
CYD_DISPLAY_HORIZONTAL_RESOLUTION,
|
||||
CYD_DISPLAY_VERTICAL_RESOLUTION,
|
||||
touch_device
|
||||
);
|
||||
configuration->mirrorX = true;
|
||||
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||
configuration->rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR;
|
||||
return std::make_shared<Ili934xDisplay>(std::move(configuration));
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@ -1,22 +0,0 @@
|
||||
#include "YellowSdCard.h"
|
||||
#include "YellowDisplayConstants.h"
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
CYD_SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC, // No card detect pin specified
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::Mutex>(),
|
||||
std::vector<gpio_num_t>(),
|
||||
CYD_SDCARD_SPI_HOST
|
||||
);
|
||||
|
||||
return std::shared_ptr<SdCardDevice>(
|
||||
new SpiSdCardDevice(std::unique_ptr<SpiSdCardDevice::Config>(configuration))
|
||||
);
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard();
|
||||
Loading…
x
Reference in New Issue
Block a user