Skip to content

Commit 032b75e

Browse files
author
Greg Smith
committed
Fixed a few more issues with the Lilygo T-Display S3 touch screen with CST328 chip.
1 parent 16e44c4 commit 032b75e

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

build_distrib/build_distrib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
dirname = Path.cwd()
1010

1111
# set version
12-
version = '2.0.0.2_beta_3'
12+
version = '2.0.0.2_beta_4'
1313

1414
def delete_files_in_folder(directory):
1515
for filename in os.listdir(directory):

source/components/esp_lcd_touch_cst328/include/esp_lcd_touch_cst328.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ esp_err_t esp_lcd_touch_new_i2c_CST328(const esp_lcd_panel_io_handle_t io, const
4949
.user_ctx = 0, \
5050
.control_phase_bytes = 1, \
5151
.dc_bit_offset = 0, \
52-
.lcd_cmd_bits = 8, \
52+
.lcd_cmd_bits = 16, \
5353
.lcd_param_bits = 0, \
5454
.flags = \
5555
{ \
@@ -65,7 +65,7 @@ esp_err_t esp_lcd_touch_new_i2c_CST328(const esp_lcd_panel_io_handle_t io, const
6565
.user_ctx = 0, \
6666
.control_phase_bytes = 1, \
6767
.dc_bit_offset = 0, \
68-
.lcd_cmd_bits = 8, \
68+
.lcd_cmd_bits = 16, \
6969
.lcd_param_bits = 0, \
7070
.flags = \
7171
{ \

source/main/platform_lgtdisps3.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,21 @@ static const char *TAG = "platform Lilygo T-Display S3";
8181
#define LILYGO_TDISPLAY_S3_LCD_V_RES (170)
8282
#define LILYGO_TDISPLAY_S3_LCD_PIXEL_CLOCK_HZ (10 * 1000 * 1000)
8383

84+
enum TouchChips
85+
{
86+
UNKNOWN,
87+
CST8165S,
88+
CST328
89+
};
90+
8491
static lv_disp_draw_buf_t disp_buf;
8592
static lv_disp_drv_t* disp_drv;
8693
static esp_lcd_panel_io_handle_t lcd_io = NULL;
8794
static esp_lcd_panel_handle_t lcd_panel = NULL;
8895
static esp_lcd_touch_handle_t tp = NULL;
8996
static esp_lcd_panel_io_handle_t tp_io_handle = NULL;
9097
static lv_indev_drv_t indev_drv; // Input device driver (Touch)
98+
static uint8_t touch_chip_type = UNKNOWN;
9199

92100
typedef struct {
93101
uint32_t addr;
@@ -123,8 +131,11 @@ __attribute__((unused)) void platform_adjust_touch_coords(lv_coord_t* x, lv_coor
123131
{
124132
lv_coord_t xpos = *x;
125133

126-
// 1.9 in landscape mode needs the co-ordinates adjusted
127-
*x = LILYGO_TDISPLAY_S3_LCD_H_RES - xpos;
134+
if (touch_chip_type == CST8165S)
135+
{
136+
// CST8165S in landscape mode needs the co-ordinates adjusted
137+
*x = LILYGO_TDISPLAY_S3_LCD_H_RES - xpos;
138+
}
128139

129140
if (*x < 0)
130141
{
@@ -340,11 +351,12 @@ void platform_init(i2c_master_bus_handle_t bus_handle, SemaphoreHandle_t I2CMute
340351
vTaskDelay(pdMS_TO_TICKS(20));
341352
gpio_set_level(TOUCH_RESET, 1);
342353
vTaskDelay(pdMS_TO_TICKS(50));
343-
354+
344355
// some early boards had CST328 touch chip, and later has CST816. They use different I2C addresses,
345356
// so probe for which one is present
346357
if (i2c_master_probe(bus_handle, ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS, 50) == ESP_OK)
347358
{
359+
touch_chip_type = CST8165S;
348360
const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
349361

350362
// Touch IO handle
@@ -378,6 +390,7 @@ void platform_init(i2c_master_bus_handle_t bus_handle, SemaphoreHandle_t I2CMute
378390
}
379391
else if (i2c_master_probe(bus_handle, ESP_LCD_TOUCH_IO_I2C_CST328_ADDRESS, 50) == ESP_OK)
380392
{
393+
touch_chip_type = CST328;
381394
const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST328_CONFIG();
382395

383396
// Touch IO handle

0 commit comments

Comments
 (0)