Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "Libraries/cJSON/cJSON"]
path = Libraries/cJSON/cJSON
url = https://github.com/DaveGamble/cJSON.git
[submodule "Libraries/epdiy"]
path = Libraries/epdiy
url = https://github.com/fonix232/epdiy
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
"TactilityCore"
"Libraries/esp_lvgl_port"
"Libraries/elf_loader"
"Libraries/epdiy"
"Libraries/lvgl"
"Libraries/lv_screenshot"
"Libraries/minitar"
Expand Down
7 changes: 7 additions & 0 deletions Devices/m5stack-papers3/CMakeLists.txt
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
)
111 changes: 111 additions & 0 deletions Devices/m5stack-papers3/Source/Configuration.cpp
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"

bool initBoot();

using namespace tt::hal;

static std::vector<std::shared_ptr<Device>> createDevices() {
return {
createPower(),
createDisplay(),
createSdCard()
};
}

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,
.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,
}
}
}
}
};
20 changes: 20 additions & 0 deletions Devices/m5stack-papers3/Source/Init.cpp
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;
}
26 changes: 26 additions & 0 deletions Devices/m5stack-papers3/Source/devices/Display.cpp
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
Copy link

@coderabbitai coderabbitai bot Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify 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 -30

Length of output: 2473


🏁 Script executed:

#!/bin/bash
# Find Gt911Touch header file and show complete constructor
fd -i 'gt911|gt.*911' --type f | head -20

Length 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.h

Length 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=h

Length 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
In Boards/m5stack-papers3/Source/devices/Display.cpp around lines 9-18, the
GT911 constructor is passed display dimensions and swapXY in a conflicting way
(comments imply rotated dimensions but swapXY is true). Decide the intended
orientation and fix the params: if the display is meant to be rotated, swap the
resolution arguments (use VERTICAL for yMax and HORIZONTAL for xMax) and set
swapXY=false; if not rotated, keep the current argument order and set
swapXY=false so the axis mapping is consistent.

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link

Choose a reason for hiding this comment

The 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
Learnt from: fonix232
PR: ByteWelder/Tactility#380
File: Boards/m5stack-papers3/Source/devices/Display.cpp:9-18
Timestamp: 2025-10-29T14:45:02.882Z
Learning: For M5Stack PaperS3 in Boards/m5stack-papers3/Source/devices/Display.cpp, the GT911 touch configuration must use PAPERS3_EPD_HORIZONTAL_RESOLUTION (960) as yMax, PAPERS3_EPD_VERTICAL_RESOLUTION (540) as xMax, with swapXY=true and mirrorX=true. Alternative configurations (swapping the resolution parameters or setting swapXY=false) result in badly resolved touch positions. This specific configuration is empirically verified to work correctly.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fonix232

The suggested edits result in badly resolved touch positions. This is the only correct configuration that actually works.

I'm pretty confident this is solveable and that coderabbitai is correct in this scenario. The Gt911Touch::Configuration has properties for swapXY, mirrorX and mirrorY.

So setting swapXY to false and mirrorX to false for the display should work when you also adjust the touch driver configuration.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Author

Choose a reason for hiding this comment

The 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);
}
11 changes: 11 additions & 0 deletions Devices/m5stack-papers3/Source/devices/Display.hpp
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();
Loading