Skip to content

Commit

Permalink
feat(touch): add i2c st1633
Browse files Browse the repository at this point in the history
Closes #22
  • Loading branch information
Lzw655 committed Jun 1, 2024
1 parent 5c44656 commit ec4efdc
Show file tree
Hide file tree
Showing 12 changed files with 400 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/LVGL/v8/Porting/ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/LVGL/v8/Rotation/ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/Panel/PanelTest/ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/SquareLine/v8/Porting/ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
* - CST816S
* - FT5x06
* - GT911, GT1151
* - ST7123
* - ST1633, ST7123
* - TT21100
* - XPT2046
*/
Expand Down
8 changes: 4 additions & 4 deletions examples/Touch/I2C/I2C.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* | Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
* | ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
*
* | Supported Touch Controllers | CST816S | FT5x06 | GT911 | GT1151 | ST7123 | TT21100 |
* | --------------------------- | ------- | ------ | ----- | ------ | ------ | ------- |
* | Supported Touch Controllers | CST816S | FT5x06 | GT911 | GT1151 | ST1633 | ST7123 | TT21100 |
* | --------------------------- | ------- | ------ | ----- | ------ | ------ | ------- | ------- |
*
* # I2C Touch Example
*
Expand Down Expand Up @@ -50,9 +50,9 @@
* - FT5x06
* - GT911, GT1151
* - TT21100
* - ST7123
* - ST1633, ST7123
*/
#define EXAMPLE_TOUCH_NAME GT911
#define EXAMPLE_TOUCH_NAME ST1633
#define EXAMPLE_TOUCH_WIDTH (480)
#define EXAMPLE_TOUCH_HEIGHT (480)
#define EXAMPLE_TOUCH_I2C_FREQ_HZ (400 * 1000)
Expand Down
1 change: 1 addition & 0 deletions src/ESP_Panel_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "touch/FT5x06.h"
#include "touch/GT1151.h"
#include "touch/GT911.h"
#include "touch/ST1633.h"
#include "touch/ST7123.h"
#include "touch/TT21100.h"
#include "touch/XPT2046.h"
Expand Down
46 changes: 46 additions & 0 deletions src/touch/ST1633.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "ESP_PanelLog.h"
#include "ST1633.h"

static const char *TAG = "ST1633_CPP";

ESP_PanelTouch_ST1633::ESP_PanelTouch_ST1633(ESP_PanelBus *bus, uint16_t width, uint16_t height,
int rst_io, int int_io):
ESP_PanelTouch(bus, width, height, rst_io, int_io)
{
}

ESP_PanelTouch_ST1633::ESP_PanelTouch_ST1633(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config):
ESP_PanelTouch(bus, config)
{
}

ESP_PanelTouch_ST1633::~ESP_PanelTouch_ST1633()
{
ESP_PANEL_ENABLE_TAG_DEBUG_LOG();

if (handle == NULL) {
goto end;
}

if (!del()) {
ESP_LOGE(TAG, "Delete device failed");
}

end:
ESP_LOGD(TAG, "Destroyed");
}

bool ESP_PanelTouch_ST1633::begin(void)
{
ESP_PANEL_CHECK_NULL_RET(bus, false, "Invalid bus");

ESP_PANEL_CHECK_ERR_RET(esp_lcd_touch_new_i2c_st1633(bus->getHandle(), &config, &handle), false, "New driver failed");

return true;
}
50 changes: 50 additions & 0 deletions src/touch/ST1633.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include "base/esp_lcd_touch_st1633.h"
#include "ESP_PanelTouch.h"

/**
* @brief ST1633 touch device object class
*
* @note This class is a derived class of `ESP_PanelTouch`, user can use it directly
*/
class ESP_PanelTouch_ST1633 : public ESP_PanelTouch {
public:
/**
* @brief Construct a new touch device in a simple way, the `init()` function should be called after this function
*
* @param bus Pointer to panel bus
* @param width The width of the touch screen
* @param height The height of the touch screen
* @param rst_io The reset pin of the touch screen, set to `-1` if not used
* @param int_io The interrupt pin of the touch screen, set to `-1` if not used
*/
ESP_PanelTouch_ST1633(ESP_PanelBus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1);

/**
* @brief Construct a new touch device in a complex way, the `init()` function should be called after this function
*
* @param bus Pointer to panel bus
* @param config Touch device configuration
*/
ESP_PanelTouch_ST1633(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config);

/**
* @brief Destroy the LCD device
*
*/
~ESP_PanelTouch_ST1633() override;

/**
* @brief Startup the touch device
*
* @return true if success, otherwise false
*/
bool begin(void) override;
};
Loading

0 comments on commit ec4efdc

Please sign in to comment.