Skip to content

Touch GSL3680 Driver support #212

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions src/drivers/touch/Kconfig.touch
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ menu "Touch"
config ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046
bool "Use XPT2046"
default n

config ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
bool "Use GSL3680"
default n
endif
endmenu

Expand Down
17 changes: 17 additions & 0 deletions src/drivers/touch/esp_panel_touch_conf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define ESP_PANEL_DRIVERS_TOUCH_USE_STMPE610 (1)
#define ESP_PANEL_DRIVERS_TOUCH_USE_TT21100 (1)
#define ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 (1)
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 (1)
#else
#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_AXS15231B
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_AXS15231B
Expand Down Expand Up @@ -148,6 +149,14 @@
#define ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 (0)
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
#else
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 (0)
#endif
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS
Expand Down Expand Up @@ -298,4 +307,12 @@
#endif
#endif

#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680 (1)
#else
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680 (0)
#endif
#endif

// *INDENT-ON*
5 changes: 4 additions & 1 deletion src/drivers/touch/esp_panel_touch_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ const utils::unordered_map<utils::string, TouchFactory::FunctionCreateDevice> To
#endif // CONFIG_ESP_PANEL_TOUCH_TT21100
#if ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046
MAP_ITEM(XPT2046),
#endif // CONFIG_ESP_PANEL_TOUCH_XPT2046
#endif // CONFIG_ESP_PANEL_TOUCH_GSL3680
#if ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
MAP_ITEM(GSL3680),
#endif // CONFIG_ESP_PANEL_TOUCH_GSL3680
};

std::shared_ptr<Touch> TouchFactory::create(
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 @@ -22,6 +22,7 @@
#include "esp_panel_touch_stmpe610.hpp"
#include "esp_panel_touch_tt21100.hpp"
#include "esp_panel_touch_xpt2046.hpp"
#include "esp_panel_touch_gsl3680.hpp"

namespace esp_panel::drivers {

Expand Down
59 changes: 59 additions & 0 deletions src/drivers/touch/esp_panel_touch_gsl3680.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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_GSL3680

#include "utils/esp_panel_utils_log.h"
#include "drivers/bus/esp_panel_bus_i2c.hpp"
#include "esp_panel_touch_gsl3680.hpp"

namespace esp_panel::drivers {

TouchGSL3680::~TouchGSL3680()
{
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

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

ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
}

bool TouchGSL3680::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");
}

// Setup driver-specific config
auto bus = static_cast<BusI2C *>(getBus());
esp_lcd_touch_io_gsl3680_config_t tp_gsl3680_config = {
.dev_addr = bus->getI2cAddress(),
};
setDriverData(&tp_gsl3680_config);

// Create the touch panel
ESP_UTILS_CHECK_ERROR_RETURN(
esp_lcd_touch_new_i2c_gsl3680(bus->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_GSL3680
89 changes: 89 additions & 0 deletions src/drivers/touch/esp_panel_touch_gsl3680.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

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

namespace esp_panel::drivers {

/**
* @brief GSL3680 touch controller
*
* This class provides implementation for GSL3680 touch controller, inheriting from
* the base Touch class to provide common touch functionality
*/
class TouchGSL3680 : public Touch {
public:
/**
* @brief Default basic attributes for GSL3680
*/
static constexpr BasicAttributes BASIC_ATTRIBUTES_DEFAULT = {
.name = "GSL3680",
.max_points_num = 5,
.max_buttons_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)
*/
TouchGSL3680(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
*/
TouchGSL3680(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
*/
TouchGSL3680(const BusFactory::Config &bus_config, const Config &touch_config):
Touch(BASIC_ATTRIBUTES_DEFAULT, bus_config, touch_config)
{
}

/**
* @brief Destruct touch device
*/
~TouchGSL3680() 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

/**
* @brief Deprecated type alias for backward compatibility
* @deprecated Use `esp_panel::drivers::TouchGGL3680` instead
*/
using ESP_PanelTouch_GTSL3680 [[deprecated("Use `esp_panel::drivers::TouchGSL3680` instead")]] =
esp_panel::drivers::TouchGSL3680;

Loading