Skip to content

Commit 0ccaa97

Browse files
DejanBukovecLzw655
authored andcommitted
GSL3680 Driver
1 parent a450042 commit 0ccaa97

File tree

8 files changed

+5541
-1
lines changed

8 files changed

+5541
-1
lines changed

src/drivers/touch/Kconfig.touch

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ menu "Touch"
7070
config ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046
7171
bool "Use XPT2046"
7272
default n
73+
74+
config ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
75+
bool "Use GSL3680"
76+
default n
7377
endif
7478
endmenu
7579

src/drivers/touch/esp_panel_touch_conf_internal.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define ESP_PANEL_DRIVERS_TOUCH_USE_STMPE610 (1)
5353
#define ESP_PANEL_DRIVERS_TOUCH_USE_TT21100 (1)
5454
#define ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 (1)
55+
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 (1)
5556
#else
5657
#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_AXS15231B
5758
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_AXS15231B
@@ -148,6 +149,14 @@
148149
#define ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 (0)
149150
#endif
150151
#endif
152+
153+
#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
154+
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
155+
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
156+
#else
157+
#define ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680 (0)
158+
#endif
159+
#endif
151160
#endif
152161

153162
#ifndef ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS
@@ -306,4 +315,12 @@
306315
#endif
307316
#endif
308317

318+
#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680
319+
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
320+
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680 (1)
321+
#else
322+
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680 (0)
323+
#endif
324+
#endif
325+
309326
// *INDENT-ON*

src/drivers/touch/esp_panel_touch_factory.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ const utils::unordered_map<utils::string, TouchFactory::FunctionCreateDevice> To
6262
#endif // CONFIG_ESP_PANEL_TOUCH_TT21100
6363
#if ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046
6464
MAP_ITEM(XPT2046),
65-
#endif // CONFIG_ESP_PANEL_TOUCH_XPT2046
65+
#endif // CONFIG_ESP_PANEL_TOUCH_GSL3680
66+
#if ESP_PANEL_DRIVERS_TOUCH_USE_GSL3680
67+
MAP_ITEM(GSL3680),
68+
#endif // CONFIG_ESP_PANEL_TOUCH_GSL3680
6669
};
6770

