Update with epdiy last version support
This commit is contained in:
parent
d738aaa84f
commit
87bf29d676
56 changed files with 1844 additions and 859 deletions
|
@ -1,29 +1,28 @@
|
|||
menu "LVGL Touch controller"
|
||||
|
||||
config LV_TOUCH_CONTROLLER
|
||||
int
|
||||
default 0 if LV_TOUCH_CONTROLLER_NONE
|
||||
default 1 if LV_TOUCH_CONTROLLER_XPT2046
|
||||
default 2 if LV_TOUCH_CONTROLLER_FT6X06
|
||||
default 3 if LV_TOUCH_CONTROLLER_STMPE610
|
||||
int
|
||||
default 0 if LV_TOUCH_CONTROLLER_NONE
|
||||
default 1 if LV_TOUCH_CONTROLLER_XPT2046
|
||||
default 2 if LV_TOUCH_CONTROLLER_FT6X06
|
||||
default 3 if LV_TOUCH_CONTROLLER_STMPE610
|
||||
default 4 if LV_TOUCH_CONTROLLER_ADCRAW
|
||||
default 5 if LV_TOUCH_CONTROLLER_FT81X
|
||||
default 6 if LV_TOUCH_CONTROLLER_RA8875
|
||||
default 7 if LV_TOUCH_CONTROLLER_GT911
|
||||
default 8 if LV_TOUCH_CONTROLLER_L58
|
||||
default 7 if LV_TOUCH_CONTROLLER_L58
|
||||
choice
|
||||
prompt "Select a touch panel controller model."
|
||||
default LV_TOUCH_CONTROLLER_NONE
|
||||
help
|
||||
Select the controller for your touch panel.
|
||||
prompt "Select a touch panel controller model."
|
||||
default LV_TOUCH_CONTROLLER_NONE
|
||||
help
|
||||
Select the controller for your touch panel.
|
||||
|
||||
config LV_TOUCH_CONTROLLER_NONE
|
||||
bool "None"
|
||||
config LV_TOUCH_CONTROLLER_XPT2046
|
||||
config LV_TOUCH_CONTROLLER_NONE
|
||||
bool "None"
|
||||
config LV_TOUCH_CONTROLLER_XPT2046
|
||||
select LV_TOUCH_DRIVER_PROTOCOL_SPI
|
||||
bool "XPT2046"
|
||||
config LV_TOUCH_CONTROLLER_FT6X06
|
||||
select LV_I2C_TOUCH
|
||||
config LV_TOUCH_CONTROLLER_FT6X06
|
||||
select LV_TOUCH_DRIVER_PROTOCOL_I2C
|
||||
bool "FT6X06"
|
||||
|
||||
config LV_TOUCH_CONTROLLER_L58
|
||||
|
@ -43,17 +42,14 @@ menu "LVGL Touch controller"
|
|||
config LV_TOUCH_CONTROLLER_RA8875
|
||||
select LV_TOUCH_DRIVER_DISPLAY
|
||||
bool "RA8875"
|
||||
config LV_TOUCH_CONTROLLER_GT911
|
||||
select LV_I2C_TOUCH
|
||||
bool "GT911"
|
||||
endchoice
|
||||
|
||||
|
||||
config LV_TOUCH_DRIVER_PROTOCOL_SPI
|
||||
bool
|
||||
help
|
||||
Touch controller protocol SPI
|
||||
|
||||
config LV_I2C_TOUCH
|
||||
config LV_TOUCH_DRIVER_PROTOCOL_I2C
|
||||
bool
|
||||
help
|
||||
Touch controller protocol I2C
|
||||
|
@ -67,20 +63,37 @@ menu "LVGL Touch controller"
|
|||
bool
|
||||
help
|
||||
Touch controller uses same interface/device as display
|
||||
(Note: Display must be initialized before touch)
|
||||
(Note: Display must be initialized before touch)
|
||||
|
||||
choice
|
||||
prompt "Touch I2C port"
|
||||
depends on LV_TOUCH_DRIVER_PROTOCOL_I2C
|
||||
|
||||
default LV_TOUCH_I2C_PORT_0
|
||||
help
|
||||
Select the I2C port used by the touch controller.
|
||||
|
||||
config LV_TOUCH_I2C_PORT_0
|
||||
bool "I2C PORT 0"
|
||||
config LV_TOUCH_I2C_PORT_1
|
||||
bool "I2C PORT 1"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Touch Controller SPI Bus."
|
||||
depends on LV_TOUCH_DRIVER_PROTOCOL_SPI
|
||||
|
||||
default LV_TOUCH_CONTROLLER_SPI2_HOST
|
||||
|
||||
default LV_TOUCH_CONTROLLER_SPI_VSPI if !IDF_TARGET_ESP32S2
|
||||
default LV_TOUCH_CONTROLLER_SPI_FSPI if IDF_TARGET_ESP32S2
|
||||
help
|
||||
Select the SPI Bus the touch controller is attached to.
|
||||
|
||||
config LV_TOUCH_CONTROLLER_SPI2_HOST
|
||||
bool "SPI2_HOST"
|
||||
config LV_TOUCH_CONTROLLER_SPI3_HOST
|
||||
bool "SPI3_HOST"
|
||||
Select the SPI Bus the TFT Display is attached to.
|
||||
|
||||
config LV_TOUCH_CONTROLLER_SPI_HSPI
|
||||
bool "HSPI"
|
||||
config LV_TOUCH_CONTROLLER_SPI_VSPI
|
||||
bool "VSPI" if !IDF_TARGET_ESP32S2
|
||||
config LV_TOUCH_CONTROLLER_SPI_FSPI
|
||||
bool "FSPI" if IDF_TARGET_ESP32S2
|
||||
endchoice
|
||||
|
||||
menu "Touchpanel (L58) Lilygo Pin Assignments"
|
||||
|
@ -120,7 +133,9 @@ menu "LVGL Touch controller"
|
|||
config LV_TOUCH_SPI_MISO
|
||||
int
|
||||
prompt "GPIO for MISO (Master In Slave Out)"
|
||||
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 35 if LV_PREDEFINED_PINS_38V1
|
||||
default 19
|
||||
help
|
||||
|
@ -129,6 +144,8 @@ menu "LVGL Touch controller"
|
|||
config LV_TOUCH_SPI_MOSI
|
||||
int
|
||||
prompt "GPIO for MOSI (Master Out Slave In)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 32 if LV_PREDEFINED_PINS_38V1
|
||||
default 23
|
||||
|
@ -137,7 +154,9 @@ menu "LVGL Touch controller"
|
|||
|
||||
config LV_TOUCH_SPI_CLK
|
||||
int "GPIO for CLK (SCK / Serial Clock)"
|
||||
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 26 if LV_PREDEFINED_PINS_38V1
|
||||
default 18
|
||||
help
|
||||
|
@ -145,7 +164,9 @@ menu "LVGL Touch controller"
|
|||
|
||||
config LV_TOUCH_SPI_CS
|
||||
int "GPIO for CS (Slave Select)"
|
||||
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 33 if LV_PREDEFINED_PINS_38V1
|
||||
default 5
|
||||
help
|
||||
|
@ -153,13 +174,15 @@ menu "LVGL Touch controller"
|
|||
|
||||
config LV_TOUCH_PIN_IRQ
|
||||
int "GPIO for IRQ (Interrupt Request)"
|
||||
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 27 if LV_PREDEFINED_PINS_38V4
|
||||
default 25
|
||||
help
|
||||
Configure the touchpanel IRQ pin here.
|
||||
endmenu
|
||||
|
||||
|
||||
menu "Touchpanel Configuration (XPT2046)"
|
||||
depends on LV_TOUCH_CONTROLLER_XPT2046
|
||||
|
||||
|
@ -186,11 +209,11 @@ menu "LVGL Touch controller"
|
|||
prompt "Maximum Y coordinate value."
|
||||
default 4095 if LV_PREDEFINED_PINS_38V4
|
||||
default 1900
|
||||
|
||||
config LV_TOUCH_XY_SWAP
|
||||
bool
|
||||
prompt "Swap XY."
|
||||
default y
|
||||
|
||||
config LV_TOUCH_XY_SWAP
|
||||
bool
|
||||
prompt "Swap XY."
|
||||
default y
|
||||
|
||||
config LV_TOUCH_INVERT_X
|
||||
bool
|
||||
|
@ -217,13 +240,36 @@ menu "LVGL Touch controller"
|
|||
endchoice
|
||||
endmenu
|
||||
|
||||
menu "Touchpanel (FT6X06) Pin Assignments"
|
||||
depends on LV_TOUCH_CONTROLLER_FT6X06
|
||||
|
||||
config LV_TOUCH_I2C_SDA
|
||||
int
|
||||
prompt "GPIO for SDA (I2C)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 21
|
||||
help
|
||||
Configure the I2C touchpanel SDA pin here.
|
||||
|
||||
config LV_TOUCH_I2C_SCL
|
||||
int "GPIO for clock signal SCL (I2C)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 22
|
||||
help
|
||||
Configure the I2C touchpanel SCL pin here.
|
||||
endmenu
|
||||
|
||||
menu "Touchpanel Configuration (FT6X06)"
|
||||
depends on LV_TOUCH_CONTROLLER_FT6X06
|
||||
|
||||
config LV_FT6X36_SWAPXY
|
||||
bool
|
||||
prompt "Swap X with Y coordinate."
|
||||
default n
|
||||
config LV_FT6X36_SWAPXY
|
||||
bool
|
||||
prompt "Swap X with Y coordinate."
|
||||
default y
|
||||
|
||||
config LV_FT6X36_INVERT_X
|
||||
bool
|
||||
|
@ -233,24 +279,19 @@ menu "LVGL Touch controller"
|
|||
config LV_FT6X36_INVERT_Y
|
||||
bool
|
||||
prompt "Invert Y coordinate value."
|
||||
default n
|
||||
|
||||
config LV_FT6X36_COORDINATES_QUEUE
|
||||
bool
|
||||
prompt "Send coordinates to FreeRTOS queue."
|
||||
default n
|
||||
help
|
||||
Receive from the FreeRTOS queue using the handle 'ft6x36_touch_queue_handle'.
|
||||
default y
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
menu "Touchpanel (STMPE610) Pin Assignments"
|
||||
depends on LV_TOUCH_CONTROLLER_STMPE610
|
||||
|
||||
config LV_TOUCH_SPI_MISO
|
||||
int
|
||||
prompt "GPIO for MISO (Master In Slave Out)"
|
||||
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 35 if LV_PREDEFINED_PINS_38V1
|
||||
default 19 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
default 19
|
||||
|
@ -259,9 +300,10 @@ menu "LVGL Touch controller"
|
|||
Configure the touchpanel MISO pin here.
|
||||
|
||||
config LV_TOUCH_SPI_MOSI
|
||||
# TODO Fix default for ESP32C3
|
||||
int
|
||||
prompt "GPIO for MOSI (Master Out Slave In)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 32 if LV_PREDEFINED_PINS_38V1
|
||||
default 18 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
|
@ -272,6 +314,8 @@ menu "LVGL Touch controller"
|
|||
|
||||
config LV_TOUCH_SPI_CLK
|
||||
int "GPIO for CLK (SCK / Serial Clock)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 26 if LV_PREDEFINED_PINS_38V1
|
||||
default 5 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
|
@ -281,6 +325,9 @@ menu "LVGL Touch controller"
|
|||
|
||||
config LV_TOUCH_SPI_CS
|
||||
int "GPIO for CS (Slave Select)"
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 33 if LV_PREDEFINED_PINS_38V1
|
||||
default 32 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
default 5
|
||||
|
@ -310,11 +357,11 @@ menu "LVGL Touch controller"
|
|||
int
|
||||
prompt "Maximum Y coordinate value."
|
||||
default 3800
|
||||
|
||||
|
||||
config LV_TOUCH_XY_SWAP
|
||||
bool
|
||||
prompt "Swap XY."
|
||||
default n
|
||||
bool
|
||||
prompt "Swap XY."
|
||||
default n
|
||||
|
||||
config LV_TOUCH_INVERT_X
|
||||
bool
|
||||
|
@ -326,7 +373,7 @@ menu "LVGL Touch controller"
|
|||
prompt "Invert Y coordinate value."
|
||||
default y
|
||||
endmenu
|
||||
|
||||
|
||||
menu "Touchpanel (ADCRAW) Pin Assignments"
|
||||
depends on LV_TOUCH_CONTROLLER_ADCRAW
|
||||
|
||||
|
@ -347,7 +394,7 @@ menu "LVGL Touch controller"
|
|||
|
||||
help
|
||||
Configure the touchpanel Y- pin. Must be ADC input.
|
||||
|
||||
|
||||
config LV_TOUCHSCREEN_RESISTIVE_PIN_XL
|
||||
int
|
||||
prompt "GPIO X-"
|
||||
|
@ -413,25 +460,25 @@ menu "LVGL Touch controller"
|
|||
config LV_TOUCH_X_MIN
|
||||
int
|
||||
prompt "Minimum X coordinate ADC value"
|
||||
range 0 1023
|
||||
range 0 1023
|
||||
default 0
|
||||
|
||||
config LV_TOUCH_Y_MIN
|
||||
int
|
||||
prompt "Minimum Y coordinate ADC value"
|
||||
range 0 1023
|
||||
range 0 1023
|
||||
default 0
|
||||
|
||||
config LV_TOUCH_X_MAX
|
||||
int
|
||||
prompt "Maximum X coordinate ADC value"
|
||||
range 0 1023
|
||||
range 0 1023
|
||||
default 1023
|
||||
|
||||
config LV_TOUCH_Y_MAX
|
||||
int
|
||||
prompt "Maximum Y coordinate ADC value"
|
||||
range 0 1023
|
||||
range 0 1023
|
||||
default 1023
|
||||
|
||||
config LV_TOUCH_XY_SWAP
|
||||
|
@ -452,13 +499,13 @@ menu "LVGL Touch controller"
|
|||
config LV_TOUCH_RA8875_SAMPLE_TIME
|
||||
int
|
||||
prompt "TP Sample Time Adjusting"
|
||||
range 0 7
|
||||
range 0 7
|
||||
default 0
|
||||
|
||||
config LV_TOUCH_RA8875_ADC_CLOCK
|
||||
int
|
||||
prompt "ADC Clock Setting"
|
||||
range 0 7
|
||||
range 0 7
|
||||
default 0
|
||||
|
||||
config LV_TOUCH_RA8875_WAKEUP_ENABLE
|
||||
|
@ -478,57 +525,4 @@ menu "LVGL Touch controller"
|
|||
|
||||
endmenu
|
||||
|
||||
menu "Touchpanel Configuration (GT911)"
|
||||
depends on LV_TOUCH_CONTROLLER_GT911
|
||||
|
||||
config LV_GT911_SWAPXY
|
||||
bool
|
||||
prompt "Swap X with Y coordinate."
|
||||
default y
|
||||
|
||||
config LV_GT911_INVERT_X
|
||||
bool
|
||||
prompt "Invert X coordinate value."
|
||||
default n
|
||||
|
||||
config LV_GT911_INVERT_Y
|
||||
bool
|
||||
prompt "Invert Y coordinate value."
|
||||
default y
|
||||
|
||||
endmenu
|
||||
|
||||
choice
|
||||
prompt "Select an I2C port for the touch panel"
|
||||
default LV_I2C_TOUCH_PORT_0
|
||||
depends on LV_I2C_TOUCH
|
||||
|
||||
config LV_I2C_TOUCH_PORT_0
|
||||
bool
|
||||
prompt "I2C port 0"
|
||||
help
|
||||
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
|
||||
Component config->I2C Port Settings.
|
||||
|
||||
config LV_I2C_TOUCH_PORT_1
|
||||
bool
|
||||
prompt "I2C port 1"
|
||||
help
|
||||
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
|
||||
Component config->I2C Port Settings.
|
||||
|
||||
endchoice
|
||||
|
||||
config LV_I2C
|
||||
bool
|
||||
default y if LV_I2C_TOUCH
|
||||
|
||||
config LV_I2C_TOUCH_PORT
|
||||
int
|
||||
default 1 if LV_I2C_TOUCH_PORT_1
|
||||
default 0
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,45 +1,55 @@
|
|||
/*
|
||||
* Copyright © 2020 Wolfgang Christl
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <driver/i2c.h>
|
||||
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||
#include <lvgl.h>
|
||||
#else
|
||||
#include <lvgl/lvgl.h>
|
||||
#endif
|
||||
#include "ft6x36.h"
|
||||
#include "lvgl_i2c/i2c_manager.h"
|
||||
#include "tp_i2c.h"
|
||||
#include "../lvgl_i2c_conf.h"
|
||||
|
||||
#define TAG "FT6X36"
|
||||
#define FT6X36_TOUCH_QUEUE_ELEMENTS 1
|
||||
|
||||
|
||||
static ft6x36_status_t ft6x36_status;
|
||||
static uint8_t current_dev_addr; // set during init
|
||||
static ft6x36_touch_t touch_inputs = { -1, -1, LV_INDEV_STATE_REL }; // -1 coordinates to designate it was never touched
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
QueueHandle_t ft6x36_touch_queue_handle;
|
||||
#endif
|
||||
ft6x36_status_t ft6x36_status;
|
||||
uint8_t current_dev_addr; // set during init
|
||||
|
||||
static esp_err_t ft6x06_i2c_read8(uint8_t slave_addr, uint8_t register_addr, uint8_t *data_buf) {
|
||||
return lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr, data_buf, 1);
|
||||
esp_err_t ft6x06_i2c_read8(uint8_t slave_addr, uint8_t register_addr, uint8_t *data_buf) {
|
||||
i2c_cmd_handle_t i2c_cmd = i2c_cmd_link_create();
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (slave_addr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(i2c_cmd, register_addr, I2C_MASTER_ACK);
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (slave_addr << 1) | I2C_MASTER_READ, true);
|
||||
|
||||
i2c_master_read_byte(i2c_cmd, data_buf, I2C_MASTER_NACK);
|
||||
i2c_master_stop(i2c_cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(TOUCH_I2C_PORT, i2c_cmd, 1000 / portTICK_RATE_MS);
|
||||
i2c_cmd_link_delete(i2c_cmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,38 +75,42 @@ uint8_t ft6x36_get_gesture_id() {
|
|||
* @retval None
|
||||
*/
|
||||
void ft6x06_init(uint16_t dev_addr) {
|
||||
if (!ft6x36_status.inited) {
|
||||
|
||||
ft6x36_status.inited = true;
|
||||
current_dev_addr = dev_addr;
|
||||
uint8_t data_buf;
|
||||
esp_err_t ret;
|
||||
ESP_LOGI(TAG, "Found touch panel controller");
|
||||
if ((ret = ft6x06_i2c_read8(dev_addr, FT6X36_PANEL_ID_REG, &data_buf) != ESP_OK))
|
||||
ESP_LOGE(TAG, "Error reading from device: %s",
|
||||
esp_err_to_name(ret)); // Only show error the first time
|
||||
ESP_LOGI(TAG, "\tDevice ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_CHIPSELECT_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tChip ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_DEV_MODE_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tDevice mode: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_FIRMWARE_ID_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tFirmware ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_RELEASECODE_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tRelease code: 0x%02x", data_buf);
|
||||
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
ft6x36_touch_queue_handle = xQueueCreate( FT6X36_TOUCH_QUEUE_ELEMENTS, sizeof( ft6x36_touch_t ) );
|
||||
if( ft6x36_touch_queue_handle == NULL )
|
||||
{
|
||||
ESP_LOGE( TAG, "\tError creating touch input FreeRTOS queue" );
|
||||
return;
|
||||
}
|
||||
xQueueSend( ft6x36_touch_queue_handle, &touch_inputs, 0 );
|
||||
/* I2C master is initialized before calling this function */
|
||||
#if 0
|
||||
esp_err_t code = i2c_master_init();
|
||||
#else
|
||||
esp_err_t code = ESP_OK;
|
||||
#endif
|
||||
|
||||
if (code != ESP_OK) {
|
||||
ft6x36_status.inited = false;
|
||||
ESP_LOGE(TAG, "Error during I2C init %s", esp_err_to_name(code));
|
||||
} else {
|
||||
ft6x36_status.inited = true;
|
||||
current_dev_addr = dev_addr;
|
||||
uint8_t data_buf;
|
||||
esp_err_t ret;
|
||||
ESP_LOGI(TAG, "Found touch panel controller");
|
||||
if ((ret = ft6x06_i2c_read8(dev_addr, FT6X36_PANEL_ID_REG, &data_buf) != ESP_OK))
|
||||
ESP_LOGE(TAG, "Error reading from device: %s",
|
||||
esp_err_to_name(ret)); // Only show error the first time
|
||||
ESP_LOGI(TAG, "\tDevice ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_CHIPSELECT_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tChip ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_DEV_MODE_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tDevice mode: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_FIRMWARE_ID_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tFirmware ID: 0x%02x", data_buf);
|
||||
|
||||
ft6x06_i2c_read8(dev_addr, FT6X36_RELEASECODE_REG, &data_buf);
|
||||
ESP_LOGI(TAG, "\tRelease code: 0x%02x", data_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,55 +120,84 @@ void ft6x06_init(uint16_t dev_addr) {
|
|||
* @retval Always false
|
||||
*/
|
||||
bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
|
||||
if (!ft6x36_status.inited) {
|
||||
ESP_LOGE(TAG, "Init first!");
|
||||
return 0x00;
|
||||
}
|
||||
uint8_t data_buf[5]; // 1 byte status, 2 bytes X, 2 bytes Y
|
||||
uint8_t data_xy[4]; // 2 bytes X | 2 bytes Y
|
||||
uint8_t touch_pnt_cnt; // Number of detected touch points
|
||||
static int16_t last_x = 0; // 12bit pixel value
|
||||
static int16_t last_y = 0; // 12bit pixel value
|
||||
|
||||
esp_err_t ret = lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, current_dev_addr, FT6X36_TD_STAT_REG, &data_buf[0], 5);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error talking to touch IC: %s", esp_err_to_name(ret));
|
||||
}
|
||||
uint8_t touch_pnt_cnt = data_buf[0]; // Number of detected touch points
|
||||
|
||||
if (ret != ESP_OK || touch_pnt_cnt != 1) { // ignore no touch & multi touch
|
||||
if ( touch_inputs.current_state != LV_INDEV_STATE_REL)
|
||||
{
|
||||
touch_inputs.current_state = LV_INDEV_STATE_REL;
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs );
|
||||
#endif
|
||||
}
|
||||
data->point.x = touch_inputs.last_x;
|
||||
data->point.y = touch_inputs.last_y;
|
||||
data->state = touch_inputs.current_state;
|
||||
ft6x06_i2c_read8(current_dev_addr, FT6X36_TD_STAT_REG, &touch_pnt_cnt);
|
||||
if (touch_pnt_cnt != 1) { // ignore no touch & multi touch
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
return false;
|
||||
}
|
||||
|
||||
touch_inputs.current_state = LV_INDEV_STATE_PR;
|
||||
touch_inputs.last_x = ((data_buf[1] & FT6X36_MSB_MASK) << 8) | (data_buf[2] & FT6X36_LSB_MASK);
|
||||
touch_inputs.last_y = ((data_buf[3] & FT6X36_MSB_MASK) << 8) | (data_buf[4] & FT6X36_LSB_MASK);
|
||||
// Read X value
|
||||
i2c_cmd_handle_t i2c_cmd = i2c_cmd_link_create();
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (current_dev_addr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(i2c_cmd, FT6X36_P1_XH_REG, I2C_MASTER_ACK);
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (current_dev_addr << 1) | I2C_MASTER_READ, true);
|
||||
|
||||
i2c_master_read_byte(i2c_cmd, &data_xy[0], I2C_MASTER_ACK); // reads FT6X36_P1_XH_REG
|
||||
i2c_master_read_byte(i2c_cmd, &data_xy[1], I2C_MASTER_NACK); // reads FT6X36_P1_XL_REG
|
||||
i2c_master_stop(i2c_cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(TOUCH_I2C_PORT, i2c_cmd, 1000 / portTICK_RATE_MS);
|
||||
i2c_cmd_link_delete(i2c_cmd);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error getting X coordinates: %s", esp_err_to_name(ret));
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_REL; // no touch detected
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read Y value
|
||||
i2c_cmd = i2c_cmd_link_create();
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (current_dev_addr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(i2c_cmd, FT6X36_P1_YH_REG, I2C_MASTER_ACK);
|
||||
|
||||
i2c_master_start(i2c_cmd);
|
||||
i2c_master_write_byte(i2c_cmd, (current_dev_addr << 1) | I2C_MASTER_READ, true);
|
||||
|
||||
i2c_master_read_byte(i2c_cmd, &data_xy[2], I2C_MASTER_ACK); // reads FT6X36_P1_YH_REG
|
||||
i2c_master_read_byte(i2c_cmd, &data_xy[3], I2C_MASTER_NACK); // reads FT6X36_P1_YL_REG
|
||||
i2c_master_stop(i2c_cmd);
|
||||
ret = i2c_master_cmd_begin(TOUCH_I2C_PORT, i2c_cmd, 1000 / portTICK_RATE_MS);
|
||||
i2c_cmd_link_delete(i2c_cmd);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error getting Y coordinates: %s", esp_err_to_name(ret));
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_REL; // no touch detected
|
||||
return false;
|
||||
}
|
||||
|
||||
last_x = ((data_xy[0] & FT6X36_MSB_MASK) << 8) | (data_xy[1] & FT6X36_LSB_MASK);
|
||||
last_y = ((data_xy[2] & FT6X36_MSB_MASK) << 8) | (data_xy[3] & FT6X36_LSB_MASK);
|
||||
|
||||
#if CONFIG_LV_FT6X36_SWAPXY
|
||||
int16_t swap_buf = touch_inputs.last_x;
|
||||
touch_inputs.last_x = touch_inputs.last_y;
|
||||
touch_inputs.last_y = swap_buf;
|
||||
int16_t swap_buf = last_x;
|
||||
last_x = last_y;
|
||||
last_y = swap_buf;
|
||||
#endif
|
||||
#if CONFIG_LV_FT6X36_INVERT_X
|
||||
touch_inputs.last_x = LV_HOR_RES - touch_inputs.last_x;
|
||||
last_x = LV_HOR_RES - last_x;
|
||||
#endif
|
||||
#if CONFIG_LV_FT6X36_INVERT_Y
|
||||
touch_inputs.last_y = LV_VER_RES - touch_inputs.last_y;
|
||||
last_y = LV_VER_RES - last_y;
|
||||
#endif
|
||||
data->point.x = touch_inputs.last_x;
|
||||
data->point.y = touch_inputs.last_y;
|
||||
data->state = touch_inputs.current_state;
|
||||
ESP_LOGD(TAG, "X=%u Y=%u", data->point.x, data->point.y);
|
||||
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs );
|
||||
#endif
|
||||
|
||||
//uint16_t lcd_x = p.x *1.37; // Max 240
|
||||
//uint16_t lcd_y = p.y *1.51; // Max 400
|
||||
data->point.x = last_x *1.37;
|
||||
data->point.y = last_y *1.51;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
/*
|
||||
* Copyright © 2020 Wolfgang Christl
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
@ -23,10 +23,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#endif
|
||||
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
|
@ -149,16 +145,6 @@ typedef struct {
|
|||
bool inited;
|
||||
} ft6x36_status_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t last_x;
|
||||
int16_t last_y;
|
||||
lv_indev_state_t current_state;
|
||||
} ft6x36_touch_t;
|
||||
|
||||
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||
extern QueueHandle_t ft6x36_touch_queue_handle;
|
||||
#endif
|
||||
/**
|
||||
* @brief Initialize for FT6x36 communication via I2C
|
||||
* @param dev_addr: Device address on communication Bus (I2C slave address of FT6X36).
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <lvgl/lvgl.h>
|
||||
#endif
|
||||
#include "l58.h"
|
||||
#include "../lvgl_i2c_conf.h"
|
||||
// Cale touch implementation
|
||||
#include "L58Touch.h"
|
||||
L58Touch Touch(CONFIG_LV_TOUCH_INT);
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
#include "touch_driver.h"
|
||||
#include "tp_spi.h"
|
||||
|
||||
#include "tp_i2c.h"
|
||||
// Is not being included in CMakeLists.txt (Research why)
|
||||
#include "l58.h"
|
||||
|
||||
|
||||
void touch_driver_init(void)
|
||||
{
|
||||
#if defined (CONFIG_LV_TOUCH_CONTROLLER_XPT2046)
|
||||
|
@ -25,16 +24,10 @@ void touch_driver_init(void)
|
|||
/* nothing to do */
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875)
|
||||
ra8875_touch_init();
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||
gt911_init(GT911_I2C_SLAVE_ADDR);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LVGL_VERSION_MAJOR >= 8
|
||||
void touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
#else
|
||||
bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
#endif
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
|
@ -53,14 +46,8 @@ bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
|||
res = FT81x_read(drv, data);
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875)
|
||||
res = ra8875_touch_read(drv, data);
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||
res = gt911_read(drv, data);
|
||||
#endif
|
||||
|
||||
#if LVGL_VERSION_MAJOR >= 8
|
||||
data->continue_reading = res;
|
||||
#else
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ extern "C" {
|
|||
#include "FT81x.h"
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875)
|
||||
#include "ra8875_touch.h"
|
||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||
#include "gt911.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
|
@ -44,12 +42,7 @@ extern "C" {
|
|||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void touch_driver_init(void);
|
||||
|
||||
#if LVGL_VERSION_MAJOR >= 8
|
||||
void touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
||||
#else
|
||||
bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
43
lvgl_touch/tp_i2c.c
Normal file
43
lvgl_touch/tp_i2c.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright © 2020 Wolfgang Christl
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <driver/i2c.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#define I2C_MASTER_FREQ_HZ 100000 /* 100kHz*/
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0 /* I2C master doesn't need buffer */
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0 /* I2C master doesn't need buffer */
|
||||
|
||||
/**
|
||||
* @brief ESP32 I2C init as master
|
||||
* @ret ESP32 error code
|
||||
*/
|
||||
esp_err_t i2c_master_init(void) {
|
||||
int i2c_master_port = I2C_NUM_0;
|
||||
i2c_config_t conf;
|
||||
conf.mode = I2C_MODE_MASTER;
|
||||
conf.sda_io_num = CONFIG_LV_TOUCH_I2C_SDA;
|
||||
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
conf.scl_io_num = CONFIG_LV_TOUCH_I2C_SCL;
|
||||
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
|
||||
i2c_param_config(i2c_master_port, &conf);
|
||||
return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
|
||||
}
|
36
lvgl_touch/tp_i2c.h
Normal file
36
lvgl_touch/tp_i2c.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright © 2020 Wolfgang Christl
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the “Software”), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __TS_H
|
||||
#define __TS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
esp_err_t i2c_master_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TS_H */
|
Loading…
Add table
Add a link
Reference in a new issue