Rename Boards/ to Devices/ (#414)
This commit is contained in:
committed by
GitHub
parent
c7c9618f48
commit
c1ff024657
@@ -0,0 +1,40 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/Power.h"
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <ButtonControl.h>
|
||||
|
||||
bool initBoot();
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
static std::vector<std::shared_ptr<Device>> createDevices() {
|
||||
return {
|
||||
createPower(),
|
||||
createDisplay(),
|
||||
ButtonControl::createTwoButtonControl(0, 14),
|
||||
};
|
||||
}
|
||||
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.createDevices = createDevices,
|
||||
.i2c = {},
|
||||
.spi {
|
||||
spi::Configuration {
|
||||
.device = SPI2_HOST,
|
||||
.dma = SPI_DMA_CH_AUTO,
|
||||
.config = {
|
||||
.mosi_io_num = GPIO_NUM_7,
|
||||
.miso_io_num = GPIO_NUM_NC,
|
||||
.sclk_io_num = GPIO_NUM_6,
|
||||
.max_transfer_sz = DISPLAY_HORIZONTAL_RESOLUTION * DISPLAY_VERTICAL_RESOLUTION * 2,
|
||||
.flags = 0
|
||||
},
|
||||
.initMode = spi::InitMode::ByTactility,
|
||||
.isMutable = false,
|
||||
.lock = tt::lvgl::getSyncLock()
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "devices/Power.h"
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include "PwmBacklight.h"
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
|
||||
#define TAG "tdisplay-s3"
|
||||
|
||||
// Power on
|
||||
|
||||
|
||||
static bool powerOn() {
|
||||
gpio_config_t power_signal_config = {
|
||||
.pin_bit_mask = BIT64(TDISPLAY_S3_POWERON_GPIO),
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.intr_type = GPIO_INTR_DISABLE,
|
||||
};
|
||||
|
||||
if (gpio_config(&power_signal_config) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_level(TDISPLAY_S3_POWERON_GPIO, 1) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initBoot() {
|
||||
ESP_LOGI(TAG, "Powering on the board...");
|
||||
if (!powerOn()) {
|
||||
ESP_LOGE(TAG, "Failed to power on the board.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) {
|
||||
ESP_LOGE(TAG, "Failed to initialize backlight.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "Display.h"
|
||||
|
||||
#include "St7789i8080Display.h"
|
||||
#include "PwmBacklight.h"
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
// Create configuration
|
||||
auto config = St7789i8080Display::Configuration(
|
||||
DISPLAY_CS, // CS
|
||||
DISPLAY_DC, // DC
|
||||
DISPLAY_WR, // WR
|
||||
DISPLAY_RD, // RD
|
||||
{ DISPLAY_I80_D0, DISPLAY_I80_D1, DISPLAY_I80_D2, DISPLAY_I80_D3,
|
||||
DISPLAY_I80_D4, DISPLAY_I80_D5, DISPLAY_I80_D6, DISPLAY_I80_D7 }, // D0..D7
|
||||
DISPLAY_RST, // RST
|
||||
DISPLAY_BL // BL
|
||||
);
|
||||
|
||||
// Set resolution explicitly
|
||||
config.horizontalResolution = DISPLAY_HORIZONTAL_RESOLUTION;
|
||||
config.verticalResolution = DISPLAY_VERTICAL_RESOLUTION;
|
||||
config.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||
|
||||
// Adjust other settings as needed
|
||||
config.gapX = 35; // ST7789 has a 35 pixel gap on X axis
|
||||
config.pixelClockFrequency = 10 * 1000 * 1000; // 10MHz for better stability
|
||||
|
||||
auto display = std::make_shared<St7789i8080Display>(config);
|
||||
return display;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <driver/gpio.h>
|
||||
|
||||
class St7789i8080Display;
|
||||
|
||||
constexpr auto DISPLAY_CS = GPIO_NUM_6;
|
||||
constexpr auto DISPLAY_DC = GPIO_NUM_7;
|
||||
constexpr auto DISPLAY_WR = GPIO_NUM_8;
|
||||
constexpr auto DISPLAY_RD = GPIO_NUM_9;
|
||||
constexpr auto DISPLAY_RST = GPIO_NUM_5;
|
||||
constexpr auto DISPLAY_BL = GPIO_NUM_38;
|
||||
constexpr auto DISPLAY_I80_D0 = GPIO_NUM_39;
|
||||
constexpr auto DISPLAY_I80_D1 = GPIO_NUM_40;
|
||||
constexpr auto DISPLAY_I80_D2 = GPIO_NUM_41;
|
||||
constexpr auto DISPLAY_I80_D3 = GPIO_NUM_42;
|
||||
constexpr auto DISPLAY_I80_D4 = GPIO_NUM_45;
|
||||
constexpr auto DISPLAY_I80_D5 = GPIO_NUM_46;
|
||||
constexpr auto DISPLAY_I80_D6 = GPIO_NUM_47;
|
||||
constexpr auto DISPLAY_I80_D7 = GPIO_NUM_48;
|
||||
constexpr auto DISPLAY_HORIZONTAL_RESOLUTION = 170;
|
||||
constexpr auto DISPLAY_VERTICAL_RESOLUTION = 320;
|
||||
|
||||
// Factory function for registration
|
||||
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,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <driver/gpio.h>
|
||||
|
||||
constexpr auto TDISPLAY_S3_POWERON_GPIO = GPIO_NUM_15;
|
||||
|
||||
std::shared_ptr<tt::hal::power::PowerDevice> createPower();
|
||||
Reference in New Issue
Block a user