-
-
Notifications
You must be signed in to change notification settings - Fork 81
Add initial support for LilyGO T-HMI S3 with device configuration and⦠#509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Revers-BR
wants to merge
6
commits into
TactilityProject:main
Choose a base branch
from
Revers-BR:lilygo_thmi_s3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+283
β0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4e8cb29
Add initial support for LilyGO T-HMI S3 with device configuration andβ¦
Revers-BR 83a9e75
Update Devices/lilygo-thmi-s3/Source/devices/Power.h
Revers-BR fbc17fa
Fix GPIO pin configuration for power control and update button controβ¦
Revers-BR 35532be
Fix GPIO pin references for power control in initBoot function
Revers-BR 2ffd7f1
Replace two-button control with one-button control in device creation
Revers-BR 87276fe
Refactor SD card configuration to include bus width and remove unneceβ¦
Revers-BR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| file(GLOB_RECURSE SOURCE_FILES Source/*.c*) | ||
|
|
||
| idf_component_register( | ||
| SRCS ${SOURCE_FILES} | ||
| INCLUDE_DIRS "Source" | ||
| REQUIRES Tactility ButtonControl XPT2046SoftSPI PwmBacklight EstimatedPower ST7789-i8080 driver vfs fatfs | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "devices/Power.h" | ||
| #include "devices/SdCard.h" | ||
| #include "devices/Display.h" | ||
|
|
||
| #include <ButtonControl.h> | ||
| #include <Tactility/hal/Configuration.h> | ||
|
|
||
| bool initBoot(); | ||
|
|
||
| using namespace tt::hal; | ||
|
|
||
| static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() { | ||
| return { | ||
| createPower(), | ||
| createSdCard(), | ||
| createDisplay(), | ||
| ButtonControl::createOneButtonControl(0) | ||
| }; | ||
| } | ||
|
|
||
| extern const Configuration hardwareConfiguration = { | ||
| .initBoot = initBoot, | ||
| .createDevices = createDevices | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #include "devices/Power.h" | ||
| #include "devices/Display.h" | ||
|
|
||
| #include "PwmBacklight.h" | ||
| #include "Tactility/kernel/SystemEvents.h" | ||
| #include <Tactility/TactilityCore.h> | ||
|
|
||
| #define TAG "thmi-s3" | ||
|
|
||
| static bool powerOn() { | ||
| gpio_config_t power_signal_config = { | ||
| .pin_bit_mask = (1ULL << THMI_S3_POWERON_GPIO) | (1ULL << THMI_S3_POWEREN_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(THMI_S3_POWERON_GPIO, 1) != ESP_OK) { | ||
| return false; | ||
| } | ||
|
|
||
| if (gpio_set_level(THMI_S3_POWEREN_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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include <Xpt2046SoftSpi.h> | ||
| #include <Tactility/hal/touch/TouchDevice.h> | ||
|
|
||
| #include "Display.h" | ||
| #include "PwmBacklight.h" | ||
| #include "St7789i8080Display.h" | ||
|
|
||
| static bool touchSpiInitialized = false; | ||
|
|
||
| static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { | ||
| auto config = std::make_unique<Xpt2046SoftSpi::Configuration>( | ||
| TOUCH_MOSI_PIN, | ||
| TOUCH_MISO_PIN, | ||
| TOUCH_SCK_PIN, | ||
| TOUCH_CS_PIN, | ||
| DISPLAY_HORIZONTAL_RESOLUTION, | ||
| DISPLAY_VERTICAL_RESOLUTION | ||
| ); | ||
|
|
||
| return std::make_shared<Xpt2046SoftSpi>(std::move(config)); | ||
| } | ||
|
|
||
| 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; | ||
| config.touch = createTouch(); | ||
| config.invertColor = false; | ||
|
|
||
| auto display = std::make_shared<St7789i8080Display>(config); | ||
| return display; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #pragma once | ||
| #include <driver/gpio.h> | ||
| #include <Tactility/hal/display/DisplayDevice.h> | ||
|
|
||
| #include "driver/spi_common.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_NC; | ||
| constexpr auto DISPLAY_RST = GPIO_NUM_NC; | ||
| constexpr auto DISPLAY_BL = GPIO_NUM_38; | ||
| constexpr auto DISPLAY_I80_D0 = GPIO_NUM_48; | ||
| constexpr auto DISPLAY_I80_D1 = GPIO_NUM_47; | ||
| constexpr auto DISPLAY_I80_D2 = GPIO_NUM_39; | ||
| constexpr auto DISPLAY_I80_D3 = GPIO_NUM_40; | ||
| constexpr auto DISPLAY_I80_D4 = GPIO_NUM_41; | ||
| constexpr auto DISPLAY_I80_D5 = GPIO_NUM_42; | ||
| constexpr auto DISPLAY_I80_D6 = GPIO_NUM_45; | ||
| constexpr auto DISPLAY_I80_D7 = GPIO_NUM_46; | ||
| constexpr auto DISPLAY_HORIZONTAL_RESOLUTION = 240; | ||
| constexpr auto DISPLAY_VERTICAL_RESOLUTION = 320; | ||
|
|
||
| // Touch (XPT2046, resistive, shared SPI with display) | ||
| constexpr auto TOUCH_MISO_PIN = GPIO_NUM_4; | ||
| constexpr auto TOUCH_MOSI_PIN = GPIO_NUM_3; | ||
| constexpr auto TOUCH_SCK_PIN = GPIO_NUM_1; | ||
| constexpr auto TOUCH_CS_PIN = GPIO_NUM_2; | ||
| constexpr auto TOUCH_IRQ_PIN = GPIO_NUM_9; | ||
|
|
||
| // Factory function for registration | ||
| std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <Tactility/hal/power/PowerDevice.h> | ||
| #include <driver/gpio.h> | ||
|
|
||
| constexpr auto THMI_S3_POWEREN_GPIO = GPIO_NUM_10; | ||
| constexpr auto THMI_S3_POWERON_GPIO = GPIO_NUM_14; | ||
|
|
||
| std::shared_ptr<tt::hal::power::PowerDevice> createPower(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "SdCard.h" | ||
|
|
||
| #include <Tactility/lvgl/LvglSync.h> | ||
| #include <Tactility/hal/sdcard/SdmmcDevice.h> | ||
|
|
||
| using tt::hal::sdcard::SdmmcDevice; | ||
|
|
||
| std::shared_ptr<SdCardDevice> createSdCard() { | ||
| auto configuration = std::make_unique<SdmmcDevice::Config>( | ||
| SD_DIO_SCLK, //CLK | ||
| SD_DIO_CMD, //CMD | ||
| SD_DIO_DATA0, //D0 | ||
| SD_DIO_NC, //D1 | ||
| SD_DIO_NC, //D2 | ||
| SD_DIO_NC, //D3 | ||
| SdCardDevice::MountBehaviour::AtBoot, | ||
| SD_DIO_BUS_WIDTH | ||
| ); | ||
|
|
||
| return std::make_shared<SdmmcDevice>( | ||
| std::move(configuration) | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| #include <driver/gpio.h> | ||
|
|
||
| #include "Tactility/hal/sdcard/SdCardDevice.h" | ||
|
|
||
| using tt::hal::sdcard::SdCardDevice; | ||
|
|
||
| constexpr auto SD_DIO_CMD = GPIO_NUM_11; | ||
| constexpr auto SD_DIO_SCLK = GPIO_NUM_12; | ||
| constexpr auto SD_DIO_DATA0 = GPIO_NUM_13; | ||
| constexpr auto SD_DIO_NC = GPIO_NUM_NC; | ||
| constexpr auto SD_DIO_BUS_WIDTH = 1; | ||
|
|
||
| std::shared_ptr<SdCardDevice> createSdCard(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include <tactility/module.h> | ||
|
|
||
| extern "C" { | ||
|
|
||
| static error_t start() { | ||
| // Empty for now | ||
| return ERROR_NONE; | ||
| } | ||
|
|
||
| static error_t stop() { | ||
| // Empty for now | ||
| return ERROR_NONE; | ||
| } | ||
|
|
||
| /** @warning The variable name must be exactly "device_module" */ | ||
| struct Module device_module = { | ||
| .name = "lilygo-thmi-s3", | ||
| .start = start, | ||
| .stop = stop, | ||
| .symbols = nullptr, | ||
| .internal = nullptr | ||
| }; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [general] | ||
| vendor=LilyGO | ||
| name=T-HMI S3 | ||
|
|
||
| [apps] | ||
| launcherAppId=Launcher | ||
|
|
||
| [hardware] | ||
| target=ESP32S3 | ||
| flashSize=16MB | ||
| spiRam=true | ||
| spiRamMode=OCT | ||
| spiRamSpeed=120M | ||
| tinyUsb=true | ||
| esptoolFlashFreq=120M | ||
|
|
||
| [display] | ||
| size=2.8" | ||
| shape=rectangle | ||
| dpi=125 | ||
|
|
||
| [lvgl] | ||
| colorDepth=16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| dependencies: | ||
| - Platforms/platform-esp32 | ||
| dts: lilygo,thmi-s3.dts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /dts-v1/; | ||
|
|
||
| #include <tactility/bindings/root.h> | ||
| #include <tactility/bindings/esp32_gpio.h> | ||
| #include <tactility/bindings/esp32_i2c.h> | ||
| #include <tactility/bindings/esp32_spi.h> | ||
|
|
||
| / { | ||
| compatible = "root"; | ||
| model = "LilyGO T-HMI S3"; | ||
|
|
||
| gpio0 { | ||
| compatible = "espressif,esp32-gpio"; | ||
| gpio-count = <49>; | ||
| }; | ||
| }; |
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.