Snapshot of JC3636W518EN kit before demo folder cleanup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
9ee85bfd86
1862 files changed
+668877
No files matched your search
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
* | ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
*
|
||||
* | Supported Touch Controllers | CST816S | FT5x06 | GT911 | GT1151 | ST1633 | ST7123 | TT21100 |
|
||||
* | --------------------------- | ------- | ------ | ----- | ------ | ------ | ------- | ------- |
|
||||
*
|
||||
* # I2C Touch Example
|
||||
*
|
||||
* The example demonstrates how to develop different model touches with I2C interface using standalone drivers and test them by printing touch point coordinates.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* I2C touch example start
|
||||
* Create I2C bus
|
||||
* Create touch device
|
||||
* I2C touch example end
|
||||
* Touch point(0): x 134, y 169, strength 50
|
||||
* Touch point(1): x 154, y 301, strength 51
|
||||
* Touch point(2): x 245, y 379, strength 30
|
||||
* Touch point(3): x 290, y 75, strength 26
|
||||
* Touch point(4): x 353, y 391, strength 35
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your touch spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following I2C touch devices:
|
||||
* - CST816S
|
||||
* - FT5x06
|
||||
* - GT911, GT1151
|
||||
* - TT21100
|
||||
* - ST1633, ST7123
|
||||
*/
|
||||
#define EXAMPLE_TOUCH_NAME ST1633
|
||||
#define EXAMPLE_TOUCH_WIDTH (480)
|
||||
#define EXAMPLE_TOUCH_HEIGHT (480)
|
||||
#define EXAMPLE_TOUCH_I2C_FREQ_HZ (400 * 1000)
|
||||
#define EXAMPLE_TOUCH_READ_POINTS_NUM (5)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_I2C_SCL (45)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_I2C_SDA (19)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_RST (-1)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_INT (-1)
|
||||
|
||||
#define _EXAMPLE_TOUCH_CLASS(name, ...) ESP_PanelTouch_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_TOUCH_CLASS(name, ...) _EXAMPLE_TOUCH_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT >= 0
|
||||
IRAM_ATTR bool onTouchInterruptCallback(void *user_data)
|
||||
{
|
||||
esp_rom_printf("Touch interrupt callback\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_PanelTouch *touch = nullptr;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2C touch example start");
|
||||
|
||||
Serial.println("Create I2C bus");
|
||||
ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA,
|
||||
ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(EXAMPLE_TOUCH_NAME));
|
||||
// Taking GT911 as an example, the following is the code after macro expansion:
|
||||
// ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA,
|
||||
// ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG());
|
||||
touch_bus->configI2cFreqHz(EXAMPLE_TOUCH_I2C_FREQ_HZ);
|
||||
touch_bus->begin();
|
||||
|
||||
Serial.println("Create touch device");
|
||||
touch = new EXAMPLE_TOUCH_CLASS(EXAMPLE_TOUCH_NAME, touch_bus, EXAMPLE_TOUCH_WIDTH, EXAMPLE_TOUCH_HEIGHT,
|
||||
EXAMPLE_TOUCH_PIN_NUM_RST, EXAMPLE_TOUCH_PIN_NUM_INT);
|
||||
// Taking GT911 as an example, the following is the code after macro expansion:
|
||||
// touch = new ESP_PanelTouch_GT911(touch_bus, EXAMPLE_TOUCH_WIDTH, EXAMPLE_TOUCH_HEIGHT,
|
||||
// EXAMPLE_TOUCH_PIN_NUM_RST, EXAMPLE_TOUCH_PIN_NUM_INT);
|
||||
touch->init();
|
||||
touch->begin();
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT >= 0
|
||||
touch->attachInterruptCallback(onTouchInterruptCallback, NULL);
|
||||
#endif
|
||||
|
||||
Serial.println("I2C touch example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
ESP_PanelTouchPoint point[EXAMPLE_TOUCH_READ_POINTS_NUM];
|
||||
int read_touch_result = touch->readPoints(point, EXAMPLE_TOUCH_READ_POINTS_NUM, -1);
|
||||
|
||||
if (read_touch_result > 0) {
|
||||
for (int i = 0; i < read_touch_result; i++) {
|
||||
Serial.printf("Touch point(%d): x %d, y %d, strength %d\n", i, point[i].x, point[i].y, point[i].strength);
|
||||
}
|
||||
} else if (read_touch_result < 0) {
|
||||
Serial.println("Read touch point failed");
|
||||
}
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT < 0
|
||||
delay(30);
|
||||
#endif
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
| Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
| ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
| Supported Touch Controllers | CST816S | FT5x06 | GT911 | GT1151 | ST7123 | TT21100 |
|
||||
| --------------------------- | ------- | ------ | ----- | ------ | ------ | ------- |
|
||||
|
||||
# I2C Touch Example
|
||||
|
||||
The example demonstrates how to develop different model touches with I2C interface using standalone drivers and test them by printing touch point coordinates.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
I2C touch example start
|
||||
Create I2C bus
|
||||
Create touch device
|
||||
I2C touch example end
|
||||
Touch point(0): x 134, y 169, strength 50
|
||||
Touch point(1): x 154, y 301, strength 51
|
||||
Touch point(2): x 245, y 379, strength 30
|
||||
Touch point(3): x 290, y 75, strength 26
|
||||
Touch point(4): x 353, y 391, strength 35
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
| Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
| ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
| Supported Touch Controllers | CST816S | FT5x06 | GT911 | GT1151 | ST7123 | TT21100 |
|
||||
| --------------------------- | ------- | ------ | ----- | ------ | ------ | ------- |
|
||||
|
||||
# SPI Touch Example
|
||||
|
||||
The example demonstrates how to develop different model touches with SPI interface using standalone drivers and test them by printing touch point coordinates.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
SPI touch example start
|
||||
Create SPI bus
|
||||
Create touch device
|
||||
SPI touch example end
|
||||
Touch point(0): x 134, y 169, strength 50
|
||||
Touch point(1): x 154, y 301, strength 51
|
||||
Touch point(2): x 245, y 379, strength 30
|
||||
Touch point(3): x 290, y 75, strength 26
|
||||
Touch point(4): x 353, y 391, strength 35
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
* | ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
*
|
||||
* | Supported Touch Controllers | XPT2046 |
|
||||
* | --------------------------- | ------- |
|
||||
*
|
||||
* # SPI Touch Example
|
||||
*
|
||||
* The example demonstrates how to develop different model touches with SPI interface using standalone drivers and test them by printing touch point coordinates.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* SPI touch example start
|
||||
* Create SPI bus
|
||||
* Create touch device
|
||||
* SPI touch example end
|
||||
* Touch point(0): x 134, y 169, strength 50
|
||||
* Touch point(1): x 154, y 301, strength 51
|
||||
* Touch point(2): x 245, y 379, strength 30
|
||||
* Touch point(3): x 290, y 75, strength 26
|
||||
* Touch point(4): x 353, y 391, strength 35
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your touch spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following SPI touch devices:
|
||||
* - XPT2046
|
||||
*/
|
||||
#define EXAMPLE_TOUCH_NAME XPT2046
|
||||
#define EXAMPLE_TOUCH_WIDTH (240)
|
||||
#define EXAMPLE_TOUCH_HEIGHT (320)
|
||||
#define EXAMPLE_TOUCH_SPI_FREQ_HZ (1 * 1000 * 1000)
|
||||
#define EXAMPLE_TOUCH_READ_POINTS_NUM (1)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_SPI_CS (46)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_SPI_SCK (10)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_SPI_MOSI (14)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_SPI_MISO (8)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_RST (-1)
|
||||
#define EXAMPLE_TOUCH_PIN_NUM_INT (-1)
|
||||
|
||||
#define _EXAMPLE_TOUCH_CLASS(name, ...) ESP_PanelTouch_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_TOUCH_CLASS(name, ...) _EXAMPLE_TOUCH_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT >= 0
|
||||
IRAM_ATTR bool onTouchInterruptCallback(void *user_data)
|
||||
{
|
||||
esp_rom_printf("Touch interrupt callback\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_PanelTouch *touch = nullptr;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI touch example start");
|
||||
|
||||
Serial.println("Create SPI bus");
|
||||
ESP_PanelBus_SPI *touch_bus = new ESP_PanelBus_SPI(
|
||||
EXAMPLE_TOUCH_PIN_NUM_SPI_SCK, EXAMPLE_TOUCH_PIN_NUM_SPI_MOSI, EXAMPLE_TOUCH_PIN_NUM_SPI_MISO,
|
||||
ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(EXAMPLE_TOUCH_NAME, EXAMPLE_TOUCH_PIN_NUM_SPI_CS));
|
||||
// Taking XPT2046 as an example, the following is the code after macro expansion:
|
||||
// ESP_PanelBus_SPI *touch_bus = new ESP_PanelBus_SPI(
|
||||
// EXAMPLE_TOUCH_PIN_NUM_SPI_SCK, EXAMPLE_TOUCH_PIN_NUM_SPI_MOSI, EXAMPLE_TOUCH_PIN_NUM_SPI_MISO,
|
||||
// ESP_LCD_TOUCH_IO_SPI_XPT2046_CONFIG(EXAMPLE_TOUCH_PIN_NUM_SPI_CS));
|
||||
touch_bus->configSpiFreqHz(EXAMPLE_TOUCH_SPI_FREQ_HZ);
|
||||
touch_bus->begin();
|
||||
|
||||
Serial.println("Create touch device");
|
||||
touch = new EXAMPLE_TOUCH_CLASS(EXAMPLE_TOUCH_NAME, touch_bus, EXAMPLE_TOUCH_WIDTH, EXAMPLE_TOUCH_HEIGHT,
|
||||
EXAMPLE_TOUCH_PIN_NUM_RST, EXAMPLE_TOUCH_PIN_NUM_INT);
|
||||
// Taking XPT2046 as an example, the following is the code after macro expansion:
|
||||
// touch = new ESP_PanelTouch_XPT2046(touch_bus, EXAMPLE_TOUCH_WIDTH, EXAMPLE_TOUCH_HEIGHT,
|
||||
// EXAMPLE_TOUCH_PIN_NUM_RST, EXAMPLE_TOUCH_PIN_NUM_INT);
|
||||
touch->init();
|
||||
touch->begin();
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT >= 0
|
||||
touch->attachInterruptCallback(onTouchInterruptCallback, NULL);
|
||||
#endif
|
||||
|
||||
Serial.println("SPI touch example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
ESP_PanelTouchPoint point[EXAMPLE_TOUCH_READ_POINTS_NUM];
|
||||
int read_touch_result = touch->readPoints(point, EXAMPLE_TOUCH_READ_POINTS_NUM, -1);
|
||||
|
||||
if (read_touch_result > 0) {
|
||||
for (int i = 0; i < read_touch_result; i++) {
|
||||
Serial.printf("Touch point(%d): x %d, y %d, strength %d\n", i, point[i].x, point[i].y, point[i].strength);
|
||||
}
|
||||
} else if (read_touch_result < 0) {
|
||||
Serial.println("Read touch point failed");
|
||||
}
|
||||
#if EXAMPLE_TOUCH_PIN_NUM_INT < 0
|
||||
delay(30);
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user