Rename Boards/ to Devices/ (#414)

This commit is contained in:
Ken Van Hoeylandt
2025-11-13 23:50:43 +01:00
committed by GitHub
parent c7c9618f48
commit c1ff024657
314 changed files with 105 additions and 99 deletions
@@ -0,0 +1,52 @@
#include "Display.h"
#include <Xpt2046Touch.h>
#include <St7789Display.h>
#include <PwmBacklight.h>
#include <Tactility/hal/touch/TouchDevice.h>
// Create the XPT2046 touch device (hardware/esp_lcd driver)
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto config = std::make_unique<Xpt2046Touch::Configuration>(
DISPLAY_SPI_HOST, // spi device / bus (SPI2_HOST)
TOUCH_CS_PIN, // touch CS (IO33)
(uint16_t)DISPLAY_HORIZONTAL_RESOLUTION, // x max
(uint16_t)DISPLAY_VERTICAL_RESOLUTION, // y max
false, // swapXy
true, // mirrorX
true // mirrorY
);
return std::make_shared<Xpt2046Touch>(std::move(config));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
// Create the ST7789 panel configuration
St7789Display::Configuration panel_configuration = {
.horizontalResolution = DISPLAY_HORIZONTAL_RESOLUTION,
.verticalResolution = DISPLAY_VERTICAL_RESOLUTION,
.gapX = 0,
.gapY = 0,
.swapXY = false,
.mirrorX = false,
.mirrorY = false,
.invertColor = false,
.bufferSize = DISPLAY_DRAW_BUFFER_SIZE, // 0 -> default 1/10 screen
.touch = createTouch(),
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
.resetPin = GPIO_NUM_NC,
.lvglSwapBytes = false,
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR // BGR for this display
};
// Create the SPI configuration (from EspLcdSpiDisplay base class)
auto spi_configuration = std::make_shared<EspLcdSpiDisplay::SpiConfiguration>(EspLcdSpiDisplay::SpiConfiguration {
.spiHostDevice = DISPLAY_SPI_HOST,
.csPin = DISPLAY_PIN_CS,
.dcPin = DISPLAY_PIN_DC,
.pixelClockFrequency = 40'000'000,
.transactionQueueDepth = 10
});
return std::make_shared<St7789Display>(panel_configuration, spi_configuration);
}
@@ -0,0 +1,27 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#include "driver/gpio.h"
#include "driver/spi_common.h"
#include <memory>
// Display (ST7789P3 on this board)
constexpr auto DISPLAY_SPI_HOST = SPI2_HOST;
constexpr auto DISPLAY_PIN_CS = GPIO_NUM_15;
constexpr auto DISPLAY_PIN_DC = GPIO_NUM_2;
constexpr auto DISPLAY_HORIZONTAL_RESOLUTION = 240;
constexpr auto DISPLAY_VERTICAL_RESOLUTION = 320;
constexpr auto DISPLAY_DRAW_BUFFER_HEIGHT = (DISPLAY_VERTICAL_RESOLUTION / 10);
constexpr auto DISPLAY_DRAW_BUFFER_SIZE = (DISPLAY_HORIZONTAL_RESOLUTION * DISPLAY_DRAW_BUFFER_HEIGHT);
constexpr auto DISPLAY_BACKLIGHT_PIN = GPIO_NUM_27;
constexpr auto DISPLAY_SPI_TRANSFER_SIZE_LIMIT = DISPLAY_DRAW_BUFFER_SIZE * sizeof(lv_color_t);
// Touch (XPT2046, resistive, shared SPI with display)
constexpr auto TOUCH_MISO_PIN = GPIO_NUM_12;
constexpr auto TOUCH_MOSI_PIN = GPIO_NUM_13;
constexpr auto TOUCH_SCK_PIN = GPIO_NUM_14;
constexpr auto TOUCH_CS_PIN = GPIO_NUM_33;
constexpr auto TOUCH_IRQ_PIN = GPIO_NUM_36;
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -0,0 +1,12 @@
#include "Power.h"
#include <ChargeFromAdcVoltage.h>
#include <EstimatedPower.h>
std::shared_ptr<tt::hal::power::PowerDevice> createPower() {
ChargeFromAdcVoltage::Configuration configuration;
// 2.0 ratio, but +.11 added as display voltage sag compensation.
configuration.adcMultiplier = 2.11;
return std::make_shared<EstimatedPower>(configuration);
}
@@ -0,0 +1,6 @@
#pragma once
#include <memory>
#include <Tactility/hal/power/PowerDevice.h>
std::shared_ptr<tt::hal::power::PowerDevice> createPower();
@@ -0,0 +1,22 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
using SdCardDevice = tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SD_CS_PIN, // CS pin (IO5 on the module)
GPIO_NUM_NC, // MOSI override: leave NC to use SPI host pins
GPIO_NUM_NC, // MISO override: leave NC
GPIO_NUM_NC, // SCLK override: leave NC
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive),
std::vector<gpio_num_t>(),
SD_SPI_HOST // SPI host for SD card (SPI3_HOST)
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}
@@ -0,0 +1,13 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include "driver/gpio.h"
#include "driver/spi_common.h"
using tt::hal::sdcard::SdCardDevice;
// SD card (microSD)
constexpr auto SD_CS_PIN = GPIO_NUM_5;
constexpr auto SD_SPI_HOST = SPI3_HOST;
std::shared_ptr<SdCardDevice> createSdCard();