Skip to content

Commit a212682

Browse files
committed
feat: Add M5Stack PaperS3 support
1 parent 8115ca4 commit a212682

File tree

21 files changed

+1242
-0
lines changed

21 files changed

+1242
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "Libraries/cJSON/cJSON"]
1717
path = Libraries/cJSON/cJSON
1818
url = https://github.com/DaveGamble/cJSON.git
19+
[submodule "Libraries/epdiy"]
20+
path = Libraries/epdiy
21+
url = https://github.com/fonix232/epdiy
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
2+
3+
idf_component_register(
4+
SRCS ${SOURCE_FILES}
5+
INCLUDE_DIRS "Source"
6+
REQUIRES Tactility esp_lvgl_port EPDiyDisplay GT911 driver esp_adc EstimatedPower vfs fatfs
7+
)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <vector>
2+
#include <memory>
3+
#include <Tactility/hal/Configuration.h>
4+
#include <Tactility/lvgl/LvglSync.h>
5+
6+
#include "devices/Display.hpp"
7+
#include "devices/Power.hpp"
8+
#include "devices/SdCard.hpp"
9+
10+
bool initBoot();
11+
12+
using namespace tt::hal;
13+
14+
static std::vector<std::shared_ptr<Device>> createDevices() {
15+
return {
16+
createPower(),
17+
createDisplay(),
18+
createSdCard()
19+
};
20+
}
21+
22+
extern const Configuration hardwareConfiguration = {
23+
.initBoot = initBoot,
24+
.createDevices = createDevices,
25+
.i2c = {
26+
i2c::Configuration {
27+
.name = "Internal",
28+
.port = I2C_NUM_0,
29+
.initMode = i2c::InitMode::ByTactility,
30+
.isMutable = false,
31+
.config = (i2c_config_t) {
32+
.mode = I2C_MODE_MASTER,
33+
.sda_io_num = GPIO_NUM_41,
34+
.scl_io_num = GPIO_NUM_42,
35+
.sda_pullup_en = true,
36+
.scl_pullup_en = true,
37+
.master = {
38+
.clk_speed = 400000
39+
},
40+
.clk_flags = 0
41+
}
42+
},
43+
i2c::Configuration {
44+
.name = "External",
45+
.port = I2C_NUM_1,
46+
.initMode = i2c::InitMode::Disabled,
47+
.isMutable = true,
48+
.config = (i2c_config_t) {
49+
.mode = I2C_MODE_MASTER,
50+
.sda_io_num = GPIO_NUM_2,
51+
.scl_io_num = GPIO_NUM_1,
52+
.sda_pullup_en = false,
53+
.scl_pullup_en = false,
54+
.master = {
55+
.clk_speed = 400000
56+
},
57+
.clk_flags = 0
58+
}
59+
}
60+
},
61+
.spi {
62+
spi::Configuration {
63+
.device = SPI2_HOST,
64+
.dma = SPI_DMA_CH_AUTO,
65+
.config = {
66+
.mosi_io_num = GPIO_NUM_38,
67+
.miso_io_num = GPIO_NUM_40,
68+
.sclk_io_num = GPIO_NUM_39,
69+
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
70+
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
71+
.data4_io_num = GPIO_NUM_NC,
72+
.data5_io_num = GPIO_NUM_NC,
73+
.data6_io_num = GPIO_NUM_NC,
74+
.data7_io_num = GPIO_NUM_NC,
75+
.data_io_default_level = false,
76+
.max_transfer_sz = 0,
77+
.flags = 0,
78+
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
79+
.intr_flags = 0
80+
},
81+
.initMode = spi::InitMode::ByTactility,
82+
.isMutable = false,
83+
.lock = nullptr
84+
}
85+
},
86+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "Tactility/kernel/SystemEvents.h"
2+
3+
#include <Tactility/TactilityCore.h>
4+
5+
#define TAG "papers3"
6+
7+
static bool powerOn() {
8+
// No power on sequence needed for M5Stack PaperS3
9+
return true;
10+
}
11+
12+
bool initBoot() {
13+
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
14+
if (!powerOn()) {
15+
TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
16+
return false;
17+
}
18+
19+
return true;
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "Display.hpp"
2+
3+
#include <Gt911Touch.h>
4+
#include <EpdiyDisplayHelper.h>
5+
6+
7+
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
8+
// Note for future changes: Interrupt pin is 48, reset is NC
9+
auto configuration = std::make_unique<Gt911Touch::Configuration>(
10+
I2C_NUM_0,
11+
PAPERS3_EPD_HORIZONTAL_RESOLUTION,// yMax - PaperS3 is rotated
12+
PAPERS3_EPD_VERTICAL_RESOLUTION, // xMax - PaperS3 is rotated
13+
true, // swapXY
14+
true, // mirrorX
15+
false, // mirrorY
16+
GPIO_NUM_NC,
17+
GPIO_NUM_48
18+
);
19+
20+
return std::make_shared<Gt911Touch>(std::move(configuration));
21+
}
22+
23+
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
24+
auto touch = createTouch();
25+
return EpdiyDisplayHelper::createM5PaperS3Display(touch);
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include <memory>
4+
#include <Tactility/hal/display/DisplayDevice.h>
5+
#include <Tactility/hal/touch/TouchDevice.h>
6+
7+
// Display
8+
#define PAPERS3_EPD_HORIZONTAL_RESOLUTION 540
9+
#define PAPERS3_EPD_VERTICAL_RESOLUTION 960
10+
11+
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

0 commit comments

Comments
 (0)