6871
std::shared_ptr<Touch> TouchFactory::create(

src/drivers/touch/esp_panel_touch_factory.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "esp_panel_touch_stmpe610.hpp"
2424
#include "esp_panel_touch_tt21100.hpp"
2525
#include "esp_panel_touch_xpt2046.hpp"
26+
#include "esp_panel_touch_gsl3680.hpp"
2627

2728
namespace esp_panel::drivers {
2829

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp_panel_touch_conf_internal.h"
8+
#if ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680
9+
10+
#include "utils/esp_panel_utils_log.h"
11+
#include "drivers/bus/esp_panel_bus_i2c.hpp"
12+
#include "esp_panel_touch_gsl3680.hpp"
13+
14+
namespace esp_panel::drivers {
15+
16+
TouchGSL3680::~TouchGSL3680()
17+
{
18+
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
19+
20+
ESP_UTILS_CHECK_FALSE_EXIT(del(), "Delete failed");
21+
22+
ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
23+
}
24+
25+
bool TouchGSL3680::begin()
26+
{
27+
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
28+
29+
ESP_UTILS_CHECK_FALSE_RETURN(!isOverState(State::BEGIN), false, "Already begun");
30+
31+
// Initialize the touch if not initialized
32+
if (!isOverState(State::INIT)) {
33+
ESP_UTILS_CHECK_FALSE_RETURN(init(), false, "Init failed");
34+
}
35+
36+
// Setup driver-specific config
37+
auto bus = static_cast<BusI2C *>(getBus());
38+
esp_lcd_touch_io_gsl3680_config_t tp_gsl3680_config = {
39+
.dev_addr = bus->getI2cAddress(),
40+
};
41+
setDriverData(&tp_gsl3680_config);
42+
43+
// Create the touch panel
44+
ESP_UTILS_CHECK_ERROR_RETURN(
45+
esp_lcd_touch_new_i2c_gsl3680(bus->getControlPanelHandle(), getConfig().getDeviceFullConfig(), &touch_panel),
46+
false, "Create touch panel failed"
47+
);
48+
ESP_UTILS_LOGD("Create touch panel(@%p)", touch_panel);
49+
50+
setState(State::BEGIN);
51+
52+
ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
53+
54+
return true;
55+
}
56+
57+
} // namespace esp_panel::drivers
58+
59+
#endif // ESP_PANEL_DRIVERS_TOUCH_ENABLE_GSL3680
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "port/esp_lcd_touch_gsl3680.h"
10+
#include "esp_panel_touch_conf_internal.h"
11+
#include "esp_panel_touch.hpp"
12+
13+
namespace esp_panel::drivers {
14+
15+
/**
16+
* @brief GSL3680 touch controller
17+
*
18+
* This class provides implementation for GSL3680 touch controller, inheriting from
19+
* the base Touch class to provide common touch functionality
20+
*/
21+
class TouchGSL3680 : public Touch {
22+
public:
23+
/**
24+
* @brief Default basic attributes for GSL3680
25+
*/
26+
static constexpr BasicAttributes BASIC_ATTRIBUTES_DEFAULT = {
27+
.name = "GSL3680",
28+
.max_points_num = 5,
29+
.max_buttons_num = 1,
30+
};
31+
32+
/**
33+
* @brief Construct a touch device instance with individual configuration parameters
34+
*
35+
* @param bus Bus interface for communicating with the touch device
36+
* @param width Panel width in pixels
37+
* @param height Panel height in pixels
38+
* @param rst_io Reset GPIO pin number (-1 if unused)
39+
* @param int_io Interrupt GPIO pin number (-1 if unused)
40+
*/
41+
TouchGSL3680(Bus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1):
42+
Touch(BASIC_ATTRIBUTES_DEFAULT, bus, width, height, rst_io, int_io)
43+
{
44+
}
45+
46+
/**
47+
* @brief Construct a touch device instance with configuration
48+
*
49+
* @param[in] bus Pointer to the bus interface for communicating with the touch device
50+
* @param[in] config Configuration structure containing device settings and parameters
51+
*/
52+
TouchGSL3680(Bus *bus, const Config &config): Touch(BASIC_ATTRIBUTES_DEFAULT, bus, config) {}
53+
54+
/**
55+
* @brief Construct a touch device instance with bus configuration and device configuration
56+
*
57+
* @param[in] bus_config Bus configuration
58+
* @param[in] touch_config Touch configuration
59+
* @note This constructor creates a new bus instance using the provided bus configuration
60+
*/
61+
TouchGSL3680(const BusFactory::Config &bus_config, const Config &touch_config):
62+
Touch(BASIC_ATTRIBUTES_DEFAULT, bus_config, touch_config)
63+
{
64+
}
65+
66+
/**
67+
* @brief Destruct touch device
68+
*/
69+
~TouchGSL3680() override;
70+
71+
/**
72+
* @brief Startup the touch device
73+
*
74+
* @return `true` if success, otherwise false
75+
*
76+
* @note This function should be called after `init()`
77+
*/
78+
bool begin() override;
79+
};
80+
81+
} // namespace esp_panel::drivers
82+
83+
/**
84+
* @brief Deprecated type alias for backward compatibility
85+
* @deprecated Use `esp_panel::drivers::TouchGGL3680` instead
86+
*/
87+
using ESP_PanelTouch_GTSL3680 [[deprecated("Use `esp_panel::drivers::TouchGSL3680` instead")]] =
88+
esp_panel::drivers::TouchGSL3680;
89+

0 commit comments

Comments
 (0)