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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ The functional block diagram is shown below:
| Chipsemicorp | CHSC6540 |
| FocalTech | FT5x06 |
| GOODiX | GT911,GT1151 |
| Hynitron | CST816S,CST820 |
| Hynitron | CST816S,CST820,CST9217 |
| Parade | TT21100 |
| Sitronix | ST7123,ST1633 |
| Solomon Systech | SPD2010 |
Expand Down
1 change: 1 addition & 0 deletions docs/drivers/touch.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| CHSC6540 | - | ✅ | |
| [CST816S](https://components.espressif.com/components/espressif/esp_lcd_touch_cst816s) | 1.0.3~1 | ✅ | |
| CST820 | - | ✅ | |
| CST9217 | 1.0.0 | ✅ | |
| [FT5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06) | 1.0.6~1 | ✅ | |
| [GT911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911) | 1.1.1~1 | ✅ | |
| [GT1151](https://components.espressif.com/components/espressif/esp_lcd_touch_gt1151) | 1.0.5~2 | ✅ | |
Expand Down
3 changes: 1 addition & 2 deletions esp_panel_board_custom_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@
* Supported controllers:
* - `AXS15231B`
* - `CHSC6540`
* - `CST816S`
* - `CST820`
* - `CST816S`, 'CST820', 'CST9217'
* - `FT5x06`
* - `GT911`, `GT1151`
* - `SPD2010`
Expand Down
16 changes: 16 additions & 0 deletions src/drivers/touch/esp_panel_touch_conf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
#define ESP_PANEL_DRIVERS_TOUCH_USE_CST9217 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
#else
#define ESP_PANEL_DRIVERS_TOUCH_USE_CST9217 (0)
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
#define ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
Expand Down Expand Up @@ -243,6 +251,14 @@
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217 (1)
#else
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217 (0)
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_FT5x06
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_FT5x06 (1)
Expand Down
52 changes: 52 additions & 0 deletions src/drivers/touch/esp_panel_touch_cst9217.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "esp_panel_touch_conf_internal.h"
#if ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217

#include "utils/esp_panel_utils_log.h"
#include "esp_panel_touch_cst9217.hpp"

namespace esp_panel::drivers {

TouchCST9217::~TouchCST9217()
{
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

ESP_UTILS_CHECK_FALSE_EXIT(del(), "Delete failed");

ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
}

bool TouchCST9217::begin()
{
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

ESP_UTILS_CHECK_FALSE_RETURN(!isOverState(State::BEGIN), false, "Already begun");

// Initialize the touch if not initialized
if (!isOverState(State::INIT)) {
ESP_UTILS_CHECK_FALSE_RETURN(init(), false, "Init failed");
}

// Create touch panel
ESP_UTILS_CHECK_ERROR_RETURN(
esp_lcd_touch_new_i2c_cst9217(
getBus()->getControlPanelHandle(), getConfig().getDeviceFullConfig(), &touch_panel
), false, "Create touch panel failed"
);
ESP_UTILS_LOGD("Create touch panel(@%p)", touch_panel);

setState(State::BEGIN);

ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();

return true;
}

} // namespace esp_panel::drivers

#endif // ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217
80 changes: 80 additions & 0 deletions src/drivers/touch/esp_panel_touch_cst9217.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include "port/esp_lcd_touch_cst9217.h"
#include "esp_panel_touch_conf_internal.h"
#include "esp_panel_touch.hpp"

namespace esp_panel::drivers {

/**
* @brief CST9217 touch controller
*
* This class provides implementation for CST9217 touch controller, inheriting from
* the base Touch class to provide common touch functionality
*/
class TouchCST9217 : public Touch {
public:
/**
* @brief Default basic attributes for CST9217
*/
static constexpr BasicAttributes BASIC_ATTRIBUTES_DEFAULT = {
.name = "CST9217",
.max_points_num = 1,
};

/**
* @brief Construct a touch device instance with individual configuration parameters
*
* @param bus Bus interface for communicating with the touch device
* @param width Panel width in pixels
* @param height Panel height in pixels
* @param rst_io Reset GPIO pin number (-1 if unused)
* @param int_io Interrupt GPIO pin number (-1 if unused)
*/
TouchCST9217(Bus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1):
Touch(BASIC_ATTRIBUTES_DEFAULT, bus, width, height, rst_io, int_io)
{
}

/**
* @brief Construct a touch device instance with configuration
*
* @param[in] bus Pointer to the bus interface for communicating with the touch device
* @param[in] config Configuration structure containing device settings and parameters
*/
TouchCST9217(Bus *bus, const Config &config): Touch(BASIC_ATTRIBUTES_DEFAULT, bus, config) {}

/**
* @brief Construct a touch device instance with bus configuration and device configuration
*
* @param[in] bus_config Bus configuration
* @param[in] touch_config Touch configuration
* @note This constructor creates a new bus instance using the provided bus configuration
*/
TouchCST9217(const BusFactory::Config &bus_config, const Config &touch_config):
Touch(BASIC_ATTRIBUTES_DEFAULT, bus_config, touch_config)
{
}

/**
* @brief Destruct touch device
*/
~TouchCST9217() override;

/**
* @brief Startup the touch device
*
* @return `true` if success, otherwise false
*
* @note This function should be called after `init()`
*/
bool begin() override;
};

} // namespace esp_panel::drivers
3 changes: 3 additions & 0 deletions src/drivers/touch/esp_panel_touch_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const utils::unordered_map<utils::string, TouchFactory::FunctionCreateDevice> To
#if ESP_PANEL_DRIVERS_TOUCH_USE_CST820
MAP_ITEM(CST820),
#endif // CONFIG_ESP_PANEL_TOUCH_CST820
#if ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
MAP_ITEM(CST9217),
#endif // CONFIG_ESP_PANEL_TOUCH_CST9217
#if ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
MAP_ITEM(FT5x06),
#endif // CONFIG_ESP_PANEL_TOUCH_FT5x06
Expand Down
1 change: 1 addition & 0 deletions src/drivers/touch/esp_panel_touch_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "esp_panel_touch_chsc6540.hpp"
#include "esp_panel_touch_cst816s.hpp"
#include "esp_panel_touch_cst820.hpp"
#include "esp_panel_touch_cst9217.hpp"
#include "esp_panel_touch_ft5x06.hpp"
#include "esp_panel_touch_gt911.hpp"
#include "esp_panel_touch_gt1151.hpp"
Expand Down
18 changes: 18 additions & 0 deletions src/drivers/touch/port/esp_lcd_touch_cst816s.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
} \
}

/**
* @brief Touch IO configuration structure with input address
*
* @param[in] addr I2C address of the touch panel
*
*/
#define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG_WITH_ADDR(addr) \
{ \
.dev_addr = addr, \
.control_phase_bytes = 1, \
.dc_bit_offset = 0, \
.lcd_cmd_bits = 8, \
.flags = \
{ \
.disable_control_phase = 1, \
} \
}

#ifdef __cplusplus
}
#endif
18 changes: 18 additions & 0 deletions src/drivers/touch/port/esp_lcd_touch_cst820.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ esp_err_t esp_lcd_touch_new_i2c_cst820(const esp_lcd_panel_io_handle_t io, const
} \
}

/**
* @brief Touch IO configuration structure with input address
*
* @param[in] addr I2C address of the touch panel
*
*/
#define ESP_LCD_TOUCH_IO_I2C_CST820_CONFIG_WITH_ADDR(addr) \
{ \
.dev_addr = addr, \
.control_phase_bytes = 1, \
.dc_bit_offset = 0, \
.lcd_cmd_bits = 8, \
.flags = \
{ \
.disable_control_phase = 1, \
} \
}

#ifdef __cplusplus
}
#endif
Loading