-
-
Notifications
You must be signed in to change notification settings - Fork 78
feat: Add basic M5Stack PaperS3 support #380
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 esp_lvgl_port EPDiyDisplay GT911 driver esp_adc EstimatedPower vfs fatfs | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| #include <vector> | ||
| #include <memory> | ||
| #include <Tactility/hal/Configuration.h> | ||
| #include <Tactility/lvgl/LvglSync.h> | ||
|
|
||
| #include "devices/Display.hpp" | ||
| #include "devices/Power.hpp" | ||
| #include "devices/SdCard.hpp" | ||
|
|
||
fonix232 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bool initBoot(); | ||
|
|
||
| using namespace tt::hal; | ||
|
|
||
| static std::vector<std::shared_ptr<Device>> createDevices() { | ||
| return { | ||
| createPower(), | ||
| createDisplay(), | ||
| createSdCard() | ||
| }; | ||
| } | ||
fonix232 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| extern const Configuration hardwareConfiguration = { | ||
| .initBoot = initBoot, | ||
| .createDevices = createDevices, | ||
| .i2c = { | ||
| i2c::Configuration { | ||
| .name = "Internal", | ||
| .port = I2C_NUM_0, | ||
| .initMode = i2c::InitMode::ByTactility, | ||
| .isMutable = false, | ||
| .config = (i2c_config_t) { | ||
| .mode = I2C_MODE_MASTER, | ||
| .sda_io_num = GPIO_NUM_41, | ||
| .scl_io_num = GPIO_NUM_42, | ||
| .sda_pullup_en = true, | ||
| .scl_pullup_en = true, | ||
| .master = { | ||
| .clk_speed = 400000 | ||
| }, | ||
| .clk_flags = 0 | ||
| } | ||
| }, | ||
| i2c::Configuration { | ||
| .name = "External", | ||
| .port = I2C_NUM_1, | ||
fonix232 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .initMode = i2c::InitMode::Disabled, | ||
| .isMutable = true, | ||
| .config = (i2c_config_t) { | ||
| .mode = I2C_MODE_MASTER, | ||
| .sda_io_num = GPIO_NUM_2, | ||
| .scl_io_num = GPIO_NUM_1, | ||
| .sda_pullup_en = false, | ||
| .scl_pullup_en = false, | ||
| .master = { | ||
| .clk_speed = 400000 | ||
| }, | ||
| .clk_flags = 0 | ||
| } | ||
| } | ||
| }, | ||
| .spi = { | ||
| spi::Configuration { | ||
| .device = SPI2_HOST, | ||
| .dma = SPI_DMA_CH_AUTO, | ||
| .config = { | ||
| .mosi_io_num = GPIO_NUM_38, | ||
| .miso_io_num = GPIO_NUM_40, | ||
| .sclk_io_num = GPIO_NUM_39, | ||
| .quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported | ||
| .quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported | ||
| .data4_io_num = GPIO_NUM_NC, | ||
| .data5_io_num = GPIO_NUM_NC, | ||
| .data6_io_num = GPIO_NUM_NC, | ||
| .data7_io_num = GPIO_NUM_NC, | ||
| .data_io_default_level = false, | ||
| .max_transfer_sz = 0, | ||
| .flags = 0, | ||
| .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, | ||
| .intr_flags = 0 | ||
| }, | ||
| .initMode = spi::InitMode::ByTactility, | ||
| .isMutable = false, | ||
| .lock = nullptr | ||
| } | ||
| }, | ||
| .uart = { | ||
| uart::Configuration { | ||
| .name = "External", | ||
| .port = UART_NUM_1, | ||
| .rxPin = GPIO_NUM_2, | ||
| .txPin = GPIO_NUM_1, | ||
| .rtsPin = GPIO_NUM_NC, | ||
| .ctsPin = GPIO_NUM_NC, | ||
| .rxBufferSize = 1024, | ||
| .txBufferSize = 1024, | ||
| .config = { | ||
| .baud_rate = 115200, | ||
| .data_bits = UART_DATA_8_BITS, | ||
| .parity = UART_PARITY_DISABLE, | ||
| .stop_bits = UART_STOP_BITS_1, | ||
| .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, | ||
| .rx_flow_ctrl_thresh = 0, | ||
| .source_clk = UART_SCLK_DEFAULT, | ||
| .flags = { | ||
| .allow_pd = 0, | ||
| .backup_before_sleep = 0, | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #include "Tactility/kernel/SystemEvents.h" | ||
|
|
||
| #include <Tactility/TactilityCore.h> | ||
|
|
||
| #define TAG "papers3" | ||
|
|
||
| static bool powerOn() { | ||
| // No power on sequence needed for M5Stack PaperS3 | ||
| return true; | ||
| } | ||
|
|
||
| bool initBoot() { | ||
| ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START); | ||
| if (!powerOn()) { | ||
| TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include "Display.hpp" | ||
|
|
||
| #include <Gt911Touch.h> | ||
| #include <EpdiyDisplayHelper.h> | ||
|
|
||
|
|
||
| static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { | ||
| // Note for future changes: Interrupt pin is 48, reset is NC | ||
| auto configuration = std::make_unique<Gt911Touch::Configuration>( | ||
| I2C_NUM_0, | ||
| PAPERS3_EPD_HORIZONTAL_RESOLUTION,// yMax - PaperS3 is rotated | ||
| PAPERS3_EPD_VERTICAL_RESOLUTION, // xMax - PaperS3 is rotated | ||
| true, // swapXY | ||
| true, // mirrorX | ||
| false, // mirrorY | ||
| GPIO_NUM_NC, | ||
| GPIO_NUM_48 | ||
| ); | ||
|
Comment on lines
+9
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify GT911 configuration parameter order vs. swap/mirror. You set swapXY=true and also pass PAPERS3_EPD_HORIZONTAL_RESOLUTION as the “yMax” argument. If the constructor order is (xMax, yMax, …), this combination could double‑swap or mis‑scale. Please confirm the signature and adjust either the max arguments or swapXY accordingly. Tip: prefer initializing via a named Configuration aggregate (if supported) to avoid positional mistakes. 🏁 Script executed: #!/bin/bash
# Show the Gt911Touch::Configuration fields / ctor signature used here.
fd -a 'Gt911Touch' | xargs -I {} rg -nP -C3 'class\s+Gt911Touch|struct\s+Configuration|Configuration\s*\(' {}Length of output: 265 🏁 Script executed: #!/bin/bash
# Extract the complete Gt911Touch::Configuration constructor definition
rg -nP -A 15 'class\s+Configuration\s*\{' | head -30Length of output: 2473 🏁 Script executed: #!/bin/bash
# Find Gt911Touch header file and show complete constructor
fd -i 'gt911|gt.*911' --type f | head -20Length of output: 69 🏁 Script executed: #!/bin/bash
# Extract complete Gt911Touch::Configuration constructor from header
rg -nP -A 20 'class\s+Configuration' Drivers/GT911/Source/Gt911Touch.hLength of output: 689 🏁 Script executed: #!/bin/bash
# Find PAPERS3_EPD resolution definitions
rg -nP 'PAPERS3_EPD_HORIZONTAL_RESOLUTION|PAPERS3_EPD_VERTICAL_RESOLUTION' --type-add='h:*.h' --type=hLength of output: 193 Fix inconsistent GT911 configuration: conflicting parameter order and swapXy flag. The comments state dimensions are swapped for rotation, yet you pass HORIZONTAL_RESOLUTION as xMax and VERTICAL_RESOLUTION as yMax (unrotated order) while also setting swapXy=true. This creates conflicting swap logic. Either swap the parameter positions (540→yMax, 960→xMax) and set swapXy=false, or keep the current parameter order and set swapXy=false. Clarify the intended display orientation and correct accordingly. 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this. The suggested edits result in badly resolved touch positions. This is the only correct configuration that actually works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fonix232, understood! I'll dismiss this review comment. Empirical testing always trumps theoretical parameter analysis – if this configuration produces correct touch positions and the suggested changes don't, then this is the right setup for the M5Stack PaperS3 hardware. ✏️ Learnings added
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm pretty confident this is solveable and that coderabbitai is correct in this scenario. The So setting swapXY to false and mirrorX to false for the display should work when you also adjust the touch driver configuration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KenVanHoeylandt I have tried every single possible configuration, alas to no avail. Setting them up otherwise, in configurations that should work in theory, offsets the zero point to an offscreen position. |
||
|
|
||
| return std::make_shared<Gt911Touch>(std::move(configuration)); | ||
| } | ||
|
|
||
| std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { | ||
| auto touch = createTouch(); | ||
| return EpdiyDisplayHelper::createM5PaperS3Display(touch); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <Tactility/hal/display/DisplayDevice.h> | ||
| #include <Tactility/hal/touch/TouchDevice.h> | ||
|
|
||
| // Display | ||
| #define PAPERS3_EPD_HORIZONTAL_RESOLUTION 540 | ||
| #define PAPERS3_EPD_VERTICAL_RESOLUTION 960 | ||
|
|
||
| std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); |
Uh oh!
There was an error while loading. Please reload this page.